mousePress() add animated .png
in
Programming Questions
•
1 year ago
I have a series of .png pictures that make up a small 72 animated framed picture. Currently I have an empty variable of Animation PenguinAnimation; up at the top.
In my setup() I have
PenguinAnimation = new Animation("PenguinAnimation/penguin_", 72, 4, ".png");
I have nothing in my draw() for the penguin.
I have nothing in my mousePressed() because I am not even sure I need this yet.
Basically what I want to do is every time I press my left mouse button, I want my penguin animation to appear and stay doing his little juggling act. I also want to be able to click multiple times and have many penguins appear and do their juggling act.
I currently have an animated background and a stationary dancing bear showing as well as a singing shark which follows my mouse.
This has to be something really easy that I am missing.
Any help is greatly appreciated.
In my setup() I have
PenguinAnimation = new Animation("PenguinAnimation/penguin_", 72, 4, ".png");
I have nothing in my draw() for the penguin.
I have nothing in my mousePressed() because I am not even sure I need this yet.
Basically what I want to do is every time I press my left mouse button, I want my penguin animation to appear and stay doing his little juggling act. I also want to be able to click multiple times and have many penguins appear and do their juggling act.
I currently have an animated background and a stationary dancing bear showing as well as a singing shark which follows my mouse.
This has to be something really easy that I am missing.
Any help is greatly appreciated.
- Animation DiscoBackgroundAnimation;
Animation BearAnimation;
Animation SharkAnimation;
Animation PenguinAnimation;
PVector trueLocationVector;
float reactionTime;
import ddf.minim.*; - AudioPlayer player;
Minim minim;
void setup()
{
size(640, 360, P3D); //set the size of the display area
frameRate(30);
- DiscoBackgroundAnimation = new Animation("DiscoBackgroundAnimation/disco_", 42, 4, ".png");
BearAnimation = new Animation("BearAnimation/bear_", 12, 4, ".png"); //instantiate another for another
PenguinAnimation = new Animation("PenguinAnimation/penguin_", 72, 4, ".png");
//new audio player
minim = new Minim(this);
player = minim.loadFile("Music/dancing.mp3", 2048);
player.play();
SharkAnimation = new Animation("SharkAnimation/shark_", 12, 4, ".png");
trueLocationVector= new PVector(width/2, height/2);
reactionTime = 1;
}
void draw()
{
DiscoBackgroundAnimation.display(0, 0);
BearAnimation.display(256, 116);
trueLocationVector.x+=((float(mouseX))-(trueLocationVector.x))/reactionTime;
- trueLocationVector.y+=((float(mouseY))-(trueLocationVector.y))/reactionTime;
- SharkAnimation.display(int(trueLocationVector.x)-64, int(trueLocationVector.y)-64);
} - void mousePressed()
- {
- }
1