Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Which of these methods is the best to use? — Gideros Forum

Which of these methods is the best to use?

Tom2012Tom2012 Guru
edited November 2012 in General questions
I'm using this code to do non-box 2d collision detections when my character collects a powerup.
function Sprite:collidesWith(sprite2)
local x,y,w,h = self:getBounds(stage)
local x2,y2,w2,h2 = sprite2:getBounds(stage)
return not ((y+h < y2) or (y > y2+h2) or (x > x2+w2) or (x+w < x2))
end
 
if(circle1:collidesWith(circle2)) then
print("yes");
end
Is it better to:

1) Create a class that detects whether each coin is hitting the main character
2) Create a for loop once and check a table of coins to see if they are hitting the main character

Thanks

Tom

Comments

  • GregBUGGregBUG Guru
    edited November 2012
    @Tom2012
    maybe method 2 is faster ?

    even more faster if you use my native (C++) collision system (tnt collision) :D ...

    Likes: ar2rsawseen

    TNT ENGiNE for Gideors Studio - Particle Engine, Virtual Pad, Animator Studio, Collision Engine - DOWNLOAD NOW !!! IT'S FREE!!! -
    www.tntengine.com
    +1 -1 (+1 / -0 )Share on Facebook
  • Hi Greg, I would really like to use your system. I downloaded and had a play but could not run on the local gideros player. Can I only test if I build in xCode?

    Thanks man!
  • for local gideros player you mean desktop player or device player ?
    for device Player you need to "recompile" the Gideros Player (check docs under "installation" section for desktop and device compile)

    anyway feel free to ask if you need help. (here or PM or gregbug at gmail . com)
    (you send me an email by tntengine.com site?)
    TNT ENGiNE for Gideors Studio - Particle Engine, Virtual Pad, Animator Studio, Collision Engine - DOWNLOAD NOW !!! IT'S FREE!!! -
    www.tntengine.com
Sign In or Register to comment.