Currently the character is jumping up&down/left&right and I can't figure out how to make him move smoothly.
I followed the AdvTileLoader tutorial for the collision detection and the code it gave me was:
I should not need to provide the collision code because it is the movement code that is messing with me.
Code: Select all
function on_collision(dt, shape_a, shape_b, mtv_x, mtv_y)
-- sort out which one our hero shape is
local hero_shape, tileshape
if shape_a == circ and shape_b.type == "tile" then
hero_shape = shape_a
elseif shape_b == dude and shape_a.type == "tile" then
hero_shape = shape_b
else
-- none of the two shapes is a tile, return to upper function
return
end
-- why not in one function call? because we will need to differentiate between the axis later
hero_shape:move(mtv_x, 0)
hero_shape:move(0, mtv_y)
emitterpos:move(mtv_x, 0)
emitterpos:move(0, mtv_y)
end