简体   繁体   English

SpriteKit问题

[英]SpriteKit Questions

I am new to Xcode and SpriteKit. 我是Xcode和SpriteKit的新手。 I have the following queries. 我有以下查询。 Please can someone help me! 请有人可以帮我!

  1. I am trying to make a game on Xcode. 我正在尝试在Xcode上制作游戏。 I have a scrolling background. 我有滚动背景。 I have made a long background which I want to continuously play on a loop. 我的背景很长,我想不断循环播放。 When the background's dimension was 768X10240 for IPAD (non-retina), my code didn't show the background. 当IPAD(非视网膜)的背景尺寸为768X10240时,我的代码未显示背景。 However, when i reduced it to 768X2048 and played it on a loop, it did. 但是,当我将其缩小为768X2048并循环播放时,它确实做到了。 So, I guess there's nothing wrong with my code. 因此,我想我的代码没有错。 But why isn't a really long background working? 但是,为什么没有那么长的工作背景呢?

  2. Is there a way to stop the "update" method from running, whilst letting some of the SKActions to run? 有没有一种方法可以停止运行“更新”方法,同时让某些SKAction运行? I tried using self.scene.view.paused which stops everything. 我尝试使用self.scene.view.paused停止一切。

  3. Is it possible to pause an SKAction half way? 是否可以将SKAction暂停一半? Say, suppose its going to run for 5 seconds, and I pause my scene after 2 seconds, and later unpause it. 说,假设它要运行5秒钟,然后我在2秒钟后暂停场景,然后将其取消暂停。 I want the SKAction to begin from where it had stopped, but its not happening. 我希望SKAction从停止的地方开始,但是没有发生。 I tried, self.speed = 0 我试过了,self.speed = 0

  4. Is it possible to do an SKAction on a given position and not on a child node? 是否可以在给定位置而不是子节点上执行SKAction?

Please help! 请帮忙!

Thank you 谢谢

  1. Without seeing your code, it's impossible to say what you did wrong. 如果不看代码,就不可能说出自己做错了什么。 Successfully running a background image loop has nothing to do with the size of the image. 成功运行背景图像循环与图像大小无关。 However, having a very large images is a bad idea as it might increase your memory requirements to an unacceptable level. 但是,拥有非常大的图像不是一个好主意,因为它可能会将您的内存需求增加到无法接受的水平。 Consider using smaller images or tiled images using an application like Tiled. 考虑使用诸如Tiled之类的应用程序使用较小的图像或平铺的图像。 Also, use a texture atlas all the time, every time! 另外,每次都使用纹理图集!

  2. You cannot stop the update: method from running. 您无法停止运行update:方法。 The update method is what makes SKActions possible. 更新方法使SKActions成为可能。

  3. You cannot pause a SKAction once you have started it unless the pause is part of an action sequence of the action. 启动SKAction后,您无法暂停它,除非该暂停是该动作的动作序列的一部分。 You can stop a SKAction with the command [self removeActionForKey:@"animation"]; 您可以使用命令[self removeActionForKey:@"animation"];停止SKAction [self removeActionForKey:@"animation"]; where self is the sprite. 自我是精灵。 Depending on the animation you are running, this might appear to pause the animation. 根据您正在运行的动画,这可能会暂停动画。

  4. This question makes no sense. 这个问题没有道理。

hi dude just go through 嗨,伙计,只是经历

sprite kit documentation before creating any game in sprite kit. 在Sprite Kit中创建任何游戏之前,请先获取Sprite Kit文档。

1)for scrolling background you are using huge size image just breakdown your image smaller size and save them inside a folder name that folder yourfoldername.atlas sprite kit automatically treated that folder as a texture atlas 1)对于滚动背景,您正在使用大尺寸的图像,只需分解较小的图像并将其保存在文件夹yourfoldername的文件夹名称内即可.atlas sprite工具包会自动将该文件夹视为纹理地图集

2)you cannot stop update loop at least their is no inbulit mehod for this but you can create your own method for it for eg 2)您不能停止更新循环,至少它们不是为此的非常规方法,但是您可以为此创建自己的方法

 boolean stopGame=FALSE;
 -(void)stopmyGame
{
    stopGame=TRUE;
 }

-(void)update:(CFTimeInterval)currentTime {
   if(stopGame)
  {
    return;
  }
  //your update code
 }

3) yeah its possible to stop a SKAction in midway there is two way for that 3)是的,有可能在中途停止SKAction,有两种方法

1) create a SKAction with key 1)用键创建一个SKAction

for eg. 例如 SKAction *moveTo= [SKAction moveToY:1000 duration:0.5]; SKAction * moveTo = [SKAction moveToY:1000持续时间:0.5]; [self runAction:up withKey:@"moveTo"]; [self runAction:up withKey:@“ moveTo”];

 [self removeActionForKey:@"moveTo"];

2) setting object.speed=0; 2)设置object.speed = 0; where object is your own class extending from sprite kit base class 其中对象是您自己的类,它是从Sprite Kit基础类扩展的

4) why u need a action on a given position ...:) 4)为什么您需要对给定位置执行操作... :)

5)you can use koboldkit a framework created on top of sprite kit have all the things that spritekit don't have 5)您可以使用koboldkit在sprite kit之上创建的框架来拥有spritekit所没有的所有东西

1)Physics Debug Drawing 1)物理调试图

2) Super-Fast Renderer TMX Read & Write 2)Super-Fast Renderer TMX读写

3)Plug-In Code for Nodes Many Built-In Behaviors 3)用于许多内置行为的节点的插入代码

4)Audio Engine 4)音频引擎

and full supported koboldkit forum 和完整支持的koboldkit论坛

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM