Hi folks,
I have some problems that is need your help because I don't know my current practices are okay.
1.With collision detection, currently I used a simple collision detection based on sprite and no need to create a physics body, like this:
function self: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 |
I wonder if I use this method, does the game run better compared to method which use physic body? In this method we can only process square object, circle object with transparent edge will return invalid result. Any ideas to to correct this?
2.In my game, I use onEnterFrame event and frameCount to manage movement. In each enter frame event, I must loop around all object in a parent sprite (called group) then process it's movement. Is this a good practice?
3.I find my game speed is ok without sound. With sound added, every time sound channel start to play, the game is a bit freeze. Any help to avoid this?
Thank you very much
Comments
If you really want proper (and fast) collision detection, you should try TNT Collision engine.
http://www.tntparticlesengine.com/?cat=15
It makes sense to use box2d only when you need physics simulation, not for collisions.
And about sound, do you use wav for sound effects? Cause by the description it seems that you are using mp3 (it takes time to decode it, thus the delay), so try using wav files for quick sound effects and mp3 for background music
Likes: thanhquan1512
2. Yes, it's really good practice.
Likes: thanhquan1512
http://www.tntparticlesengine.com/
Ultimate Games on Appstore
Ultimate Games on Google Play