After combing the various directories of the quick-cocos2d-x framework, we started our instance tutorial, after helloworld, add a picture, lua editor, I used lua editor, not bad.
- First, create a game01 instance by referring to the tutorial. Command: create_project-p com. cocos2dlua. game01-r landscape
- Use quickplayer to open game01 and display helloworld. Normal.
- Open config. lua in the game01 \ scripts directory and find:
- -- Design resolution
CONFIG_SCREEN_WIDTH = 960
CONFIG_SCREEN_HEIGHT = 640
- Change 960 to 1136, because we will use the iPhone 5S test, so it is 1136*640
- Find a background image with a size of 1136*640. we name it bg01.jpg and place it in the game01 \ res. The res contains a framework_precompiled.zip file, which must not be deleted.
- MainScene. lua file in game01 \ scripts \ app \ scenes,
- Function MainScene: ctor ()
Ui. newTTFLabel ({text = "Hello, World", size = 64, align = ui. TEXT_ALIGN_CENTER })
: Pos (display. cx, display. cy)
: AddTo (self)
End
- Delete the code in ctor () and end. You can also use -- comment before each line, or add -- [[, add] before the code end to annotate the entire segment.
- Function MainScene: ctor ()
Local bg = display. newSprite ("bg01.jpg ")
Bg: setPosition (display. cx, display. cy)
Self: addChild (bg)
End
- Then, the background image is displayed. Display. newSprite () is used to create a new genie with images. display. cx is the center of screen x, display. cy is the center of screen y, and addChild () is used to add an object.
- We recommend that you view the display. lua in the framework, which is specific implementation and some function descriptions.