如何在cocos 2d中移动背景 [英] How to move background in cocos 2d

查看:147
本文介绍了如何在cocos 2d中移动背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我想开发像涂鸦跳的游戏。但我有一些问题与以下功能 -

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或i应该只使用手动碰撞。

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.

推荐答案


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

  1. 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.

手动检测。最好通过边界点或矩形检测。
有关详情,请访问我的博客条目,以便与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)。

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/

这篇关于如何在cocos 2d中移动背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆