tweenanimatecanvas.java.svn-base
来自「example2 众多JAVA实例源码...学习java基础的好帮手」· SVN-BASE 代码 · 共 63 行
SVN-BASE
63 行
package opusmicro.demos.animate2;
import java.util.Vector;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Graphics;
public class TweenAnimateCanvas extends Canvas {
int width;
int height;
Vector children = new Vector();
Component child;
private int position = 0;
public TweenAnimateCanvas() {
this.setFullScreenMode(true);
width = getWidth();
height = getHeight();
}
void pre(){
if(position>0){
position--;
}
repaint();
serviceRepaints();
}
void next(){
if(position<1){
position++;
}repaint();
serviceRepaints();
}
protected void keyPressed(int keyCode){
int action = getGameAction(keyCode);
switch(action){
case Canvas.UP:pre();break;
case Canvas.DOWN:next();break;
}
}
protected void sizeChanged(int w, int h){
width = w;
height = h;
}
public void addChild(Component child){
if(!children.contains(child)) {
children.addElement(child);
}
}
protected void paint(Graphics g) {
g.setColor(-1);
g.fillRect(0, 0, width, height);
if(!children.isEmpty()){
for(int i=0;i<children.size();i++){
child = (Component) children.elementAt(i);
child.paint(g, i==position );
}
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?