我在 SpriteKit 游戏中遇到纹理问题:
在touchesBegan
我做:
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
CGPoint location = [touch locationInNode:self];
SKNode *node = [self nodeAtPoint:location];
if ([node.name isEqualToString:@"worm"]) {
[node removeAllActions];
SKAction *change = [SKAction setTexture:[SKTexture textureWithImageNamed:@"worm2"]];
[node runAction:change];
此代码有效,但新纹理“worm2”已缩放,与应有的相比,您会发现它很糟糕。
来自 Apple 文档,https ://developer.apple.com/library/ios/documentation/SpriteKit/Reference/SKAction_Ref/Reference/Reference.html#//apple_ref/occ/clm/SKAction/setTexture:resize :
应该有方法: setTexture:resize:
但是从我放的图片中可以看出,这种方法不存在..
我错过了什么?
谢谢大家