【发布时间】:2016-01-17 21:33:52
【问题描述】:
我找到一些代码可以帮助我创建一个按钮,当它按下时可以动画。但它在objective-c上。一般来说,我可以理解这段代码是什么,但我无法快速正确地翻译它。请帮我快速翻译一下。非常感谢。
1.
- (SKSpriteNode *)fireButtonNode
{
SKSpriteNode *fireNode = [SKSpriteNode spriteNodeWithImageNamed:@"fireButton.png"];
fireNode.position = CGPointMake(fireButtonX,fireButtonY);
fireNode.name = @"fireButtonNode";
fireNode.zPosition = 1.0;
return fireNode;
}
2.
- (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:@"fireButtonNode"]) {
}
}
【问题讨论】:
-
@Mr.Tigr 哦,我大体上同意 IInspectable 所说的话。我为你做了一个例子,因为它不需要太多时间,特别是因为我注意到你是一个新成员,但最好包括你迄今为止尝试过的东西来展示解决问题的努力问题。这样,您就不会面临被否决的风险。
标签: ios swift sprite-kit