I'm currently working on a game that's similar to this one: https://www.youtube.com/watch?v=l8cYYPpRboo However, I don't know how I'd be able to create a main character like this (mouse aiming + rotating body). Any chance someone here could help?
public void act(){
gif();
}
private void gif(){
int SIZE = 100;
int COUNTER = 0;
COUNTER++;
GreenfootImage imageOne = new GreenfootImage (SIZE,SIZE);
GreenfootImage imageTwo = new GreenfootImage (SIZE,SIZE);
if (COUNTER==1){
setImage (imageOne);
} else if (COUNTER==2){
setImage (imageTwo);
} else {
COUNTER = 0;
setImage (imageOne);
}
}import greenfoot.GreenfootImage;
public class Animator {
private String folder;
private String action;
private int index = 0;
private int frames;
/**
* This class requires you to put your animation frames in folders. The animation frames need to be named in
* the following format: "action_index" where action is the sprites current action and index is the frames
* index.
*
* @param folder
* The name of the sprites folder
*
* @param action
* The name of the animaton sequence
*
* @param frames
* The number of frames in the animation sequence
*/
public Animator(String folder, String action, int frames) {
this.folder = folder;
this.action = action;
this.frames = frames;
}
public int getIndex() {
return index;
}
public void setIndex(int index) {
this.index = index;
}
public String getAction() {
return action;
}
public void setAction(String action, int frames) {
this.action = action;
this.frames = frames;
}
public GreenfootImage getFrame() {
GreenfootImage img = new GreenfootImage(folder + "/" + action + "_" + index);
index++;
index %= frames;
return img;
}
}