Hi, I starting to get used to Gideros, but now I facing a problem that I can't solve. I'm using some bitmap sprites placed on screen that overlap each other partially. My problem is detecting only specific touches to the visible area of each bitmap. It's possible to attach a polygon shape to a bitmap sprite and define a touch event only on that shape? By the way I not using box2d because I dont need it.
Somebody know how to help me?
Thanks in advance.
Comments
It's up to you to decide if the touch (from the event.x and event.y) is meant for a particular object (usually done using Sprite:hitTestPoint() ) and if it is THEN you could call event.stopPropegation() (sp?) which will stop any further objects from being called.
If your bitmaps overlap then you could either define your own "poly line" to represent the actual shape of the bitmap and do a point in polygon test. I mentioned elsewhere about a method (hack really) to detect touches in a non-transparent area of a bitmap.
If you have a "stack" of bitmaps and you'd like to touch the one on "top" and have the others ignore the touches then you need to assign some kind of "z" value to each bitmap so you can check in code what their depth was. In this instance it might be easier just to register a single touch event handler and from within that - walk through your list of bitmaps and make the appropriate choices from there.
#MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill
Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
Cool Vizify Profile at https://www.vizify.com/oz-apps
Website: http://www.castlegateinteractive.com
https://play.google.com/store/apps/developer?id=Castlegate+Interactive
This is why I would usually recommend a single touch handler that does all of the work as opposed to having a separate one for each object.
#MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill
@techdojo I took your advice and I'm going to explore the single touch handler version, using the hitTestPoint() function and some additional "math" to differentiate the shapes I want. I using triangles....so how hard can it ;-) ?
@OZApps For the moment I not dealing with collisions, but I will be soon ( I hope :-) )
@Scouser Your suggestion need to include box2 physics (which I not using for now).
PS:Have anyone made tests about application file size with box2d included/not included?
thanks again.
Collision code was a comment to @techdojo suggesting that his response was complete in all regards and if anyone wanted to really add something it would be in the form of actual code samples.
Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
Cool Vizify Profile at https://www.vizify.com/oz-apps
Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
Cool Vizify Profile at https://www.vizify.com/oz-apps
Website: http://www.castlegateinteractive.com
https://play.google.com/store/apps/developer?id=Castlegate+Interactive
#MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill