【发布时间】:2014-03-26 05:24:20
【问题描述】:
有没有办法将 skphysics 应用于动画角色?好的,当我在屏幕上移动播放器时,我让播放器播放动画,下面是它的动画代码,但是由于某种原因,当我想将物理应用于我的动画时,我收到一个错误,提示数据类型错误。 将“SKSpriteNode *_strong”发送到不兼容类型“CGRect”(又名“struct CGRect”)的参数
没有声誉,我无法回答我自己的问题,所以我在这里发帖。
其实没关系,我必须添加这个 _Player.frame,我希望这是正确的,并且正在为我的角色添加物理特性。但是,如果我错了,请纠正我。谢谢。
- (void) Player {
_Player = [SKSpriteNode spriteNodeWithImageNamed:@"bird"];
_Player.xScale = 0.88;
_Player.yScale = 0.88;
_Player.position = CGPointMake(100, 100);
[self addChild:_Player];
// 1
NSMutableArray *PlayerCh = [NSMutableArray arrayWithCapacity:2];
// 2
for (int i = 1; i < 2; i++) {
NSString *mytextureName = [NSString stringWithFormat:@"bird%d", i];
SKTexture *ItsTexture = [SKTexture textureWithImageNamed:mytextureName];
[PlayerCh addObject:ItsTexture];
}
// 3
for (int i = 2; i > 1; i--) {
NSString *mytextureName = [NSString stringWithFormat:@"bird%d", i];
SKTexture *ItsTexture = [SKTexture textureWithImageNamed:mytextureName];
[PlayerCh addObject:ItsTexture];
}
// 4
_PlayerAnimation = [SKAction animateWithTextures:PlayerCh timePerFrame:0.1];
// SKPHYSICS FOR PLAYER
SKPhysicsBody *MYPLAYER = [SKPhysicsBody bodyWithCircleOfRadius:_Player]; // I get a error here.
}
【问题讨论】:
标签: animation sprite-kit