怎样实现图片自上而下慢慢显示出来?
代码如下,请各位支个招,谢谢!
这样的话每次只能显示裁减区域的图片,其他区域均为白色,对于裁减区域我不是很懂.
public class AplashCanvas extends Canvas {
/**
* constructor
*/
private Displayable nextUI;
private int width;
private int height;
private Font font;
private Image img=null;
private int y;
private Timer timer=null;
private boolean first;
public AplashCanvas(Displayable disp) {
first=true;
this.nextUI=disp;
width=this.getWidth();
height=this.getHeight();
font=Font.getDefaultFont();
timer=new Timer();
//初始化图片
try
{
img=Image.createImage( "/images/011.png ");
}
catch(
IOException e)
{
e.printStackTrace();
}
//初始化绘图纵坐标
y=this.height/2-this.img.getHeight()/2;
}
/**
* paint
*/
public void paint(Graphics g) {
if(first)
{
g.setColor(0xffffff);
g.fillRect(0,0,this.getWidth(),this.getHeight());
}
//设置裁剪区域
g.setClip(0,y,width,5);
// System.out.println(y);
//绘制图片
g.drawImage(this.img,this.width/2,this.height/2,Graphics.VCENTER|Graphics.HCENTER);