Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Moving the finger above objects — Gideros Forum

Moving the finger above objects

Good morning,

I'm developing a new game I have the following problem:

I've made a N times N grid full of circles and I want to detect when the user touch one circle and then moves the finger, while moving if the circle under his finger has a specific property, let's say dot.className == 'red', I want to detect that.

I suppose that the basis is in the following example http://giderosmobile.com/forum/discussion/1393/drag-me-example/p1 but I don't know how to continue.

Could someone give me any hint?

Thank you!

Comments

  • ar2rsawseenar2rsawseen Maintainer
    Accepted Answer
    for each dot you should have an event added:
    dot:addEventListener(Event.MOUSE_MOVE, function(self, e)
        if self:hitTestPoint(e.x, e.y) then
            e:stopPropagation()
            print(self.className)
        end
    end, dot)
  • OZAppsOZApps Guru
    Accepted Answer
    @synchrotongames (that was a bit long name) if you have a N x N grid of circles (same size) then you do not even need to detect the circles individually. Given the size of each cell in the grid, you can determine which cell is touched at that instance and from a table of properties you can get the specific property that you need.

    or you can place the circles in a table and then based on the index determine the circle and get it's properties.
    twitter: @ozapps | http://www.oz-apps.com | http://howto.oz-apps.com | http://reviewme.oz-apps.com
    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
  • Thanks to both of you, I've solved the problem using ar2rsawseen's solution but OZApps's suggestion it's good idea too.

    I hope that my next post is to show to you my new game ;)
Sign In or Register to comment.