SpriteKit PhysicsBody:无法创建物理体 [英] SpriteKit PhysicsBody: Could not create physics body

查看:20
本文介绍了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];
}

错误是:

2014-08-30 12:55:47.515 kalabaska[1569:50535] PhysicsBody:无法创建物理实体.

2014-08-30 12:55:47.515 kalabaska[1569:50535] PhysicsBody: Could not create physics body.

推荐答案

感谢 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:无法创建物理体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆