Hi, I am in the finishing stages of my first game, yeeah! I really love LUA and Corona but sometimes it's easy to get stuck and now i am there again :)
I am having platforms in my game that moves in two directions. Both horizontal and vertical. I managed to get the player on to those platforms when it moves and so far it is ok. I am also using physics for my game and I think that it did not get easier with that - but on the other side the gamefeeling is awesome!
Problem
When the player is traveling on a platform that moves vertical, he doesn't jump of the platform? It works perfect on the platforms that moves horizontal? I am using levelHelper for creation of levels, you will see some code I am using to interact with objects in my code.
In my collision routine I have this code to see if the player is hitting a moving platform:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | elseif event.other.lhTag == LevelHelper_TAG.MOVING then --======================================================= -- MOVING PLATFORMS --======================================================= if (attachedPlatform==false) then --Create an instance to the moving platform ActivePlatform = loader:spriteWithUniqueName(event.other.lhUniqueName) --Check that collision occurs on top of platform if (ActivePlatform.y - ball.y>12) then --Offset of player and platform PlatformOffset = ActivePlatform.x - ball.x --Check that the player hits inside the platform and not on edges. if(PlatformOffset>-40 and PlatformOffset<40) then --Change tag on sprite to avoid any more collisions right now.... ActivePlatform.lhTag = LevelHelper_TAG.DEFAULT --Player can jump ball.jumping = true --player is attached to the platform attachedPlatform = true end end end else ball.jumping = true end |