(GO) cocos2d-x the playback of each frame animation the practice of setting a listener function

Source: Internet
Author: User

1Local cache =cc. Animationcache:getinstance ()2Cache:addanimations ("animations-2.plist")3Local animation = Cache:getanimation ("Dance_1")4Animation:setdelayperunit (0.25)5Animation:setrestoreoriginalframe (true)6Local Aniamte =cc. Animate:create (animation)7 sprite:runaction (CC. Repeatforever:create (Aniamte))8 9Local listener =cc. Eventlistenercustom:create (CC. Animation_frame_displayed_notification,Tenfunction (Event, AA,BB,CC) OneLocal name =Event: Geteventname () A print (name) - End -         ) the       -Cc. Director:getinstance (): Geteventdispatcher (): addeventlistenerwithfixedpriority (Listener,-1); -    


PS: This is a very good practice, when we need to do the playback of each frame to do processing, we can use it, UserData access to the interface, not provided, we can ourselves imitate geteventname, write a method to obtain getuserdata. or a different script interface function

(GO) cocos2d-x the playback of each frame animation the practice of setting a listener function

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.