Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Easy way to do multitouch? — Gideros Forum

Easy way to do multitouch?

NinjadoodleNinjadoodle Member
edited October 2017 in General questions
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 :)

Comments

  • Did you checkout the MultiTouch demo that ships with Gideros?
  • NinjadoodleNinjadoodle Member
    edited October 2017
    @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 Maintainer
    yes, you should use TOUCH_xxx events instead of mouse

    Likes: SinisterSoft

    +1 -1 (+1 / -0 )Share on Facebook
  • 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
  • SinisterSoftSinisterSoft Maintainer
    edited October 2017
    The TOUCH_xxx events work, I use them on my latest game without issues.

    What device are you testing it on?
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • @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?
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • piepie 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.
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • @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.
    zip
    zip
    Bottlez.zip
    18K
  • 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 :)
Sign In or Register to comment.