Tob*_*oby 5 objective-c ios sprite-kit
我正在尝试使用SpriteKit,我正在构建一个人形角色,他使用多个图像文件进行面部表情.因此,我可以构建一个SKSpriteNode来使用一系列其他精灵来描绘这个角色,即每个手臂和腿以及头部的节点,但我想为脸部使用多个节点.在标准的UIKit中,您可以使用带有图像数组的UIImageView,它将使用您设置的持续时间自动为该数组设置动画.
NSArray *animationArray = [NSArray arrayWithObjects:
[UIImage imageNamed:@"image1.jpg"],
[UIImage imageNamed:@"image2.jpg"],
..., nil];
UIImageView *animationView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 400, 260)];
[self.view addSubview:animationView];
animationView.animationImages=animationArray;
animationView.animationDuration=1.5;
animationView.animationRepeatCount=0;
[animationView startAnimating];
Run Code Online (Sandbox Code Playgroud)
SpriteKit中的等价物是什么?
您可以使用它SKAction来创建动画,如下所示:
SKAction *animation = [SKAction animateWithTextures:_animationArray timePerFrame:0.1];
[self runAction:animation withKey:@"myAnimation"]; // self is e.g. SKSpriteNode object
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
733 次 |
| 最近记录: |