Add cocostudio exported animations to the project code and play them cyclically. Export cocostudio

Source: Internet
Author: User

Add cocostudio exported animations to the project code and play them cyclically. Export cocostudio


Introduce # include "cocostudio/CocoStudio. h" using namespace cocostudio in the Code;
ArmatureDataManager: getInstance ()-> addArmatureFileInfo ("fishes/blowFish/Blowfish. ExportJson ");

Armature * armature = Armature: create ("Blowfish ");
Armature-> setTag (10010 );
Armature-> setPosition (350,350); // play the animation
Armature-> getAnimation ()-> playByIndex (0 );
This-> addChild (armature );
How to Use the cocostudio ui editor to implement the setting interface and include code

2.1? First, create the main configuration interface:

CocoStudio Installation
Program and prepare the required materials

Create a new project named "ChaosFight" and set the resolution (based on actual needs). Here, manually enter the resolution.
Import the game materials to the project, and add the image box control to display the background.
Add controls as needed. we added the following four text buttons in an image box on the main interface and four image buttons in the following row, there are two text buttons and a text field at the bottom ).

Note the following points during editing:

When setting the image button, you can set the image to be displayed when it is disabled. The "interaction" attribute must be enabled for all clickable controls.
Set button properties the default picture is the same as the clicked image (or different, if you press not set, the actual operation is not displayed, blank)
Export some resource files

2.2? Next, we need a second-level UI interface for "changing the password:

Create a new project and import related resources.
Shows the design interface:

Three passwords are added here. When designing such three similar control sets, we have a skill. First, we have a partial control area, such as the "old password" area. Then we will structure the related control tree, unified,

Click the object structure on the right. We can copy the entire "Node" of the tree and paste it into the tree, for example, in the "New Password" area, we set the related controls on the "new password" node, and then drag this node to complete the relative position of the internal elements.
Modify relevant attributes, naming rules, and export resources

3? Compile code control page logic

Create a new project, introduce CocoGUILIB extension library, and UI
Resource file exported by the editor (please pay attention to the official instructions in real time for Project Creation steps. The operation steps for different versions are different. Here, we use 2.1.4e
Download the latest version library to configure the environment in the simplest way .)
Create a new scenario class for loading our UI
Resources, and write the relevant logic. The key code is as follows (to implement the loading and jump logic control function). All codes are engineering resources:
? Download project code: Click to download the entire project
# Ifndef TestCpp_ChaosFight_h
# Define TestCpp_ChaosFight_h

# Include "cocos2d. h"
# Include "CocosGUI. h"

USING_NS_CC;
USING_NS_CC_EXT;

Class ChaosFightUI: public CCLayer {
Public:
Static CCScene * scene ();
Virtual bool init ();
CREATE_FUNC (ChaosFightUI );

Void tbChangePwdCallback (CCObject * pSender );
Void tbBindingEmailCallback (CCObject * pSender );
Void tbChangeRoleCallback (CCObject * pSender );
Void tbLogoutCallback (CCObject * pSender );

Void btnSoundEffectCallback (CCObject * pSender );
Void btnmusic1_tcallback (CCObject * pSender );
Void btnSavingElectricityCallback (CCObject * pSender );
Void btnVideoCallback (CCObject * pSender );

... The remaining full text>

Why does an animation always play multiple times after flash is exported to swf format? How can I make it play only once?

Add the code in the last frame: stop ();

Related Article

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.