Hi guys,
I am trying to make a dogs obstacle game.
Dogs are spawned from the left and as soon as they touch the ground they start running to the right screen side (Landscape) direction.
When I have one dog that is not a problem, below functions work.
But when I have multiple dogs (spawning) and insert them into a group this does not work.
Can you help me please:
a) How can I track multiple objects positions and fire an action (setLinearVelocity) as soon as particular object (child) passes certain x point?
b) I have problem with adding Runtime to a group in this case?
c) Variables “jump_completed” and “oneJump” make no sense when multiple objects are in game, only when one object is in game?
MY RUN/JUMP/RUN CODE:
local jump_completed = false
local function onGroundCollision(event)
if(event.phase == “began” and jump_completed == false) then
jump_completed = true
player:setLinearVelocity(250, 0 ) – player runs when touches the ground
end
end
local oneJump = false
player:addEventListener(“collision”, onCollision)
local function jumpAgain(event)
if (jump_completed == true and player.x > (obstacle.x - 50) and oneJump == false) then
player:setLinearVelocity(20, - 250) – player jumps when passes obstacle.x - 50 position
oneJump = true
jump_completed = false
end
end
Runtime:addEventListener ( “enterFrame”, jumpAgain )
!