Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Can Stage take a touch event? — Gideros Forum

Can Stage take a touch event?

ondesicondesic Member
edited July 2012 in General questions
I simply wanted to test event handling. When I touch the screen, I want to turn the screen black. I figured it would be easy, but the following code doesn't work for me:

function onTouchDown(event)
application:setBackgroundColor(rgb(0, 0, 0))
end

stage:addEventListener(Event.TOUCHES_BEGIN, onTouchDown)

Comments

  • talistalis Guru
    edited July 2012
    application:setBackgroundColor(0xFFF)
     
     
    stage:addEventListener(Event.MOUSE_DOWN , function ()
    	application:setBackgroundColor(0x000)
    end)
    Dont forget that ontouch event can be only tested on real device not on player. If you want to test on emulator(player) than use MOUSE_DOWN instead of ontouch event.
    it is working try this please.
  • Interesting. I didn't know that. Where do I read about this? Is it in the reference manual? Any other oddities with the player?
  • ar2rsawseenar2rsawseen Maintainer
    edited July 2012
    Not sure if it applies, but since Stage inherits from Sprite, then it has no width or height, until you add something to it. So you can't click object width 0 width and 0 height. But I might be wrong and stage gets device's screen dimensions. Need to test that.
    Its best to test it with images :)
  • @ar2rsawseen even without adding no object (images etc..) this code is working.

    application:setBackgroundColor(0xFFF)

    stage:addEventListener(Event.MOUSE_DOWN , function ()
    application:setBackgroundColor(0x000)
    end)
  • @ondesic actually i can not find where it is written but i read it somewhere in this forum as far as i remember. Touch events are only working on real devices, in player mouse events are working.
    If i will find i will post it here.
  • hmm ok it was my bad the topic is about multi touch. so touch events are also working as far as they are single touch events not multi touch:)
  • @talis no you are correct, as far as my testing has gone touch events do not work in the player, only mouse events. It's been that way for quite some time.

    I always wondered why they didn't support at least one touch event in the player, I can understand how multitouch is not possible with a mouse but it is a little weird. Event.MOUSE_DOWN will work in the player without a problem. Event.TOUCHES_BEGIN will not, etc.
    ThumbHurt Games / FB: ThumbHurt Games / FB: Eli/Teranth | Skype: teranth37
Sign In or Register to comment.