control max speed in sprite kit
Tag : ios , By : Govind Bhavan
Date : March 29 2020, 07:55 AM
wish of those help I'm trying to control the max speed of my character in my game. When I move him I use this: , This is working good. - (void)didEvaluateActions
{
CGFloat maxSpeed = 600.0f;
if (self.heroShip.physicsBody.velocity.dx > maxSpeed) {
self.heroShip.physicsBody.velocity = CGVectorMake(maxSpeed, self.heroShip.physicsBody.velocity.dy);
} else if (self.heroShip.physicsBody.velocity.dx < -maxSpeed) {
self.heroShip.physicsBody.velocity = CGVectorMake(-maxSpeed, self.heroShip.physicsBody.velocity.dy);
}
if (self.heroShip.physicsBody.velocity.dy > maxSpeed) {
self.heroShip.physicsBody.velocity = CGVectorMake(self.heroShip.physicsBody.velocity.dx, maxSpeed);
} else if (self.heroShip.physicsBody.velocity.dy < -maxSpeed) {
self.heroShip.physicsBody.velocity = CGVectorMake(self.heroShip.physicsBody.velocity.dx, -maxSpeed);
}
}
|
iOS 7 Sprite Kit speed change for animation
Date : March 29 2020, 07:55 AM
this one helps. Look up the various types of SKActionTimingMode and apply the ones as needed to your situation. This will remove the need for anything like [SKAction speedTo:0.1 duration:0.5]. https://developer.apple.com/library/mac/documentation/SpriteKit/Reference/SKAction_Ref/Reference/Reference.html#//apple_ref/c/tdef/SKActionTimingModeSKAction *actionMoveUp = [SKAction moveToY:2 * node.size.height / 3 duration:0.5];
actionMoveUp.timingMode = SKActionTimingEaseOut;
SKAction *actionMoveDown = [SKAction moveToY:node.size.height / 2 duration:0.5];
actionMoveDown.timingMode = SKActionTimingEaseIn;
SKAction *actionMoveUpHalf = [SKAction moveToY:node.size.height duration:1];
actionMoveUp.timingMode = SKActionTimingEaseOut;
[node runAction:[SKAction repeatActionForever:
[SKAction sequence:@
[actionMoveUp,
actionMoveDown,
actionMoveUpHalf,
actionMoveDown]]]];
|
Wrong moving speed for sprite animation
Date : March 29 2020, 07:55 AM
like below fixes the issue You'd have to change the speed mechanism of the fish, By lowering the number you multiply with changing this.speedX= (tx/dist) * 1
this.speedX=(tx/dist) * 0.1
|
Previous sprite in paper2D flip book animation remains behind updated sprite animation
Date : March 29 2020, 07:55 AM
Hope that helps Never mind guys. I found out. By changing the papersprite character to a flipbook instead, I was able to cycle through the enums without error
|
Changing Sprite animation Speed (pygame)
Date : March 29 2020, 07:55 AM
help you fix your problem You can decouple the animation rate from the frame rate by tying it to time in some way. One way is to use pygame.time.get_ticks() to return the number of milliseconds since pygame.init() was called. If you store this value, you can measure how much time has elapsed and animate appropriately. def update(self):
self.elapsed = pygame.time.get_ticks() - self.elapsed
if self.elapsed > 500: # animate every half second
self.animate()
|