Quick Links: Gideros Home | Download Gideros | Developer Guide
Easy way to do multitouch?
  • Hi guys

    Is there an easy way to enable multitouch in Gideros.

    I need to be able to touch a sprite while a finger is already touching the screen/another sprite.

    Im currently using MOUSE_DOWN.

    I tried looking around but can't find anything relevant to what I'm looking for.

    Thank you for any help :)
  • antixantix +1 -1
    Member
    Did you checkout the MultiTouch demo that ships with Gideros?
    Check out my DevBlog, my GitHub, and my games Falling Animals | Breaky Wall | Exetor
  • @antix - I can't find it :( Is it called Multitouch? Is it under example projects?
  • I found one called touch explorer :)

    Is that the one you mean?
  • hgy29hgy29 +1 -1 (+1 / -0 )
    Maintainer
    yes, you should use TOUCH_xxx events instead of mouse

    Likes: SinisterSoft

  • Hi @Hgy29 - Hmmm, I'm attaching my listeners in this way but m not getting anything ...
    Bottle = Core.class(Sprite)
     
    function Bottle:init(x, y, image, atlas)
     
    self.sprite = Bitmap.new(atlas:getTextureRegion(image))
    self.sprite:setAnchorPoint(0.5, 1)
    self.sprite:setPosition(x, y)
     
    self:addChild(self.sprite)
    mg:addChild(self)
     
    self:addEventListener(Event.TOUCHES_BEGIN, self.onTouch, self)
     
    end
     
    function Bottle:onTouch(event)
     
    if self:hitTestPoint(event.touch.x, event.touch.y) then
    self.sprite:setAlpha(0.5)
    end
    end
  • The TOUCH_xxx events work, I use them on my latest game without issues.

    What device are you testing it on?
  • @SinisterSoft - It most likely something I'm doing wrong. It's working when I add listeners to the bottles inside the scene's init function.

    I just can't get it working when I try to setup the listener inside the class itself.

    PS. Galaxy S3 (old lol)
  • It should work. Maybe post a zip of the code somewhere so someone can take a look for you?
  • pie +1 -1
    Member
    @Ninjadoodle if this may help, there is a table in touches event named allTouches, where you can find every contemporary touch indexed with its info like this:

    event.allTouches[i]

    I didn't check this, but I believe that event.touch.x and event.touch.y are related only to the first touch and these should be equal to event.allTouches[1].x and event.allTouches[1].y

  • No, each touch is tracked and given an id, you use this id to monitor movement and the touch ending.
  • antixantix +1 -1
    Member
    @NinjaDoodle, I've mashed up a small example similar to yours but using Bitmaps, not Sprites ;)

    Have a look and you should see how this works.

    Note, it does not handle overlapping items.
    Bottlez.zip
    18K
    Check out my DevBlog, my GitHub, and my games Falling Animals | Breaky Wall | Exetor
  • Hi @antix

    Thank heaps for putting together an example, I really appreciate the effort!

    I will have a good look at it and let you know how it goes :)

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Login with Facebook Sign In with OpenID

In this Discussion

Top Posters