gpt4 book ai didi

ios - Objective c SpriteKit 节点

转载 作者:行者123 更新时间:2023-11-28 18:55:27 26 4
gpt4 key购买 nike

我想在 SpriteKit 中制作简单的游戏,基本上我想做的是让节点在触摸时显示并在大约 5 秒后消失。这是用于板的代码示例:

SKSpriteNode* board = [[SkSpriteNode alloc] initWithImageNamed:@"board"];
board.name = boardCategoryName;
board.position = CGPointMake (CGRectGetMaxX(self.frame),board.frame.seize.height *4.6f);
[self.addChild:board];
board.physicsBody = [SKphysicsBody bodyWithRectangleOFSize:board.frame.size];
board.physicsBody.restitution =0.1f;
board.physicsBody.friction = 0.4f;
board.physicsBody.dynamic = No;

最佳答案

Mr T 确实提供了 1 个选项,但我个人会使用 SKActionsequencewaitForDurationremoveFromParent() 在处理节点时,像这样:

let waitDuration = SKAction.waitForDuration(5)
let killAction = SKAction.removeFromParent()
let seqAction = SKAction.sequence([waitDuration,killAction])
....
board.runAction(seqAction)

关于ios - Objective c SpriteKit 节点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34292515/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com