Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Using Tiled for collectables? — Gideros Forum

Using Tiled for collectables?

vyh77vyh77 Member
edited July 2014 in General questions
I'm using Tiled, and the TileMap class to import it, using a Tile layer to draw tiles, and an Object layer to create static box2d objects.

I want to draw collectables with Tiled, with an object layer to detect collisions. I thought on using Event.BEGIN_CONTACT to detect the collision and remove the collectable's body fixture (b2.Body:destroyFixture), so the player goes through as if nothing was there, but still being able to detect the collision. What I found is that on events the World gets locked and I couldn't even try my theory.

Somebody knows the correct way of implementing collectables with Tiled?

Comments

  • ar2rsawseenar2rsawseen Maintainer
    Accepted Answer
    to by pass the world locked event, try this little hack:
    Timer.delayedCall(1, function()
        --remove collectible here
    end)
    it will make the removal of collectible execute on another enter frame event, where world is not locked anymore

    Additionally even if you remove body on collision, there will still be a little knockback for character because of collision, to remove it, set isSensor = true to fixture, so character would pass through the collectible ;)
  • vyh77vyh77 Member
    @ar2rsawseen it works!! thanks a lot!!
Sign In or Register to comment.