QUICK-COCOS2DX 3.3 in about CC. Scaleto action does not get the desired effect

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.