2015年10月5日 星期一

02161061,陳侑增,week4

import gifAnimation.*;
PImage[] imgKPgif;
Gif myKP;
void setup(){
  size(500,500);
  myKP=new Gif(this,"KP.gif");
  myKP.loop();
}
void draw(){
  image(myKP,0,0);
}
要先裝能用gif的工具,sketch->Import library->add  library 然後搜尋gif 的第一個!~
寫完後會有一個柯p狂敲桌子,完全不會累= ="
import gifAnimation.*;
PImage[] imgKPgif;
Gif myKP;
void setup(){
  size(500,500);
  myKP=new Gif(this,"KP.gif");
}
void draw(){
  image(myKP,0,0);
}
void mousePressed(){
  myKP.play();
  myKP.ignoreRepeat();
}

Now,we can control the image.When we pressed the mouse,the image will run one time.



import gifAnimation.*;
PImage[] imgKPgif;
Gif myKP,myKP2;
void setup(){
  size(1000,500);
  myKP=new Gif(this,"KP.gif");
  myKP2=new Gif(this,"KP.gif");
}
void draw(){
  image(myKP,0,0);
  image(myKP2,500,0);
}
void mousePressed(){
  if(mouseButton==LEFT){myKP.play();myKP.ignoreRepeat();}
  if(mouseButton==RIGHT){myKP2.play();myKP2.ignoreRepeat();}
}
void keyPressed(){
  if(key=='a'){myKP.play();myKP.ignoreRepeat();}
  if(key=='b'){myKP2.play();myKP2.ignoreRepeat();}
}


We can use keyboard to control the image..

import gifAnimation.*;
PImage[] imgKPgif;
Gif myKP,myKP2;
Minim minim;
AudioPlayer player;
void setup(){
  size(1000,500);
  frameRate(100);
  minim=new Minim(this);
  player = minim.loadFile("shoes.mp3");
  player.play();
  myKP=new Gif(this,"KP.gif");
  myKP2=new Gif(this,"KP.gif");
}
void draw(){
  image(myKP,0,0);
  image(myKP2,500,0);
}
void mousePressed(){
  if(mouseButton==LEFT){myKP.jump(0);myKP.play();myKP.ignoreRepeat();}
  if(mouseButton==RIGHT){myKP2.jump(0);myKP2.play();myKP2.ignoreRepeat();}
}
void keyPressed(){
  if(key=='a'){myKP.play();myKP.ignoreRepeat();}
  if(key=='b'){myKP2.play();myKP2.ignoreRepeat();}
}

Add the music !!!~











沒有留言:

張貼留言