Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Code seems to execute without touching the screen — Gideros Forum

Code seems to execute without touching the screen

simransimran Member
edited June 2014 in General questions
The situation is : I have my first scene, I click on it and go to second scene using scene manager.

In second scene, I have some code that is to be executed only when user touches the screen, but as soon as I go to second screen, the character is already moving up and down with its initial values without me touching the screen.Please, any idea? where am I doing it wrong?
Here is the code:

function Play: init()
self: addEventListener(Event.TOUCHES_BEGIN, self.whenTouched, self)
self: addEventListener(Event.TOUCHES_END, self.whenuntouched, self)
end

function Play: whenTouched()
self.touchStarted= true
x,y = self.myAnim:getPosition()

if self.touchStarted then
speed = -16
self.touchStarted = false
end
y = y + speed;
print(y)
self.myAnim:setPosition(x,y)
end

Comments

Sign In or Register to comment.