动画的目的在于两点之间移动 [英] Animating an object to move between two points

查看:91
本文介绍了动画的目的在于两点之间移动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在做一个游戏,你必须使唤部队,目的地意点击,点击士兵,士兵移动到目的地。

I'm making a game where you have to order troops around, meaning click on the destination, click on the soldier, and the soldier moves to the destination.

我有动画的部分问题。我已经想通了的MouseListener和图形的东西。我知道,你应该使用表达式y = mx + B M = Y2 - Y1 / X2 - X1 Ÿ - Y1 = M。(X - X1),但不知道如何落实到我的应用程序这种

I am having problems with the animation part. I have already figured out the MouseListener and graphics stuff. I know that you are supposed to use y = mx + b, m = y2 - y1/x2 - x1 and y - y1 = m(x - x1), but don't know how to implement this into my application.

我有一个包含了听众的游戏类和 UserUnit 包含实际的<$ C类$ C>的moveTo()方法。假设我已经得到了一切想通了,如果我不我会问。谢谢你。

I have a Game class that contains the listeners, and a UserUnit class that contains the actual moveTo() method. Assume that I've got everything else figured out, if I don't I'll ask. Thanks.

推荐答案

在此相关的例如,机器人< A HREF =htt​​p://robotchase.sourceforge.net/org/gcs/robot/RCModel.html#move%28int,%20int%29相对=nofollow> 移动(INT,INT ) 对步进在八(半)基本方向之一,如玩家的发车位置<一个href=\"http://robotchase.svn.sourceforge.net/viewvc/robotchase/trunk/src/org/gcs/robot/RCModel.java?revision=65&view=markup\"相对=nofollow>此处。 javax.swing中的一个实例。定时器 驱动动画。

In this related example, robots move(int, int) toward the player's grid position by stepping in one of eight (semi-) cardinal directions, as shown here. An instance of javax.swing.Timer drives the animation.

这篇关于动画的目的在于两点之间移动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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