寻找 Corona SDK 问题(平台碰撞)。

我正在使用预碰撞函数让我的玩家穿过平台,像这样:

local function PhysicsPreCo(self,event)
    local Type = event.other.Type
    local PlayerY = self.y
    local PlatY = event.other.y

    if Type == "Platform" then
      if PlayerY -8  > PlatY then event.contact.isEnabled = false ; print("H") end
    end
end

所以到目前为止,一切都可以使我的玩家正确地穿过平台,但有时当我太早跳到平台前面时,我的玩家会撞到平台的左侧而不是穿过去。

我想使用内容宽度和内容高度来识别左侧平台,并告诉物理引擎在撞到它时穿过去,但我没有成功找到解决方法。

任何帮助将不胜感激,非常感谢:)

点赞
用户1376249
用户1376249

下面是关于碰撞的教程,包括单侧碰撞。

http://coronalabs.com/blog/2012/11/27/introducing-physics-event-contact/

有一个现成的项目演示了所有的功能

https://www.dropbox.com/s/4rbltonmrp5xwri/PhysicsContact.zip

为了运行上面的代码,你需要在config.lua的内容部分添加

graphicsCompatibility = 1
2014-08-15 00:29:34