In the development process need to do an animation, using a width-to-height ratio of 1:2 rectangular picture, the shape is a frame; want it to scale from the specified size to a certain multiplier according to the 1:1 aspect ratio.
The first method to use:
Localfrm = Display.newsprite ('#frm. png')--rectangular frame with a width-to-height ratio of 1:2LocalFrmsize =frm:getcontentsize ()LocalICONW, Iconh = -, -LocalScale =2.5 --expected magnificationLocalTime =0.2 --Animation Execution TimeFrm:setscale (iconw/Frmsize.width, Iconh/frmsize.height) frm:setcontentsize (iconw, Iconh) transition.execute (frm, CC. Scaleto:create (time, scale))
However, it was found that the magnification did not maintain a 1:1 aspect ratio because it has been made into a square using Setscale and setcontentsize.
Why? The reason can only be during the amplification process, the Setcontentsize function is invalid. Remember Ccnode:setscale () function Comment: Setscale does not change a node's contentsize. So setcontentsize is not valid, amplification is not calculated according to its contentsize.
It would be better to read as follows:
Localfrm = Display.newsprite ('#frm. png')--rectangular frame with a width-to-height ratio of 1:2LocalFrmsize =frm:getcontentsize ()LocalICONW, Iconh = -, -LocalScale =2.5 --expected magnificationLocalTime =0.2 --Animation Execution TimeTransition.execute (frm, CC.) Scaleto:create (time, scale* Iconw/Frmsize.width, scale* iconh/frmsize.height))
QUICK-COCOS2DX 3.3 in about CC. Scaleto action does not get the desired effect