skaction

add SKAction to Sprite queue run one after another

时光总嘲笑我的痴心妄想 提交于 2020-01-01 03:34:12
问题 I listen to touch and add SKAction to a sprite. If existing actions are not complete yet, I want the action to be added to a queue so it will execute one after another. Any experienced similar design? I did using Array and Block. If there is any easier approach? @interface GAPMyScene() @property(strong,nonatomic)SKSpriteNode*ufo; @property(strong,nonatomic)NSMutableArray*animationQueue; @property(copy,nonatomic)void(^completeMove)(); @end @implementation GAPMyScene -(id)initWithSize:(CGSize

What are good ways to work around the encoding limitation of SKAction code blocks during application state preservation?

廉价感情. 提交于 2019-12-31 03:54:09
问题 Problem When the node hierarchy is encoded, as is common during application state preservation or a “game save”, nodes running SKAction actions with code blocks must be handled specially, since the code blocks cannot be encoded. Example 1: Delayed Callback after Animation Here, an orc has been killed. It is animated to fade out and then remove itself from the node hierarchy: SKAction *fadeAction = [SKAction fadeOutWithDuration:3.0]; SKAction *removeAction = [SKAction removeFromParent];

Spritekit crashes when entering background

橙三吉。 提交于 2019-12-30 08:10:12
问题 Allright guys, I've been developing an app in which I have a NSMutableDictionary with an SKAction object in it. The SKAction is for playing a sound. This all works well, except ... the app crashes upon entering background with the following stack trace: * thread #1: tid = 0x187d7, 0x3461b932 libGPUSupportMercury.dylib`gpus_ReturnNotPermittedKillClient + 10, queue = 'com.apple.spritekit.renderQueue, stop reason = EXC_BAD_ACCESS (code=1, address=0x1) frame #0: 0x3461b932 libGPUSupportMercury

Stop SKAction that RepeatsForever - Sprite Kit

给你一囗甜甜゛ 提交于 2019-12-28 15:13:08
问题 I want to run two animations on my spriteNode depending on its rotation. If the value is negative run one of the animations, if it's positive run the other. And I managed to do that (kind of) but I have a problem. If Animation1 is running, and zRotation changes to positive, they both run because they are repeating forever. So I did this : NSMutableArray *walkingTextures = [NSMutableArray arrayWithCapacity:14]; for (int i = 1; i < 15; i++) { NSString *textureName = [NSString stringWithFormat:@

Stop SKAction that RepeatsForever - Sprite Kit

做~自己de王妃 提交于 2019-12-28 15:12:31
问题 I want to run two animations on my spriteNode depending on its rotation. If the value is negative run one of the animations, if it's positive run the other. And I managed to do that (kind of) but I have a problem. If Animation1 is running, and zRotation changes to positive, they both run because they are repeating forever. So I did this : NSMutableArray *walkingTextures = [NSMutableArray arrayWithCapacity:14]; for (int i = 1; i < 15; i++) { NSString *textureName = [NSString stringWithFormat:@

Update Function Does Not Keep Up With Moving Sprite

点点圈 提交于 2019-12-25 16:51:42
问题 I have two sprites which a flush against each other. I'm moving one of the sprites around using a SKAction and moving the other sprite using the update function. Every time the update function is called, it calculates the position the second sprite needs to be at so that it continues to be flush against the first sprite. However, it seems the update function can not move the second sprite fast enough, as a gap appears between the two sprites. I assume the SKAction repositioning of the first

SKAction waitForDuration() blocking SKAction sequence

拜拜、爱过 提交于 2019-12-24 18:32:48
问题 self.runAction(SKAction.sequence([ SKAction.waitForDuration(1), SKAction.runBlock({ self.speed = 0; print("pause") }), SKAction.waitForDuration(0.1), SKAction.runBlock({ self.speed = realSpeed; print("resume") }) ])) The last skaction does not get called. But when I remove the second waitForDuration, the last skaction gets called. self.runAction(SKAction.sequence([ SKAction.waitForDuration(1), SKAction.runBlock({ self.speed = 0; print("pause") }), SKAction.runBlock({ self.speed = realSpeed;

Applying impulses in SpriteKit

我的未来我决定 提交于 2019-12-24 12:56:15
问题 I am working on a simple game where a player advances up through a level by collecting coins. Each coin that the player collects moves them further in the level. Here is a picture that explains it a little more: There are two different kinds of coins - regular coins and 'special' coins. Regular coins give them a normal boost. Special coins should give the player a temporary extra boost. Special coins can always be found in the middle of regular coin group (As shown in the picture). My problem

How to implement SKActionTimingFunction?

被刻印的时光 ゝ 提交于 2019-12-24 12:34:34
问题 How do you implement SKActionTimingFunction in objective-c?. I've looked everywhere and I just found an example in swift. Thanks! 回答1: heres an example moveAction.timingFunction = ^float(float t){ return sin(t * M_PI/2); }; man i hate blocks in objective-c 回答2: In Swift 4.2: moveAction.timingFunction = { time -> Float in return sin(time * .pi/2) } 来源: https://stackoverflow.com/questions/28520521/how-to-implement-skactiontimingfunction

How to run or execute an SKAction from outside of the object?

荒凉一梦 提交于 2019-12-24 08:58:29
问题 I have some code like following: -(void) createBall { _ballSprite = [SKSpriteNode spriteNodeWithImageNamed:@"ball0001"]; _ballSprite.position = CGPointMake(firstNode.position.x, firstNode.position.y); SKAction *ballScale =[SKAction scaleXTo:-0.5 duration:0]; SKAction *ballMove = [SKAction moveByX:0 y:-300 duration:0]; SKAction *ballMoveScale = [SKAction sequence:@[ballScale,ballMove]; SKAction *ballScaleMove = [SKAction sequence:@[ballMove,ballScale]; //Unused variable [_ballSprite runAction