Get the App
SLTechnology News&Howtos  ›  Development  › 

How to add a genie sprite to cocos2d-x

Shulou Source: shulou.com Published: 2022-06-02 16:25:48 10月04日 Update

This article will explain in detail how to add a genie sprite in cocos2d-x, the content of the article is of high quality, so the editor will share it for you as a reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.

Add an elf sprite

The bool CMyFirstScene::init () function is added at the end of the second scenario.

Auto s = Sprite::create ("19300001150142129966113771140.jpg")

This- > addChild (sPhone1)

/ / do something

Returntrue

19300001150142129966113771140.jpg

It's a picture of a rabbit. You have to add the file to the project. (xcode's add files to "project")

What is an elf? Is it moving, animals? Aircraft? Equipment (gun, × ×)? Enemy, immovable: obstacles, walls, bricks? Hey, mines, huh? Traps, etc.

0.1 reduce the sprite and make it fully displayed

Auto s = Sprite::create ("19300001150142129966113771140.jpg")

CCSize size=CCDirector::sharedDirector ()-> getWinSize ()

S-> setPosition (ccp (size.width/2,size.height/2))

S-> setScale (0.3)

This- > addChild (sPhone1)

/ / do something

Returntrue

}

On how to add a genie sprite in cocos2d-x to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Tags: Elves can move content articles more knowledge articles good rabbits functions animals pictures mines scenes basics that is enemies files bricks equipment Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Shulou Technology NVidia Redmi macOS