skaction

Swift 1.2 bug: different behavior between iOS 7.1 and 8.3 while removing SKSpriteNode from parent

China☆狼群 提交于 2019-12-24 04:04:35
问题 Sample project: https://github.com/wilkinho/RemoveFromParentTest Swift version: 1.2 Xcode version: 6.3 I try to remove a SKSpriteNode from its parent and add it back to the SKScene within its own SKAction run block (or callback). The result differs in iOS 7.1 and 8.3. In iOS 7.1, after touching the device, the console prints: sprite.parent:Optional(<SKScene> name:'(null)' frame:{{0, 0}, {320, 568}}) sprite.scene:nil sprite2.parent:Optional(<SKScene> name:'(null)' frame:{{0, 0}, {320, 568}})

SKAction: how to generate a random delay in generation of nodes

夙愿已清 提交于 2019-12-23 04:02:31
问题 I use the following piece of code to generate SKNodes periodically. Is there a way to make the period of generation of these SKNodes random. Specifically, how do I make the "delayFish" in the following code an action with a random delay? [self removeActionForKey:@"fishSpawn"]; SKAction* spawnFish = [SKAction performSelector:@selector(spawnLittleFishes) onTarget:self]; SKAction* delayFish = [SKAction waitForDuration:3.0/_moving.speed]; SKAction* spawnThenDelayFish = [SKAction sequence:@

OpenAL vs AVAudioPlayer vs other techniques for playing sounds

巧了我就是萌 提交于 2019-12-22 08:51:53
问题 I know that OpenAL is fast library but it doesn't support any compressed audio format and it's not so easy to use... AVAudioPlayer is not so fast, but supports wide range file formats, as well as compressed formats like mp3. Also there is an SKAction class which can play a sound, as well as SystemSoundID... I have few questions: What would be a preferred way/player/technique to play : sound effects(multiple at the time)? sound effects which can be sometimes repeated after small time delay

iOS SpriteKit SKAction completion call not working/creating odd results

雨燕双飞 提交于 2019-12-21 21:31:05
问题 I'm trying to have a SKNode move onto the screen on command. I've set up the following SKAction chain so that 1) The node moves up and offscreen, then 2) the node moves down into a starting place, then 3) starts moving around. I've used the following code to try and implement this: SKAction *moveUp = [SKAction moveTo: shipIntroSpot1 duration:3.0]; SKAction *moveDown = [SKAction moveTo:shipSpot1 duration:ship1MovementSpeed]; [self enumerateChildNodesWithName:@"ship1" usingBlock:^(SKNode *node,

How to assign Keys to SKActions in Swift

拈花ヽ惹草 提交于 2019-12-21 14:06:34
问题 I was hoping someone would be able to help me with this problem. I can't seem to find a way to assign a key to an SKAction for Sprite Kit for the removeActionWithKey method. I have also tried assinging the action to a key in a dictionary but the program didn't recognize the key assignment and thus returned a nil value. Here is what I tried to do: var textureanimation = SKAction.repeatActionForever(SKAction.animateWithTextures(_walkingframes, timePerFrame: 0.1)) var dictionary = ["animation":

checking if an SKNode is running a SKAction

谁说我不能喝 提交于 2019-12-21 09:29:17
问题 How can I check whether a SKNode is already running an action before running an action on it? I want to be able to do something like... if (![mySprite isRunningActions]) { [mySprite runAction:action]; } If there is no built in way I'm thinking of creating a new BOOL property for holding the action state. 回答1: Look at using named actions using any of the SKAction key-based methods. So you would instead run your action using the named equivalent to runAction: which is runAction:withKey: . If an

SpriteKit - How to fix distortion in Node's animation?

不打扰是莪最后的温柔 提交于 2019-12-20 05:47:24
问题 I have created an animation of various PNGs, but there are various frames that stretch to the border so the node is 'filled'. The animation should look like the GIF that I have created using the same pictures. Does anybody know how to make the animation look like the GIF? GIF: Gif: Animation should look like this Actual: Extra slow Actual result of the code Border: Here you can see the border of the physics body that has the same size of the "node's border" I have tried to fix the problem by

Randomizing node movement duration

若如初见. 提交于 2019-12-20 05:30:34
问题 I am making a game in SpriteKit and I have a node that is moving back and forth across the screen and repeating using the code: let moveRight = SKAction.moveByX(frame.size.width/2.8, y: 0, duration: 1.5) let moveLeft = SKAction.moveByX(-frame.size.width/2.8, y: 0, duration: 1.5) let texRight = SKAction.setTexture(SKTexture(imageNamed: "Drake2")) let texLeft = SKAction.setTexture(SKTexture(imageNamed: "Drake1")) let moveBackAndForth = SKAction.repeatActionForever(SKAction.sequence([texRight,

runAction on SKNode does not complete

人走茶凉 提交于 2019-12-19 11:53:44
问题 I use a subclass NSOperation to obtain serial execution of SKAction as described in this question: How to subclass NSOperation in Swift to queue SKAction objects for serial execution? I then modified the previous subclass in order to group animations for several nodes: https://stackoverflow.com/a/30600718/540780 At last, as I needed to run completion block after SKAction completed, I slightly modified the code by using an array of struct instead an array of tuples. struct ActionData { let

SKScene becomes unresponsive while being Idle

混江龙づ霸主 提交于 2019-12-19 11:36:10
问题 Hello I have a SceneKit game. All the game play is in one scene and when the game is over the sprit kit overlay acts as a game over screen and when they hit play again the sprite kit labels disappear and the game resets all in the same scene. My issuing is coming in the game over. If the user hits the replay button within a few seconds then everything goes well. But if the user sits on the game over place for over five seconds then the scene freezes. I am really confused as the app is idle