CCSprite 遵循随机路径? (科科斯2D)

发布于 2024-11-13 06:52:13 字数 432 浏览 5 评论 0原文

我在设计我的第一个 cocos2d 游戏时遇到了一些困难,非常感谢您的帮助。

该游戏基本上是一款横向卷轴游戏,英雄(在滑板上)会进入不同的路径(线性、圆形、曲线等),如下图所示:

http://www.legendstyler.com/cocosq.jpg

这是我的问题:

  1. 绘制路径并让精灵跟随的最佳方法是什么它们(尤其是圆形 绘制路径

  2. 如果我想让跳跃和着陆看起来更真实,我需要使用物理引擎吗?它会让我的碰撞检测或跟踪路径变得更轻松吗?

请注意,我将按随机顺序和距离放置路径。我不打算用固定元素绘制关卡。

非常感谢,祝你有美好的一天 =)

I'm facing some difficulties in the design of my first cocos2d game and I'd really appreciate your help.

The game is basically a side-scroller and the hero (on a skateboard) runs into different paths (linear, circular, curvy, .. etc) as drawn in this sketch:

http://www.legendstyler.com/cocosq.jpg

Here are my questions:

  1. What is the best approach for drawing paths and letting a sprite follow them (especially circular paths) ?

  2. If I'd like the jumping and landing to look realistic, do I need to use a physics engine ? will it make my life easier in collision detection or following paths ?

Please note that I'm going to place the paths in random order and distances. I'm not planning to draw a level with fixed elements.

Many thanks and have a good day =)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

昔梦 2024-11-20 06:52:13
  1. 玩家应该画出角色应该遵循的线,还是你在谈论一条假想的线?

如果那应该是一条虚线,那么您可以使用 cos 和 sin 来计算它。如果玩家应该绘制它,那么您可以使用数组来存储 x,y 坐标。

  1. 您可能会使用 box2d。设置完所有内容(包含对象的世界)后,您将获得很多东西(例如弹跳和碰撞)。但移动有点棘手,因为你必须使用力来移动对象,而不是仅仅“移动”它们一个像素一个像素。例如,如果您想将角色移至右侧,则必须推动他。
  1. Should the player draw the line that the character should follow, or are you talking about an imaginary line?

If that should be an imaginary line, then you could calculate it using cos and sin. If the player should draw it, then you might use an array to store the x,y coordinates.

  1. You might use box2d. After you've set up everything (the world with it's objects) you will get a lot of stuff (such as bouncing and collision). But the movement is a bit trickier, because you will have to use forces to move objects, instead of just "moving" them pixel for pixel. For example, if you would like to move your character to the right, you will have to push him.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文