gpt4 book ai didi

android - 在 SpriteKit 上停用物理

转载 作者:行者123 更新时间:2023-11-29 02:52:51 25 4
gpt4 key购买 nike

我想暂时停用节点的物理功能。请帮我解决这个问题。

  SKSpriteNode * node = [SKSpriteNode spriteNodeWithImageNamed:@"blade.png"];
node.size = CGSizeMake(30, 30);
node.physicsBody = [SKPhysicsBody bodyWithRectangleOfSize:node.size];
node.physicsBody.dynamic = YES;
node.physicsBody.collisionBitMask = CharacterCategory;
node.physicsBody.categoryBitMask = ObjectCategory;
node.physicsBody.contactTestBitMask = CharacterCategory;
node.position = nd.Position;
node.physicsBody.mass = 10000;
SKAction * actfadein = [SKAction fadeInWithDuration:nd.FadeInDuration];
SKAction * actfadeout = [SKAction fadeOutWithDuration:nd.FadeOutDuration];
SKAction * wait = [SKAction waitForDuration:3];
SKAction * removephy = [SKAction runBlock:^(void){
// i tried to removeFromParent but it never comes back
}];
SKAction * activatephy = [SKAction runBlock:^(void){
//[self addChild:node];
}];
SKAction * myActions = [SKAction sequence:@[actfadeout,removephy,wait,activatephy,actfadein]];
[node runAction:[SKAction repeatActionForever:myActions]];
[FadeObjects addChild:node];

最佳答案

只需将 SKSpriteNodephysicsBody 属性设置为 nil。如果稍后需要再次应用物理,只需分配另一个 physicsBody

关于android - 在 SpriteKit 上停用物理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24284652/

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