Quick-cocos2d-x Study Notes [3] -- display. newSprite create genie, quickcocos2d

Source: Internet
Author: User

Quick-cocos2d-x Study Notes [3] -- display. newSprite create genie, quickcocos2d

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.


The laptop win7 system has created a wireless network with a shared genie, so many people can connect to it. Why can't I have more than 3?

In fact, the wireless networks created by the sharing genie cannot be connected to too many users at the same time. If the computer problem is not ruled out by others, it may be your mobile phone settings or hardware problems. I did not cover the world 3, so I couldn't answer the question. I often sent wireless Internet access to my mobile phone. The stability was good.
 
: New Concept 3 New Oriental Study Notes and after-school answers

I have one .. Are you using QQ? I will pass it to you

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.