當前位置:編程學習大全網 - 編程軟體 - 在《超級瑪麗》中,只要按壹下空格,人物就調跳壹下,這個用java swing怎麽實現!謝謝

在《超級瑪麗》中,只要按壹下空格,人物就調跳壹下,這個用java swing怎麽實現!謝謝

要是 swing 的button 的話

setBounds

public void setBounds(int x,

int y,

int width,

int height)移動組件並調整其大小。由 x 和 y 指定左上角的新位置,由 width 和 height 指定新的大小。

參數:

x - 組件的新 x 坐標

y - 組件的新 y 坐標

width - 組件的新 width

height - 組件的新 height

button.setBonds(button.getBonds().getX(),button.getBonds().getY()-50,button.getBonds().getWidth

(),button.getBonds().getHeight() )

button.getBonds().getY()-50, 就是向上移動坐標的關鍵

  • 上一篇:寶馬3系nbt能升級id7嗎?
  • 下一篇:誰知道在哪了可以免費下載網賺教程視頻?
  • copyright 2024編程學習大全網