Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
collision other object height — Gideros Forum

collision other object height

txarlytxarly Member
edited January 2013 in General questions
hi,

i have a collision function and i want to know if the character collides with an enemy jumping over it, but i can´t get the other object´s height.Any idea?

local function onplayerCollision(event)

local fixtureA = event.fixtureA
local fixtureB = event.fixtureB
local bodyA = fixtureA:getBody()
local bodyB = fixtureB:getBody()

local playerBody, other

if bodyA.info.material == "heroe" then
playerBody = bodyA
other = bodyB
elseif bodyB.info.material == "heroe" then
playerBody = bodyB
other = bodyA
end
if playerBody ~= "heroe" and (other.info.material == "enemy" ) then

if player.y < other.y-(other.height*0.5) then --??
display.remove(event.object1); event.object1 = nil --??
else
print("enemycontact")--gameOver()
end
end
end

i use gideros svg level editor


thanks

Comments

  • If you store a reference to the related sprite in your body, you could then fetch the height of the sprite. Or you could store the height ahead of time like you do with the info/material properties.
Sign In or Register to comment.