API transition.to

Rotation using API transition

Can you do the same with less lines and single-image program?

local numero = display.newImage( "cinco.png" ) numero.x = display.contentCenterX numero.y = display.contentCenterY local listener1 = function( obj ) numero:removeSelf() numero = nil local numero2 = display.newImage( "cinco2.png" ) numero2.x = display.contentCenterX numero2.y = display.contentCenterY transition.to( numero2.path, { time=2000, x1=434, y1=0, x2=434, y2=0, x3=-434, y3=0, x4=-434, y4=0,  }   ) end transition.to( numero.path, { time=2000, x1=434, y1=0, x2=434, y2=0, x3=-434, y3=0, x4=-434, y4=0, onComplete=listener1 } )

Hi @fferraro67,

I’m not sure what kind of animation you want here. Do you want the “5” to “spin” around a theoretical Y axis? If so, does this need to occur in an endless loop, or only one time (one spin)?

Best regards,

Brent

Hello Brent. I want to rotate the number “5” on the Y axis, once or more. It matters not that. I found a problem. I think it’s my mistake, but I’m not sure. Sometimes the number “5” full 360 degrees. But sometimes makes 180 degrees counterclockwise and returns to the home position sense. And it does so with the same program, without changing a comma. Is the simulator? Have I done something wrong? It is not the first time you encounter such problems.

Is there a simpler and safer way to do this?

Something like this?

local numero = display.newImage( "cinco.png" ) numero.x = display.contentCenterX numero.y = display.contentCenterY local listener1 = function( obj ) transition.to( numero, { time=2000, xScale = 1} ) end -- rotate only transition.to( numero, { time=2000, xScale = -1, onComplete=listener1} ) -- rotate and move --transition.to( numero, { time=2000, x = 50, y = 50, xScale = -1, onComplete=listener1} ) 

Good Luck!

burhan

It is a good idea, Burhan J. In fact simplifies much of the code. But there is a problem: there is no real rotation. Makes 180 degrees in one direction and 180 degrees in the opposite direction. When would have to do 360 degrees in one direction. I will check what I am saying, as more program lines sometimes it does the same and sometimes they do not. I still could not come up with the error. Not if the program, some API, or the simulator. 

Thank you very much, it is a good idea.

How I upload two videos of 1.3 MB each to see the effect of the API?

Hi @fferraro67,

I think you’ll need to upload the videos to YouTube or Vimeo or similar. I don’t think our forums support video uploads.

Best regards,

Brent

Hi @fferraro67,

I’m not sure what kind of animation you want here. Do you want the “5” to “spin” around a theoretical Y axis? If so, does this need to occur in an endless loop, or only one time (one spin)?

Best regards,

Brent

Hello Brent. I want to rotate the number “5” on the Y axis, once or more. It matters not that. I found a problem. I think it’s my mistake, but I’m not sure. Sometimes the number “5” full 360 degrees. But sometimes makes 180 degrees counterclockwise and returns to the home position sense. And it does so with the same program, without changing a comma. Is the simulator? Have I done something wrong? It is not the first time you encounter such problems.

Is there a simpler and safer way to do this?

Something like this?

local numero = display.newImage( "cinco.png" ) numero.x = display.contentCenterX numero.y = display.contentCenterY local listener1 = function( obj ) transition.to( numero, { time=2000, xScale = 1} ) end -- rotate only transition.to( numero, { time=2000, xScale = -1, onComplete=listener1} ) -- rotate and move --transition.to( numero, { time=2000, x = 50, y = 50, xScale = -1, onComplete=listener1} ) 

Good Luck!

burhan

It is a good idea, Burhan J. In fact simplifies much of the code. But there is a problem: there is no real rotation. Makes 180 degrees in one direction and 180 degrees in the opposite direction. When would have to do 360 degrees in one direction. I will check what I am saying, as more program lines sometimes it does the same and sometimes they do not. I still could not come up with the error. Not if the program, some API, or the simulator. 

Thank you very much, it is a good idea.

How I upload two videos of 1.3 MB each to see the effect of the API?

Hi @fferraro67,

I think you’ll need to upload the videos to YouTube or Vimeo or similar. I don’t think our forums support video uploads.

Best regards,

Brent