Black Horse programmer cocos2d game engine review Note 1

Source: Internet
Author: User
Tags image flip

/** ---------------------------- Game scenario setup ---------------------------------- 1 first create a surfaceview, which can update the UI (global) in the Child thread) 2. instantiate the surfaceview in the oncreate method. 3. Use the setcontentview method to set the surfaceview object to the interface. 4. Get a director. 5. Tell the director to display the screen to surfaceview. the relationship between cocos2d and surfaceview objects is associated. 6. Set the display frame rate. 7. Set the speed of each frame. 1.0f/30. 1/30 was previously written. 0f, so there will be some differences. Now here we have solved 8. Create scenario object 9. Create a set layer object. This object inherits cclayer, which is actually a layer, genie and animations are actually used in the Set layer object. Therefore, we need to create 10 sets in the Set layer object. Use the addChild method of the scenario object to add the set layer object to the scene object. 11. Use the director. runWithScene method running scenario object ---------------------------- add and use the genie ---------------------------------- Add the genie. To create a category of Sprite actions on the screen, you need to repeat it and copy the file to the assets folder. Then, in the constructor of the cclayer subclass object, initialize the ccsprite genie object. you can add Action 1 for a Sprite object after it is set to the set layer object, define a global sprite object 2 in the cclayer subclass. initialize this sprite object in the subclass constructor and use sprite (); // set the display file name, put the file in the assert directory 3. Set the coordinates displayed by the Wizard: setPosition (x, y). You can also set the vector cgpoint object. Note: the android coordinate system uses the upper left corner of the screen as the origin, while cocos2d uses the lower left corner of the screen as the origin 4 of the screen, and adds the genie object to the set layer object. this. addChild (); note that you must add the genie to the set layer object before setting the action --------------------------- -Genie action -------------------------------- ctrl + f10 in ecplise to set whether to display the action: flip: x, y flip image: x, y ------------ show/hide: hide/show rotation Animation: clockwise rotate + forward/-inverse Scaling: + zoom in/-down scale jump action: requires a new coordinate, and the jump height and the number of jumps are translated: moveTo requires a new coordinate, that is, the instantaneous action of a source and a target: Image flip/flip display/hide CCFlipX X axis image flip (horizontal flip) ---- >>>>) (-0,100) CCFlipY Y axis image flip (vertical flip) ---- >>>> (100) (0,-) Translation: moveTo // scaling action // What is the value specified here when scaling in an action? // Number of times, that is, it takes 3 times to enlarge by 15 times. 5 times more CCScaleTo scale = CCScaleTo. action (3, 15); // Let the sprite run the action. runAction (scale); First add the genie to the set layer object, then define the action, and then use the genie to run the action // rotation duration: duration indicates the duration of the action. // ang: angle: CCRotateTo rotate = CCRotateTo. action (3,180); // Let the sprite run the action. runAction (rotate); // moves from vertex A to vertex B CGPoint newPoint = CGPoint. ccp (100,150); // translation animation CCMoveTo move = CCMoveTo. action (3, newPoint); // Let the sprite run the action. runAction (move); a translation animation requires at least two points: a, ba: 100,100 B: 100,150, that is, 50a: 100,100 B: 100, -150 moved down 150 CGPoint newPoint = CGPoint. ccp (100,250); // The first parameter is the animation duration, the second parameter is the coordinate, the third parameter is the jump height, and the third parameter is the number of jumps CCJumpTo jump = CCJumpTo. action (3, newPoint, 18); // Let the sprite run the action. runAction (jump );*/

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.