ios - SKSpriteNode 不稳定的滑动?
<p><p><strong>我创建了以下 Sprite 套件节点:</strong></p>
<pre><code>SKSpriteNode *megadeth;
megadeth = ;
megadeth.name = @"awesome";
</code></pre>
<p><strong>并添加滑动手势如下:</strong></p>
<pre><code>-(void)didMoveToView:(SKView *)view{
UISwipeGestureRecognizer *recognizerUp = [ initWithTarget:self action:@selector(handleSwipeUp:)];
recognizerUp.direction = UISwipeGestureRecognizerDirectionUp;
[ addGestureRecognizer:recognizerUp];
UISwipeGestureRecognizer *recognizerDn = [ initWithTarget:self action:@selector(handleSwipeDn:)];
recognizerDn.direction = UISwipeGestureRecognizerDirectionDown;
[ addGestureRecognizer:recognizerDn];
}
- (void)handleSwipeUp:(UISwipeGestureRecognizer *)sender{
NSLog(@"Node Swiped Up");
if (sender.state == UIGestureRecognizerStateEnded)
{
CGPoint touchLocation = ;
touchLocation = ;
SKSpriteNode *touchedNode = (SKSpriteNode *);
if(){
NSLog(@"Perform Action on AWESOME node");
SKAction *moveUp = ;
SKAction *fade = ;
//SKAction *remove = ;
SKAction *sequence = ];
;
}
}
}
</code></pre>
<p>当我滑动节点时,它会滑动,但它会回到原来的位置,然后淡出以移除。</p>
<p>我想要的是,当我刷卡时,它应该移动到刷卡的位置并移除。我在这里错过了什么吗?</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p><strong>我使用 <code></code> 而不是 <code></code> ,这让一切都像魅力一样工作</strong> </p>
<p><strong>这是更新后的 <code>handleSwipeUp:</code> 方法:</strong></p>
<pre><code>- (void)handleSwipeUp:(UISwipeGestureRecognizer *)sender{
NSLog(@"Node Swiped Up");
//if (sender.state == UIGestureRecognizerStateEnded)
//{
CGPoint touchLocation = ;
touchLocation = ;
SKSpriteNode *touchedNode = (SKSpriteNode *);
if(){
NSLog(@"Perform Action on AWESOME node");
**SKAction *moveUp = ;**
//SKAction *fade = ;
SKAction *remove = ;
SKAction *sequence = ];
;
}
//}
</code></pre>
<p>}</p>
<p>希望对你有帮助!!!</p></p>
<p style="font-size: 20px;">关于ios - SKSpriteNode 不稳定的滑动?,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/29065278/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/29065278/
</a>
</p>
页:
[1]