CORONA SDK LUA HELP ..... COLLISION ERROR [英] CORONA SDK LUA HELP..... COLLISION ERROR

查看:124
本文介绍了CORONA SDK LUA HELP ..... COLLISION ERROR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





在我的游戏中我创造了一个碰撞功能,在这个游戏中,多个蛋从天空落下,当它们与地面相撞时我希望他们消失..问题是,当第一个接触地面时,它会消失,但其余的人都不会......你能帮助我吗?

COLLISON CODE:

Hi,

in my game i have created a collision function, in this game multiple eggs fall from the sky and when they collide with the "ground" i want them to disappear .. the problem is that when the first contacts the ground it disappears but the rest of them don''t.. can you pls help me?
COLLISON CODE:

  function onGroundCollision( self, event )
   if ( event.phase == "began" ) then
        if(self.myName == "egg") then 
            if(event.other.myName == "ground") then
                audio.play(sound3)
                
                    self.isVisible = false
                    self:removeSelf()
                end                    
            end
        end
end



FRAMES CODE:

这是丢弃多个鸡蛋的代码:


FRAMES CODE:
this is the code that drops multiple eggs:

local function onFrame(event)    
frameCounter = frameCounter + 1
if(frameCounter % 40 == 0 and eggCount > 0) then 
        eggCount = eggCount - 1
        local egg = display.newImage("egg.png")
        egg.x = math.random(0, 310)
        egg.y = 0
        egg.rotation = math.random(0, 360)
        physics.addBody(egg, {density = 2.0, friction = 1.5, bounce=0.01})

推荐答案

您应该尝试此处 [ ^ ]。


这篇关于CORONA SDK LUA HELP ..... COLLISION ERROR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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