isShake bug?

Here’s a sample code. If the sound plays at each isShake, why it’s not the same with transition.to (same way on simulator or device)?
Thanks for feedback.

–Test multiple isShake

local t1 = display.newText("?", 160, 160, native.systemFontBold, 70)
t1:setTextColor(255, 255, 0)

local sound = media.newEventSound( “maj.caf” )

local shake = {}

function shake:accelerometer(e)
if(e.isShake == true) then
transition.to(t1, {time=1000, rotation = 360}) --plays only one time at the first isShake (why?)
media.playEventSound(sound ) --plays at each isShake, ok
end
end

Runtime:addEventListener(“accelerometer”, shake)
-------------------------------------- [import]uid: 8970 topic_id: 4673 reply_id: 304673[/import]

hmmm… Interesting…

If you were doing a move transition you would write:

[lua]transition.to(t1, {time=10, x = 10})[/lua]

This would only work once as every time after the first shake, the object is already at x=0.

To keep it moving across the screen you would need to write:

[lua]transition.to(t1, {time=10, x = t1.x + 10})[/lua]

or reset the position of the object before each shake event:

[lua]t1.x = display.contentWidth * 0.5
transition.to(t1, {time=10, x = 10})[/lua]

Apparently it seems that each image starts at rotation=0 and you need to treat that like a cartesian movement - either add to it or reset it.

You can add to it like so:

[lua]transition.to(t1, {time=1000, rotation = t1.rotation+360})[/lua]

or reset it like so:

[lua]t1.rotation = 0
transition.to(t1, {time=1000, rotation = 360})[/lua]

It’s not rotating to 360 degrees after the first event because it already is at 360 degrees. You need to set it back to 0 to continue or keep going forward another 360 degrees from it’s present rotation. [import]uid: 11393 topic_id: 4673 reply_id: 14785[/import]

Thanks a lot for the very clear explanation! [import]uid: 8970 topic_id: 4673 reply_id: 14790[/import]

Thanks a lot for the very clear explanation! [import]uid: 8970 topic_id: 4673 reply_id: 14791[/import]