开发者

How do I add background in cocos2d?

开发者 https://www.devze.com 2023-01-24 06:47 出处:网络
I\'m a total noob. Starting my first app. I\'m using cocos2d and there\'s isn\'t a .xib file so how do I add a background image behind the sprites I have i开发者_StackOverflow中文版n my scene?In Cocos

I'm a total noob. Starting my first app. I'm using cocos2d and there's isn't a .xib file so how do I add a background image behind the sprites I have i开发者_StackOverflow中文版n my scene?


In Cocos2d you don't use xibs you have to place all the objects by code. Check the samples that come with Cocos2d to get a sense of how it works. If you already know how to add sprites, adding a background is done the same way, it would be just another sprite just add it with a lower z-order.

[self addChild:myBackground z:0];

"self" would be the actual CCLayer

"myBackground" the sprite you created with the bakcground iamge.

and "z" would have to be lower than the z used for the other elements.

0

精彩评论

暂无评论...
验证码 换一张
取 消