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