且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Cocos2d添加背景图像到图层?

更新时间:2023-11-11 12:27:04

你不需要有一个图层,但他们很方便。将层视为将sprite(视觉和组织)分组的一种方式。你可能希望你的背景图片分组为一个层,所有的敌人在游戏中作为另一个层。这允许你更干净地处理每个集。例如您可以移除特定图层,而不是找到所有敌人并删除它们。

You do not need to have a layer, but they are handy. Think of the layers as a way of grouping sprites (both visually and organizationally). You may want your background images grouped as a layer and all the enemies in a game as another layer. This allows you to deal with each set more cleanly. e.g. You can remove a specific layer instead of finding all of the enemies and removing them.

如果有帮助,请在Photoshop或图形编辑程序中播放图层。 cocos2d中的图层类似。

If it helps, play with layers in Photoshop or a graphics editing program. Layers in cocos2d work similarly.

对于一个简单的场景,将背景添加到图层或场景不会有什么区别。但它不需要很久以前的分层的好处。

For a simple scene, adding the background to a layer or to a scene won't make much difference. But it doesn't take long before the benefits of layering kicks in.