This was a test run that I may include later on.
It failed.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ball = display.newCircle(60,60,60,60) square = display.newRect(300,300,100,100) group = display.newGroup() group:insert(ball) group:insert(square) function moveball(event) print("touched") transition.to( ball, { time=1500, x=event.x, y=event.y} ) end function check() if (ball.x >= 300) then print("over 300") transition.to( group, { time=1500, x=ball.x-300} ) end end Runtime:addEventListener("touch", moveball) Runtime:addEventListener("enterFrame", check) |
I think it may be because you are trying to move the ball and the group at the same time even though the ball is one of the items in the group.
This isn't perfect but you will at least see them moving. I pulled the runtime listeners once the ball was in place. Moving it around while trying to transition it and it's group isn't a good idea ;)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | myGroup = display.newGroup() ball = display.newCircle(60,60,60,60) square = display.newRect(300,300,100,100) myGroup:insert(ball) myGroup:insert(square) function moveball(event) print("touched") transition.to( ball, { time=1500, x=event.x, y=event.y} ) end function check(event) if (ball.x >= 300) then Runtime:removeEventListener("touch", moveball) Runtime:removeEventListener("enterFrame", check) print "300" transition.to(myGroup, {time =1000, x=-200}) end end Runtime:addEventListener("touch", moveball) Runtime:addEventListener("enterFrame", check) |
views:1515 update:2011/10/5 8:48:05