如何在 cocos 2d 中移动背景中移动、背景、如何在、cocos

2023-09-06 09:50:48 作者:你若安好、便是老天瞎了眼

您好,我想开发像涂鸦跳跃"这样的游戏.但是我对以下功能有一些问题-

Hi i want to develop game like 'Doodle jump'.But i have some problem with the following features-

1.如何移动背景场景/图像.

1.How to move background scene/image.

2.如何检测物体之间的碰撞.是否需要像box2d这样的物理引擎或者我应该使用手动碰撞.

2.How to detect collision between object.Is it needed a physics engine like box2d or i should just use manual collision.

3.背景图片的大小应该是多少.

3.what should be the size of the background image.

4.事实上我不知道背景是如何移动的.所以我需要有人解释一下.

4.In fact i have no idea how does background move .So i need a explanation from someone.

推荐答案

背景运动A) 你可以创建一个 TMX Tilemap,然后制作一个非常高的 Tiled-Map.B)您可以创建一个纹理,然后循环纹理坐标而不是真正移动它.

Background Movement A) You could create a TMX Tilemap and then make a very high Tiled-Map. B) You could create one texture and then cycle the texture coords instead of really moving it.

手动检测.最好是通过Point in Boundingbox"或Rect in Rect"来检测它.有关更多详细信息,请访问我的关于 cocos2d 碰撞检测的博客条目:http://www.anima-entertainment.de/?p=262

Detect it manually. Best is detect it via "Point in Boundingbox" or "Rect in Rect". For more detail visit my blog entry for collision detection with cocos2d : http://www.anima-entertainment.de/?p=262

图片的大小请记住,纹理在内存中始终是 2 的幂.如果要在内存中创建一个视网膜高分辨率(960x640 像素)的背景图像,则纹理为 1024x1024.如果可能,使用较小的背景图像并拉伸它们.(如 512x512).但对于大型滚动图像,我真的会推荐 TMX 支持.

Size of an Image Keep in Mind that textures are always at power of 2 in the memory. If you want to create one Background-Image at retina highresolution (960x640 Pixel) in the memory will be a texture of 1024x1024. If possible use smaller Background-Images and stretch them. (like 512x512). But I really would recommend for big scrolling images the TMX Support.

CCTMXTiledMap * tmxNode = [CCTMXTiledMap tiledMapWithGMXFile:@"Level.tmx"];

//假设您想在 1 秒内将其向下移动 50 像素:

[tmxNode runAction:[CCMoveBy actionWithDuration:1.0 position:ccp(0,-50)];

创建平铺地图:http://www.mapeditor.org/

 
精彩推荐
图片推荐