如何在Cocoa中移动sprite? [英] How do I move a sprite in Cocoa?

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

问题描述

我在Objective-C中使用Mac可可应用程序。这是一个很简单的问题,但我找不到答案。我只想在屏幕上移动一个精灵,就像在Snake游戏。我需要使用NSTimer或NSAnimation,我将如何使用它?

I'm working in Objective-C for a Mac cocoa application. It's a pretty simple question, but I can't find an answer. I just want to move a sprite across the screen, like in a Snake game. Do I need to use NSTimer or NSAnimation, and how would I use it?

感谢

推荐答案

您可以使用Core Animation。它提供了一个统一的方法来移动和动画在屏幕上的视觉元素。

如果你打算创建一个简单的游戏,可爱的爱有一个很好的小行星的例子:

http://cocoawithlove.com/2009/02/asteroids- style-game-in-coreanimation.html

You could use Core Animation. It provides a unified way to move and animate visual elements on the screen.
If you plan to create a simple game, "Cocoa with Love" has a nice "Asteroid" example:
http://cocoawithlove.com/2009/02/asteroids-style-game-in-coreanimation.html

另一个与游戏相关的核心动画项目是Apple的Geek游戏板:
http://developer.apple.com/library/mac/#samplecode/GeekGameBoard/简介/ Intro.html

Another game-related Core Animation project is Apple's Geek Game Board: http://developer.apple.com/library/mac/#samplecode/GeekGameBoard/Introduction/Intro.html

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

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