使用向量在XNA / C#中移动精灵
我目前正在研究使用C#语言开发XNA游戏。 我有两个类:主游戏处理程序和“ sprite”类。以下是一些基本的伪代码,我希望可以充分描述问题。 Game.cs class game { sprite the_sprite; void update(time) { var mouse = mouse.state if(mouse.clicked) { this.the_sprite.moveTo(mouse.x, mouse.y) } this.the_sprite.update(time) base.update(time) } } Sprite.cs class sprite { vector2 location; vector2 move_to; void moveTo(x, y) { this.move_to = new vector2(x, y) } void update(time) { if(this.location.x > this.move_to.x /* …