Ios 适用于3.5英寸和4英寸屏幕大小的Iphone的精灵套件游戏
我已经用Xcode 5开发了一个4英寸屏幕的Sprite工具包小游戏,但我想知道我是否可以以及如何在3.5英寸屏幕上使用它。当我用iPhone5打开应用程序时,一切正常,但如果我用iPhone4S模拟器打开应用程序,很多东西都隐藏在屏幕之外 我读了很多帖子,解决方案似乎有限制,但这是最好的解决方案吗?它和SpriteKit一起工作吗?你怎么能用它 例如,我将一个孩子放在如下位置:Ios 适用于3.5英寸和4英寸屏幕大小的Iphone的精灵套件游戏,ios,objective-c,iphone,Ios,Objective C,Iphone,我已经用Xcode 5开发了一个4英寸屏幕的Sprite工具包小游戏,但我想知道我是否可以以及如何在3.5英寸屏幕上使用它。当我用iPhone5打开应用程序时,一切正常,但如果我用iPhone4S模拟器打开应用程序,很多东西都隐藏在屏幕之外 我读了很多帖子,解决方案似乎有限制,但这是最好的解决方案吗?它和SpriteKit一起工作吗?你怎么能用它 例如,我将一个孩子放在如下位置: AAShareBubbles *shareBubbles = [[AAShareBubbles alloc] ini
AAShareBubbles *shareBubbles = [[AAShareBubbles alloc] initWithPoint:CGPointMake(self.view.frame.size.width/2, (self.view.frame.size.height/2)+170)
170是绝对位置。对于4英寸屏幕,大约(高度/2)+170可以,但对于3.5英寸屏幕则不行。对于不同的设备,您可以通过多种方法来实现这一点,可以为不同的设备大小创建不同的纹理LAS,也可以通过最简单的方法更改SKView 例如 将此行添加到viewController
#define IS_WIDESCREEN ( fabs( ( double )[ [ UIScreen mainScreen ] bounds ].size.height - ( double )568 ) < DBL_EPSILON )
-(void)addLoadingScene
{
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
if (IS_WIDESCREEN) {
//this code for iPhone 4 inches
//get device type _deviceType=iphonebig;
//define globalscaleX and globalscaleY in header fine
//where skview is reference of your view
_globalscaleX=(1024.0f*2)/(568*2);
_globalscaleY=(768.0f*2)/(320*2);
yourfirstScreen = [loadingScene sceneWithSize:CGSizeMake(_SKView.bounds.size.height*_globalscaleX, _milkhuntSKView.bounds.size.width*_globalscaleY)];
//please take a look at all the scaleMode defined by spritekit
yourfirstScreen.scaleMode = SKSceneScaleModeFill;
} else {
//this code for iPhone 3.5 inches
_deviceType=iphone;
_globalscaleX=(1024.0f*2)/(480*2);
_globalscaleY=(768.0f*2)/(320*2);
yourfirstScreen = [loadingScene sceneWithSize:CGSizeMake(_SKView.bounds.size.height.bounds.size.height*_globalscaleX, _SKView.bounds.size.height bounds.size.width*_globalscaleY)];
yourfirstScreen.scaleMode = SKSceneScaleModeFill;
}
} else {
//this code for iPad
_deviceType=ipad;
_globalscaleX=1.0f;
_globalscaleY=1.0f;
LoaderScreen = [loadingScene sceneWithSize:CGSizeMake(_SKView.bounds.size.height.bounds.size.height, _SKView.bounds.size.height.bounds.size.width)];
yourfirstScreen.scaleMode = SKSceneScaleModeAspectFill;
}
[_SKView presentScene:LoaderScreen];
}
#定义IS#u宽屏(晶圆厂((双)[[UIScreen mainScreen]边界].size.height-(双)568)
3.5英寸和4英寸之间的纵横比会有所不同,导致场景在3.5英寸屏幕上看起来不同,甚至有点挤压,但由于他是在缩放之后才想到这一点,因此缩放将是最快的解决方案。(否则需要重新设计场景以适应两种屏幕大小)是的。。。我认为它可以正常工作,但我需要在所有场景的游戏中插入这段代码,可能是在:-(id)initWithSize:(CGSize)size{if(self=[super initWithSize:size]){…
之后创建所有实例。然后我可以替换实例和属性的方法…这是思考问题的正确方法吗?