日期:2014-05-20 浏览次数:20840 次
//这段代码加载Cartoon1到4,4副图片,没问题 try{ //Cartoon1...Cartoon7定义为Image Cartoon1=Image.createImage("/youli_qian10.png"); Cartoon2=Image.createImage("/youli11_20.png"); Cartoon3=Image.createImage("/youli21_30.png"); Cartoon4=Image.createImage("/youli31_41.png"); spriteCartoon1=new Sprite(Cartoon1,Cartoon1.getWidth() ,Cartoon1.getHeight()/10); spriteCartoon2=new Sprite(Cartoon2,Cartoon2.getWidth() ,Cartoon2.getHeight()/10); spriteCartoon3=new Sprite(Cartoon3,Cartoon3.getWidth() ,Cartoon3.getHeight()/10); spriteCartoon4=new Sprite(Cartoon4,Cartoon4.getWidth() ,Cartoon4.getHeight()/11); spriteYouli1=spriteCartoon1; spriteYouli2=spriteCartoon2; spriteYouli3=spriteCartoon3; spriteYouli4=spriteCartoon4; int tmpx=-80; int tmpy=30; spriteYouli1.setPosition(tmpx,tmpy); spriteYouli2.setPosition(tmpx,tmpy); spriteYouli3.setPosition(tmpx,tmpy); spriteYouli4.setPosition(tmpx,tmpy); }catch(Exception ex){};
//这里重新加载Cartoon1到7在加载第4副的时间卡主了 try{ Mydebug_Flush(-1); Cartoon1=Image.createImage("/hong1-5.png"); Mydebug_Flush(-2); Cartoon2=Image.createImage("/hong5-10.png"); Mydebug_Flush(-3);//到这里程序不在往下执行,卡在这里了 Cartoon3=Image.createImage("/hong11-15.png"); Mydebug_Flush(-4); Cartoon4=Image.createImage("/hong16-20.png"); Mydebug_Flush(-5); Cartoon5=Image.createImage("/hong21-25.png"); Mydebug_Flush(-6); Cartoon6=Image.createImage("/hong26-30.png"); Mydebug_Flush(-7); Cartoon7=Image.createImage("/hong31-35.png"); spriteHong1=new Sprite(Cartoon1,Cartoon1.getWidth()/5 ,Cartoon1.getHeight()); spriteHong2=new Sprite(Cartoon2,Cartoon2.getWidth()/5 ,Cartoon2.getHeight()); spriteHong3=new Sprite(Cartoon3,Cartoon3.getWidth()/5 ,Cartoon3.getHeight()); spriteHong4=new Sprite(Cartoon4,Cartoon4.getWidth()/5 ,Cartoon4.getHeight()); spriteHong5=new Sprite(Cartoon5,Cartoon5.getWidth()/5 ,Cartoon5.getHeight()); spriteHong6=new Sprite(Cartoon6,Cartoon6.getWidth()/5 ,Cartoon6.getHeight()); spriteHong7=new Sprite(Cartoon7,Cartoon7.getWidth()/5 ,Cartoon7.getHeight()); int tmpx,tmpy; tmpx=40;tmpy=-50; spriteHong1.setPosition(tmpx,tmpy); spriteHong2.setPosition(tmpx,tmpy); spriteHong3.setPosition(tmpx,tmpy); spriteHong4.setPosition(tmpx,tmpy); spriteHong5.setPosition(tmpx,tmpy); spriteHong6.setPosition(tmpx,tmpy); spriteHong7.setPosition(tmpx,tmpy); }catch(Exception ex){}; CartoonFrames=1; } lm.paint(gra,0,0); spriteHong1.paint(gra); Sleep(100); this.flushGraphics(); spriteHong1.nextFrame();