I'm creating a "creative" game like terraria (but, it will be a "farm" game hehe)... Ok, i'm trying to check when my character collides with the ground (after collides with the ground, the jumping variable must be set to false, when false, the character can jump again right?)..ok... but, the problem is:
if character collides with a "wall", the jumping variable is set to false, then, if i continue to press "jump button", my character go away to the sky (¬¬)...
I don't know how to test if the character collided in a ground, the ground could be : over a table, a terrain, over a box, e.g...but it must NEVER get the collision when it is a wall collision, or a "monster" collision, or any other objects around the game world...
Here is my key controller:
Code: Select all
instance.update = function (dt)
local needAnimate = false
if love.keyboard.isDown("d") then
if instance.direction == -1 then
instance.direction = 1
instance.animation = anim8.newAnimation('bounce',instance.grid('1-3,2'),0.1)
end
instance.body:applyForce(400,0)
needAnimate = true
end
if love.keyboard.isDown("w") and (not instance.isJumping) then
instance.body:applyForce(0,-150000)
instance.isJumping = true
end
if love.keyboard.isDown("a") then
if instance.direction == 1 then
instance.direction = -1
instance.animation = anim8.newAnimation('bounce',instance.grid('1-3,1'),0.1)
end
instance.body:applyForce(-400,0)
needAnimate = true
end
if(needAnimate) then
instance.animation:update(dt)
else
instance.animation:gotoFrame(2)
end
end
Code: Select all
function beginContact(a, b, coll)
mainChar.isJumping = false
end
Thx guys!