Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Collision detection of objects using TNTCollision Engine — Gideros Forum

Collision detection of objects using TNTCollision Engine

simransimran Member
edited June 2014 in General questions
I am trying to do collision detection(tried using TNTCollision but did not work ).

1. My (1st object ) background object is moving continuously from off the screen and towards left of screen,I am translating its position to left by subtracting 4 from its current position in Enter_Frame.
-->It's 'Y' changes in every EnterFrame randomly and so it's height changes the value of which I certainly have)
-->The AnchorPoint of this object has been set to (0,1)

2. Second object just moves up and down, its X remains 0 (which is the centre of the screen).
I tried a couple of things to detect collision manually but it's kind of getting confusing because the anchorpoint of first object is (0,1), any knack to detect collision between such objects?

I tried this using TNTCollisionEngine but I am quite surprised that it's not working:Here is the code

if colcheck (mc1:getX(), mc1:getY(), mc1:getWidth(), mc1:getHeight(), mc1:getRotation(), d, f, up:getWidth(), up:getHeight(), up:getRotation()) then
tntCollision.setCollisionAnchorPoint(0, 1)
print("YOU LOOSE")
end

mc1 here is an animation I created using MovieClip
Thanks

Comments

  • on tnt collision anchor point must be the same for 2 objects to check.
    sorry.
    TNT ENGiNE for Gideors Studio - Particle Engine, Virtual Pad, Animator Studio, Collision Engine - DOWNLOAD NOW !!! IT'S FREE!!! -
    www.tntengine.com
  • simransimran Member
    Yes, I think that was the issue. I could not set anchor point for movieClip(not allowed), so here is what finally worked :)

    if mc1:getX() >= up:getX() and mc1:getX() + mc1:getWidth() <= d + up:getWidth() and mc1:getY() >= f - up:getHeight() then
    local text4 = TextField.new(conf.fontLarge, "YOU LOOSE")
    text4:setPosition(conf.dx - conf.width/3, conf.dy - conf.height/5)
    text4:setTextColor(0x0000)
    self:addChild(text4)
    end

    Thanks
  • GregBUGGregBUG Guru
    Accepted Answer
    use tnt animator... you can set anchor point... :)
    TNT ENGiNE for Gideors Studio - Particle Engine, Virtual Pad, Animator Studio, Collision Engine - DOWNLOAD NOW !!! IT'S FREE!!! -
    www.tntengine.com
  • simransimran Member
    Oh, I did not know that. I am going to try it then , Thanks :)
Sign In or Register to comment.