转向点脚本不起作用
我已经想出了一个非常基本的脚本来实现这一点,但它似乎不起作用。我的脚本中的注释代码正在工作,但我的新功能不起作用。有人可以告诉我为什么这个脚本不起作用吗?
public int _x = 0;
public int _y = 0;
Bitmap _scratch = BitmapFactory.decodeResource(getResources(), R.drawable.icon);
public void move_to(int fx, int fy, int tx, int ty){
if(fx<tx){
fx+=1;
}else
if(fx>fy){
fx-=1;
}
if(fy<ty){
fy+=1;
}else
if(fy>fy){
fy-=1;
}
}
@Override
public void onDraw(Canvas canvas) {
canvas.drawColor(Color.BLACK);
canvas.drawBitmap(_scratch, _x, _y, null);
//_y+=1;
// _x+=1;
move_to(_x, _y, 50, 100);
}
I've come up with an extremely basic script to move towards a point but it does not seem to be working. the commented code that's in my script was working, but my new function is not working. Could somebody please tell me why this script is not working.
public int _x = 0;
public int _y = 0;
Bitmap _scratch = BitmapFactory.decodeResource(getResources(), R.drawable.icon);
public void move_to(int fx, int fy, int tx, int ty){
if(fx<tx){
fx+=1;
}else
if(fx>fy){
fx-=1;
}
if(fy<ty){
fy+=1;
}else
if(fy>fy){
fy-=1;
}
}
@Override
public void onDraw(Canvas canvas) {
canvas.drawColor(Color.BLACK);
canvas.drawBitmap(_scratch, _x, _y, null);
//_y+=1;
// _x+=1;
move_to(_x, _y, 50, 100);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想你想要这个:
I think you want this:
在 move_to 中更改 fx 和 fy。也许您想更改 _x 和 _y。
In move_to you change fx and fy. Maybe you want to change _x and _y instead.