Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
EventListener question — Gideros Forum

EventListener question

tytadastytadas Member
edited August 2016 in General questions
So I have just connected my phone to Gideros, and I'm trying to create glasses which I have to move on the characters head.

This is the code:
local ggez = Bitmap.new(Texture.new("glass.png"))
 
	ggez:setPosition(application:getContentWidth()/2, application:getContentHeight()/2)
	ggez:setAnchorPoint(0, 0)
 
	stage:addChild(ggez)
 
	stage:addEventListener(Event.TOUCHES_MOVE, function(e)
		ggez:setPosition(e.touch.x, e.touch.y)
 
	end)
 
	stage:addEventListener(Event.ENTER_FRAME, function()
 
	end)
The code works when I'm on the emulator of Gideros, I can move the glasses. But it is not allowed to me to move the glasses on my phone. Does anyone knows why does this occurs?

Comments

  • n1cken1cke Maintainer
    The code seems fine.
    Will that glasses move on your phone with MOUSE_MOVE?
    stage:addEventListener(Event.MOUSE_MOVE, function(e)
        ggez:setPosition(e.x, e.y)
    end)
  • tytadastytadas Member
    edited August 2016
    Nooo :( It works via emulator, but I don't know why the glasses cant be moved while using phone.. Hmm
  • antixantix Member
    edited August 2016
    oops, never mind :D
  • n1cken1cke Maintainer
    edited August 2016 Accepted Answer
    Try to test if Event.TOUCHES_MOVE is triggered:
    stage:addEventListener(Event.TOUCHES_MOVE, function(e)
      print(e.touch.x, e.touch.y) --> this should print something
      ggez:setPosition(e.touch.x, e.touch.y)
    end)
  • Yay it works now! I can move the glasses on my phone! Can the printed numbers in the console affect my game @n1cke? :P Thanks btw :P
  • n1cken1cke Maintainer
    edited August 2016
    @tytadas: I guess that was because for some reason files on your phone wasn't updated when you sent them from your PC. And when you edited it the update was triggered.
    Or for some reason `print` function triggered Studio console and it started work.
  • tytadastytadas Member
    edited August 2016
    Yeah I haven't updated my gideros. I'm a bit scared to update, my all projects might get lost :D
Sign In or Register to comment.