不使用游戏引擎开发简单游戏?
我正在尝试开发一个简单的足球游戏,包括点球,其中我必须为球从球员到球门柱制作动画......之前我一直在使用简单的动画使用计时器添加到球图像的轴,以便它从一个点移动到另一个点..但我没有得到预期的结果,因为动画不是那么流畅...所以我正在考虑使用游戏引擎...由于我是一个新程序员,我对游戏引擎一无所知,也找不到任何有关box2d或花栗鼠或麻雀等引擎的适当文档 >..我还考虑使用 UIView 动画 而不是早期的动画,因为我认为这样可以实现更好的动画,而无需在游戏引擎上摸索......我要去没有这个问题,所以如果有人能对我的这个问题有所了解,那就太好了???
I am trying to develop a simple soccer game including penalty kicks in which i have to animate a ball from player to the goal post...earlier i have been using simple animations using a timer to add to the axis of ball image so that it moves from 1 point to another..but i did not have the desired result as animations were not that smooth...So i was thinking of using a Game Engine...Since i am a New Programmer i have no idea about game engine and neither can i find any proper documentation regarding engines like box2d or chipmunks or sparrow..i was also thinking of using UIView animations instead of the earlier animations as i think that can achieve far better animations without scratching my head trying to work on a game engine....I am going no where with this so it would be really great if someone can put some light on this issue of mine???
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用UIView动画,如:
您还应该使用具有相同间隔的NSTimer,以便您可以顺利地调用动画。
然后,实现该方法:
这应该适用于任何简单的游戏。
Use UIView animations, like in:
You should also use an NSTimer with the same interval so that you can call animations smoothly.
Then, implement the method:
This should do for ANY simple game.
当您用 cocos2d 标记问题时,我猜您正在使用或计划使用它。动画
CCSprites
很容易,例如在这个游戏 https://github.com/ haqu/tweejump。在您的
onEnter
实现中,只需调用[self ScheduleUpdate]
这将定期调用
update:
,您可以在其中进行绘图,这将处理球的平滑运动。
ball_pos
、ball_velocity
和ball_acc
为vvCertex2F
。您甚至可能不需要处理加速度,只需在有人击球时给球一个脉冲(即提高速度)。
您可能还需要一些阻尼来减慢球的速度。你可以通过降低每一步的速度来做到这一点
As you tagged the question with
cocos2d
, I guess you're using it, or planning to. AnimatingCCSprites
is easy as you can see e.g. in this game https://github.com/haqu/tweejump.In your
onEnter
implementation, just call[self scheduleUpdate]
this will call routinely the
update:
where you can do your drawingThat'll handle smooth movement of the ball.
ball_pos
,ball_velocity
andball_acc
beingvvCertex2F
.You probably don't even have to deal with acceleration, and only give an impulse to the ball when someone hit it (i.e. bump the velocity).
You probably also want some damping to slow the ball down. you do it by reducing the velocity at every step