简体   繁体   English

在月食的y轴上向上移动图像

[英]Move image up they y-axis in eclipse

I am making a game for androids using eclipse and I had some trouble trying to figure this out. 我正在使用eclipse开发一款适用于Android的游戏,但在尝试解决这一问题时遇到了一些麻烦。 I already have 2 images on my layout and I just want to figure out how to make them move one unit up the y axis with a timer that is repeatedly. 我的布局上已经有2张图片,我只想弄清楚如何使它们重复使用一个计时器沿y轴向上移动一个单位。 Thanks alot for any help appreciate it! 非常感谢您提供的任何帮助!

You can do something like 你可以做类似的事情

final int interval = 1000; // one second


View myView = ...;
Handler handler = new Handler();
Runnable runnable = new Runnable() {
    @Override
    public void run() {
        // Do work
        myView.setY(myView.getY() + 1); 
        handler.postDelayed(this, interval);
   }
handler.post(runnable);

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

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