I tried to make a platformer game to learn, like http://osmstudios.com/tutorials/love2d- ... ing-levels
and and that works, but only for the main character, the enemies is another history.
Enemies no step the ground, they just move in x axis (velocity + -), I tried to make like the player, the problem is where they collision, they can´t move.
Code: Select all
function espadachin:init()
....
Entity.init(self, world, x, y, self.imgx[self.it],self.imgy[self.it])
self.world:add(self, self:getRect())
end
function espadachin:collisionFilter(other)
local x, y, w, h = self.world:getRect(other)
local espadachinBottom = self.y + self.h
local otherBottom = y + h
return 'slide'
end
function espadachin:update(dt)
....
self.x, self.y, collisions, len = self.world:move(self, self.x, self.y, self.collisionFilter)
for i, coll in ipairs(collisions) do
if coll.normal.y < 0 then
self.isGrounded = true
else
self.isGrounded= false
end
end
I thinking to use love.physics and take a dynamic body all the map, but I would need get all tilelayer with any function, like.
Code: Select all
for k, object in pairs(map.objects) do
end
I used STI library and bump library