无法创建物理实体

无法创建物理实体

本文介绍了SpriteKit PhysicsBody:无法创建物理实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的游戏中有一个玩家,它有两个飞行,坠落状态.他们每个人都有一个图像:player_flying,player_falling相应.我还使用身体来检测碰撞.当我使用一种纹理时,它完全可以正常工作.但是,当我尝试在不同条件下使用不同纹理同时使用这两种方法时,它在日志中显示了错误.我正在这样尝试:

I have a player in my game, it has two states flying, falling. Each of them has an image: player_flying, player_falling correspondingly. I am also using a physical bodies to detect collision. It is completely normally functioning when I use one texture. But when I am trying to use both in different conditions using different textures, it shows me an error in the log. I am trying it like that:

if (self.player.physicsBody.velocity.dy > 30) {
    self.player.texture = [SKTexture textureWithImageNamed:@"player_flying"];
    self.player.physicsBody = [SKPhysicsBody bodyWithTexture:self.player.texture
                                                        size:self.player.size];
}
else
{
    self.player.texture = [SKTexture textureWithImageNamed:@"player_falling"];
    self.player.physicsBody = [SKPhysicsBody bodyWithTexture:self.player.texture
                                                        size:self.player.size];
}

错误是:

推荐答案

感谢0x141E,我发现我的纹理周围有一些白色的污点,删除后,一切都开始起作用.现在我想知道如何在代表我的物理对象的纹理周围隐藏笔划.

thanks 0x141E, i found out that my texture had some white shit around it, after I've deleted it, everything started to work. Now i am wondering how to hide stroke around my texture which represents my physical object.

这篇关于SpriteKit PhysicsBody:无法创建物理实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 03:00