Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
How to Eliminate Sprite/Texture "White Space" from registering with Touch EventListeners? — Gideros Forum

How to Eliminate Sprite/Texture "White Space" from registering with Touch EventListeners?

Daimyo21Daimyo21 Member
edited March 2014 in General questions
So my game requires no collision or physics... to simply put it, when I add touch eventlisteners (mouseDown, mouseUp, mouseMove) to sprites, I want the eventlisteners to only register the actual shown texture and not the transparent white space etc.

Example of a specific scenario I am trying to accomplish:

Ok I have one circle sprite with a transparent hole in the middle so you can see sprites behind the circle from the center.

Now put a solid square sprite behind the circle sprite (both contain touch eventlisteners), but when I want to grab the square sprite that is behind the circle sprite, I grab the circle sprite because of the transparent white space in the center that is still registered from the touch event.

I see shape editor and texture pack with trim options but not sure if that is going to solve my problem.

Comments

  • GregBUGGregBUG Guru
    edited March 2014
    @Daimyo21
    mmm ...
    you should ignore circle collision and then check if there is a collision with square sprite?

    if you need a more precise (and fast) collision detection you should use TNT Collision Engine. (it's free)

    www.tntengine.com

    edit:

    i mean you can check with tntcollision if your internal circle (hole) is in collision with x,y (on event touch) if so (you are touching the internal transparent zone of your circle sprite) you can check if you are in collision also with square sprite...
    should work...

    TNT ENGiNE for Gideors Studio - Particle Engine, Virtual Pad, Animator Studio, Collision Engine - DOWNLOAD NOW !!! IT'S FREE!!! -
    www.tntengine.com
  • @Daimyo21
    mmm ...
    you should ignore circle collision and then check if there is a collision with square sprite?

    if you need a more precise (and fast) collision detection you should use TNT Collision Engine. (it's free)

    www.tntengine.com

    edit:

    i mean you can check with tntcollision if your internal circle (hole) is in collision with x,y (on event touch) if so (you are touching the internal transparent zone of your circle sprite) you can check if you are in collision also with square sprite...
    should work...

    That would certainly help to some extent I think, but even if I were to have a check to see if I am clicking within the transparent part / colliding with square sprite, how could I get it to select the square touch event versus the circle?

    Ultimately I am trying to grab the square sprite behind the circle without having to move the circle sprite out of the way.
  • ar2rsawseenar2rsawseen Maintainer
    The code would look something like this
    circle:addEventListener(Event.MOUSE_DOWN, function(e)
        if --[[check for circle collision etc ]] then
            --stop event propagation any further
            e:stopPropagation()
            circle.isDragged = true
        end
    end)
    circle:addEventListener(Event.MOUSE_MOVE, function(e)
        if circle.isDragged then
            --stop event propagation any further
            e:stopPropagation()
            --move circle
        end
    end)
    circle:addEventListener(Event.MOUSE_END, function(e)
        if circle.isDragged then
            --stop event propagation any further
            e:stopPropagation()
            circle.isDragged = false
        end
    end)
    And same thing for square
Sign In or Register to comment.