Hello,
Regarding my previous question (Sprites with random text), is it possible like in Xcode/Cocoa
to enlarge the touch area of a sprite? I have a sprite, for example 80x80 px and want a touch
area of 100x100 px (10 pixels extra around the sprite).
Also can you always use onMouse events instead of onTouches? They both work on the simulator.
Thanks,
Marc
Comments
I'm not sure if what you ask is available.
But an alternative way would be to add a bigger child (touch area) to your sprite (text container), that would be responsible of event listeners (like a "bounding" or "collision" box).
When this touch area detects an event, an action is triggered on its parent (getParent()).
When you add a touch listener to a sprite, ALL sprites with touch listeners receive all the events (unless one calls the event.stopPropagation() function), so all you have to do is instead of calling Sprite:testHitPoint() just call Sprite:getBounds() which returns the screen position and then adjust the size of the bounds and do the in box comparison yourself. It's exactly what I do when I press a button - I have an "extended" area around the sprite so you can slightly move off without loosing a potential press.
eg.
#MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill
But this will also reduce the available space in my sprite sheet.
Regards,
Marc
Website: http://www.castlegateinteractive.com
https://play.google.com/store/apps/developer?id=Castlegate+Interactive