Game, no picture, no picture, can be called a game, so we should first look at how to create a genie using quick.
The quick API explains how to create the genie in detail, so it is very easy to create.
Display. newsprite (filename, X, Y, Params)
Filename: SPRITE file name
X: X coordinate
Y: Y coordinate
Params: Table parameters (not commonly used)
We can add the X and Y parameters for convenience during creation so that we do not need to set the location later. In addition, when we use cocos2dx for the sprite file name, we all know that there are direct reads from the file, and some are read from the cache frame, so to distinguish, quick uses "#" on the file name to distinguish them. If it comes with "#", the name is read from the cache frame.
In practice, modify the code in the myscene scenario created in the previous section.
The images used are,
Packaging tools create image sets
Normal Image File
Code,
Function myscene: ctor () -- Common File Creation wizard local SP1 = display. newsprite ("icon.png", display. width/4, display. cy) Self: addchild (SP1) -- creates an image cache display. addspriteframeswithfile ("Coco. plist "," coco.png ") -- create local SP2 = display by cache image name. newsprite ("#icon.png", display. width/2, display. cy) Self: addchild (SP2) -- create a ccspriteframelocal frame = display. newspriteframe ("icon.png") Local SP3 = display. newsprite (frame, display. width/4*3, display. cy) Self: addchild (SP3) End
Display Effect,
You can see these three input filename parameters, you can create the same genie effect.
In the code above, display. width is the screen width, equivalent to getwinsize (). width, and display. Cy is half of the screen height, equivalent to getwinsize (). Height/2
After the Wizard is created, some basic attribute settings such as zooming and rotating for the sprite are the same as those in the original usage. Here is no example.