Hello,
I am using SceneManager and I have the same background on start scene as well as second level scene.
Here is piece of code:
Now, the problem is that in my second screen "plays", I have many objects on this level, but I want only one of them to move up and down on touch, the object is taken from texture pack and is basically an animation:
If i do self:getPosition and self:setPosition, all the objects in this level change their position, how do I change position of only self.anim[frame] when the user touches the screen?
--in Play.lua
self.anim =
{
Bitmap.new(pack:getTextureRegion("flappy1.png", true)),
Bitmap.new(pack:getTextureRegion("flappy2.png",true)),
}
and then something like this :
self:addChild(self.anim[1])
self: addEventListener(Event.TOUCHES_BEGIN, self.whenTouched, self)
self: addEventListener(Event.TOUCHES_END, self.whenuntouched, self)
function Play: whenTouched()
x,y= self:getPosition()
self:setPosition(x, y-20)
end
function Play: whenuntouched()
x, y= self:getPosition()
self:setPosition(x, y+20)
print("down")
end
Comments