简体   繁体   English

XNA Game Studio最简单的精灵动画

[英]XNA game studio simplest sprite animation

Ok so i want to animate my "Hero" = Rectangle sprite i want to make very simple animation i have 2 images first(Hero sprite facing right) second image(Hero sprite facing left) the images size is equal everything its ok.All i want is whenever i move right or left my Hero Sprite image changes to Image facing right of Image facing left and i have no clue how to do that. 好吧,所以我想给我的“ Hero” =矩形精灵动画,我想制作非常简单的动画,我先有2张图像(Hero sprite朝右)第二张图像(Hero sprite朝左),图像大小等于所有ok.All我想要的是每当我向右或向左移动时,我的Hero Sprite图像都将变为Image right向左Image,我不知道该怎么做。 If someone can post an simple algorith to do that i will be very thankful thank you. 如果有人可以发布一个简单的算法来做到这一点,我将非常感谢。

Basicly i move right/left with Left/Right Arrows so when i press Right Arrow i want my Hero Image to be replaced with choosed from me image and same if i press Left Arrow 基本上,我使用向左/向右箭头向右/向左移动,因此当我按向右箭头时,我希望将我的英雄图像替换为从我的图像中选择的图像,如果我按向左箭头,则相同

If you require more information to help me ask me. 如果您需要更多信息来帮助我,请问我。

Make a sprite class, implementing animation in it (preferebly using sprite sheets), and when the left arrow is pressed: PlayerSprite = PlayerSpriteLeft and when the right arrow is pressed, do it the other way. 制作一个精灵类,在其中实现动画(最好使用精灵表),并在按下左箭头时: PlayerSprite = PlayerSpriteLeft ,在按下右箭头时,采用另一种方法。

Object oriented programming comes in really handy at this point, so make use of it! 面向对象的编程在这一点上非常方便,因此请充分利用它!

Make a Sprite class exposing the methods Draw(SpriteBatch sBatch) , Update(float time) and the properties Interval and NumberOfFrames or something like that. 使一个Sprite类公开Draw(SpriteBatch sBatch)Update(float time)以及属性IntervalNumberOfFrames或类似的东西。

Be creative! 有创造力!

The platformer example on the Microsoft website is a good place to start. Microsoft网站上的平台程序示例是一个很好的起点。 It has a Sprite animation class that you'll be able to learn from. 它具有一个Sprite动画类,您可以从中学习。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM