国产片侵犯亲女视频播放_亚洲精品二区_在线免费国产视频_欧美精品一区二区三区在线_少妇久久久_在线观看av不卡

服務(wù)器之家:專注于服務(wù)器技術(shù)及軟件下載分享
分類導(dǎo)航

PHP教程|ASP.NET教程|Java教程|ASP教程|編程技術(shù)|正則表達(dá)式|C/C++|IOS|C#|Swift|Android|VB|R語言|JavaScript|易語言|vb.net|

服務(wù)器之家 - 編程語言 - Android - Android實現(xiàn)在屏幕上移動圖片的方法

Android實現(xiàn)在屏幕上移動圖片的方法

2021-03-26 15:17紅薯 Android

這篇文章主要介紹了Android實現(xiàn)在屏幕上移動圖片的方法,實例分析了Android操作圖片的相關(guān)技巧,需要的朋友可以參考下

本文實例講述了Android實現(xiàn)在屏幕上移動圖片的方法。分享給大家供大家參考。具體實現(xiàn)方法如下:

1. Speed.java文件:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package net.obviam.droidz.model.components;
public class Speed {
  public static final int DIRECTION_RIGHT = 1;
  public static final int DIRECTION_LEFT = -1;
  public static final int DIRECTION_UP  = -1;
  public static final int DIRECTION_DOWN = 1;
  private float xv = 1// velocity value on the X axis
  private float yv = 1// velocity value on the Y axis
  private int xDirection = DIRECTION_RIGHT;
  private int yDirection = DIRECTION_DOWN;
  public Speed() {
    this.xv = 1;
    this.yv = 1;
  }
  public Speed(float xv, float yv) {
    this.xv = xv;
    this.yv = yv;
  }
  public float getXv() {
    return xv;
  }
  public void setXv(float xv) {
    this.xv = xv;
  }
  public float getYv() {
    return yv;
  }
  public void setYv(float yv) {
    this.yv = yv;
  }
  public int getxDirection() {
    return xDirection;
  }
  public void setxDirection(int xDirection) {
    this.xDirection = xDirection;
  }
  public int getyDirection() {
    return yDirection;
  }
  public void setyDirection(int yDirection) {
    this.yDirection = yDirection;
  }
  // changes the direction on the X axis
  public void toggleXDirection() {
    xDirection = xDirection * -1;
  }
  // changes the direction on the Y axis
  public void toggleYDirection() {
    yDirection = yDirection * -1;
  }
}

2. main.java文件:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
public void run() {
  Canvas canvas;
  Log.d(TAG, "Starting game loop");
  while (running) {
    canvas = null;
    // try locking the canvas for exclusive pixel editing
    // in the surface
    try {
      canvas = this.surfaceHolder.lockCanvas();
      synchronized (surfaceHolder) {
        // update game state
        this.gamePanel.update();
        // render state to the screen
        // draws the canvas on the panel
        this.gamePanel.render(canvas);
      }
    } finally {
      // in case of an exception the surface is not left in
      // an inconsistent state
      if (canvas != null) {
        surfaceHolder.unlockCanvasAndPost(canvas);
      }
    // end finally
  }
}
public void update() {
  // check collision with right wall if heading right
  if (droid.getSpeed().getxDirection() == Speed.DIRECTION_RIGHT
      && droid.getX() + droid.getBitmap().getWidth() / 2 >= getWidth()) {
    droid.getSpeed().toggleXDirection();
  }
  // check collision with left wall if heading left
  if (droid.getSpeed().getxDirection() == Speed.DIRECTION_LEFT
      && droid.getX() - droid.getBitmap().getWidth() / 2 <= 0) {
    droid.getSpeed().toggleXDirection();
  }
  // check collision with bottom wall if heading down
  if (droid.getSpeed().getyDirection() == Speed.DIRECTION_DOWN
      && droid.getY() + droid.getBitmap().getHeight() / 2 >= getHeight()) {
    droid.getSpeed().toggleYDirection();
  }
  // check collision with top wall if heading up
  if (droid.getSpeed().getyDirection() == Speed.DIRECTION_UP
      && droid.getY() - droid.getBitmap().getHeight() / 2 <= 0) {
    droid.getSpeed().toggleYDirection();
  }
  // Update the lone droid
  droid.update();
}

希望本文所述對大家的Android程序設(shè)計有所幫助。

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 国产视频色 | 日本欧美久久久久免费播放网 | 日韩精品在线观看免费 | 亚洲欧美在线视频 | 在线成人免费电影 | 成人免费在线电影 | 成人午夜精品一区二区三区 | 国产精品3区 | 精品一区二区电影 | 91久久| 一本大道av伊人久久综合 | 亚洲夜幕久久日韩精品一区 | 日韩在线观看中文字幕 | 免费观看黄色 | 色综合视频在线观看 | 精品一区二区久久久久久久网站 | 久久精品国产99精品国产亚洲性色 | 日韩av免费在线观看 | 成人国产免费视频 | 99精品视频在线 | av网站免费线看 | 国产精品免费观看 | 搡女人真爽免费午夜网站 | 一区二区三区国产视频 | 人成网址| 激情网五月天 | 亚洲高清日本 | 黄色免费在线观看 | 欧美色图一区 | 亚洲综合二 | 成人精品视频在线观看 | av在线精品 | 国产99久久久精品视频 | 色综合久久久久 | www免费网站在线观看 | 免费一级黄色毛片 | 在线视频三级 | 国产一区二区三区在线观看网站 | 国产成人精品一区二区三区四区 | 欧美日韩成人在线视频 | 99精品久久久久久久免费 |