精灵套件和游戏开发新手我正在Following tutorial @ Raywenderlich 学习。
WHAT I AM DOING ?
我在地图上实现了连续动作,在播放器上实现了重力,我知道旋转动作可以像这样添加到SKSpriteNode。
SKAction *action = [SKAction rotateByAngle:M_PI duration:1];
[myPlayer runAction:[SKAction repeatActionForever:action]];
我的重力玩家如下
MSPlayer.h
#import <SpriteKit/SpriteKit.h>
@interface MSPlayer : SKSpriteNode
@property (nonatomic, assign) CGPoint velocity;
- (void)update:(NSTimeInterval)delta;
@end
MSPlayer.m
#import "MSPlayer.h"
#import "SKTUtils.h"
@implementation MSPlayer
//2
- (instancetype)initWithImageNamed:(NSString *)name {
if (self == [super initWithImageNamed:name]) {
self.velocity = CGPointMake(0.0, 0.0);
}
return self;
}
- (void)update:(NSTimeInterval)delta {
//3
CGPoint gravity = CGPointMake(0.0, -10.0);
//4
CGPoint gravityStep = CGPointMultiplyScalar(gravity, delta);
//5
self.velocity = CGPointAdd(self.velocity, gravityStep);
CGPoint velocityStep = CGPointMultiplyScalar(self.velocity, delta);
//6
self.position = CGPointAdd(self.position, velocityStep);
}
-(CGRect)collisionBoundingBox {
return CGRectInset(self.frame, 2, 0);
}
@end
My Issue is
现在的问题是我希望Node旋转并让它随着重力跳跃,旋转在Node即将结束跳跃之前结束。应该怎么做才能使两个动画同时结束?
答案 0 :(得分:0)
为Jumping写另一个runAction
[myPlayer runAction:[SKAction repeatActionForever:runAction]];
在这里定义runAction。