Hey,
So Im trying to make my animation only run through once, it is repeating. Im trying to make it only go through once and be done. (Im making a castlevaniaesk game) (Its also for my grade 12 final project)
class Alucard {
float x = width/2;
float y = height/2;
float xspeed = 0;
float yspeed = 0;
PImage[] alwalk = new PImage[16];
int currentwa = 0;
PImage alidle = new PImage();
PImage[] alatt = new PImage[17];
int currentat = 0;
Alucard() {
walking();
//jumping();
//running();
attack();
idle();
}
void idle() {
if (action == 0) {
alidle = loadImage(âidle.pngâ);
image(alidle, x, y);
}
}
void walking() {
alwalk[0] = loadImage(âwalking15.pngâ);
alwalk[1] = loadImage(âwalking16.pngâ);
alwalk[2] = loadImage(âwalking17.pngâ);
alwalk[3] = loadImage(âwalking18.pngâ);
alwalk[4] = loadImage(âwalking19.pngâ);
alwalk[5] = loadImage(âwalking20.pngâ);
alwalk[6] = loadImage(âwalking21.pngâ);
alwalk[7] = loadImage(âwalking22.pngâ);
alwalk[8] = loadImage(âwalking23.pngâ);
alwalk[9] = loadImage(âwalking24.pngâ);
alwalk[10] = loadImage(âwalking25.pngâ);
alwalk[11] = loadImage(âwalking26.pngâ);
alwalk[12] = loadImage(âwalking27.pngâ);
alwalk[13] = loadImage(âwalking28.pngâ);
alwalk[14] = loadImage(âwalking29.pngâ);
alwalk[15] = loadImage(âwalking30.pngâ);
if (key == âdâ) {
action = 2;
if (action == 2) {
image(alwalk[currentwa], x, y);
currentwa++;
if (currentwa > 15)currentwa = 0;
}
}
}
void attack() {
alatt[0] = loadImage(âattack0.pngâ);
alatt[1] = loadImage(âattack1.pngâ);
alatt[2] = loadImage(âattack2.pngâ);
alatt[3] = loadImage(âattack3.pngâ);
alatt[4] = loadImage(âattack4.pngâ);
alatt[5] = loadImage(âattack5.pngâ);
alatt[6] = loadImage(âattack6.pngâ);
alatt[7] = loadImage(âattack7.pngâ);
alatt[8] = loadImage(âattack8.pngâ);
alatt[9] = loadImage(âattack9.pngâ);
alatt[10] = loadImage(âattack10.pngâ);
alatt[11] = loadImage(âattack11.pngâ);
alatt[12] = loadImage(âattack12.pngâ);
alatt[13] = loadImage(âattack13.pngâ);
alatt[14] = loadImage(âattack14.pngâ);
alatt[15] = loadImage(âattack15.pngâ);
alatt[16] = loadImage(âattack16.pngâ);
if (key == âzâ) {
action = 3;
if (action == 3) {
image(alatt[currentat], x, y);
currentat++;
if (currentat == 16) {
action = 0;
background(255);
}
}
println(action);
}
}
}