Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
how to detect a hero leave the ground — Gideros Forum

how to detect a hero leave the ground

albert988albert988 Member
edited March 2013 in Game & application design
there is a hero in my game and the map move from left to right

at first, the hero is on the ground as an object in the tiled map

but after then the hero will come up against precipice, however in my game, the hero "walk" through it instead of falling down .

My question is how can I detect the hero have leave the ground and make him falling down?

Comments

  • edited March 2013
    EDIT: since I didn't understand the case, this answer was out of topic.
  • still don't clearly understand your question. But if you want to check whether the hero is in ground or not, you can use this:

    ground:hitTestPoint(hero:getX(), hero:getY())

    to checks whether the hero (in global coordinate system) is in bounds of the ground.
    thanks to @thanhquan1512, but I want more detail, so I upload my code

    In the game if hero don't jump, he won't fall down

    please help
  • edited March 2013
    Hi albert,

    In hero.lua, I try to set friction = 0 in hero body:
    self.body:createFixture {shape = shape, density = 1.2, restitution = 0.2, friction = 0}
    I tested and it worked fine with 1st hole. However the next hole he still didn't fall don't know why

  • tkhnomantkhnoman Member
    Accepted Answer
    It might be super late, or you might already get the answer, but i will answer it anyway.

    On hero.lua, line 16:
     self.body = world:createBody {type = b2.DYNAMIC_BODY, fixedRotation = true,allowSleep = false}
    Never set hero/enemy to allow sleep.
Sign In or Register to comment.