This site requires JavaScript, please enable it in your browser!
Greenfoot back
LaurentiuRohan
LaurentiuRohan wrote ...

2018/2/7

Play charater idle animation if there aren't any keys pressed

4
5
6
7
LaurentiuRohan LaurentiuRohan

2018/2/27

#
danpost wrote...
In your Menu world constructor, add the following line:
Puppy_Player.lives = 3;// or whatever starting value it is supposed to get
Then in the Puppy_Player class, change the field declaration line for 'lives' to this:
public static int lives;
I added the second line to the Puppy class and first to the Start_LevelSelect_World because from there I want that Puppy to begin the game. But when the world loads that world and Mace_Level lives = 0, and if he touches water class lives are starting decreasing by -1 without changing Game_Over
danpost danpost

2018/2/27

#
Do not set the value of line in any other world class (like, remove line 29, I believe it to be at) in the Mace_Level class.
LaurentiuRohan LaurentiuRohan

2018/2/27

#
danpost wrote...
Do not set the value of line in any other world class (like, remove line 29, I believe it to be at) in the Mace_Level class.
Still won't work, I added the scenario updated here again, could you please look at it , and tell me what I did wrong with lives..? http://www.greenfoot.org/scenarios/20903
danpost danpost

2018/2/27

#
LaurentiuRohan wrote...
danpost wrote...
Do not set the value of line in any other world class (like, remove line 29, I believe it to be at) in the Mace_Level class.
Still won't work, I added the scenario updated here again, could you please look at it , and tell me what I did wrong with lives..? http://www.greenfoot.org/scenarios/20903
I will be out for a while, so I will not be able to get to it right away.
LaurentiuRohan LaurentiuRohan

2018/2/27

#
danpost wrote...
LaurentiuRohan wrote...
danpost wrote...
Do not set the value of line in any other world class (like, remove line 29, I believe it to be at) in the Mace_Level class.
Still won't work, I added the scenario updated here again, could you please look at it , and tell me what I did wrong with lives..? http://www.greenfoot.org/scenarios/20903
I will be out for a while, so I will not be able to get to it right away.
Plase, just the thing with lives, I have to give the project at school tommorow...
danpost danpost

2018/2/28

#
I still see lives being assigned a value of 3 in multiple world classes. Also, I see it being declared in more than one class as well. It should only be declared once and should only be set once at the beginning.
LaurentiuRohan LaurentiuRohan

2018/3/7

#
danpost wrote...
I still see lives being assigned a value of 3 in multiple world classes. Also, I see it being declared in more than one class as well. It should only be declared once and should only be set once at the beginning.
Danpost, please help me with something. I want to add game to android platfrom, so I have to change Greenfoot.keyisdown with Greenfoot.mousePressed. So I created 2 buttosn and added them to the every world of the game. I tried to add this commands separately into act and check key methods of the Puppy_Player but doesen't works. If any of button is clicked the player makes nothing. I want to do everything what he does like when the keys are pressed, I mean runing the annimation that you helped me with, Now the of Puppy looks like that. For Buttons actors that have to be pressed for movin left and right there isn't any code. Can you help me please? Those 2 are the lines of code that I've tried to add in the act and checkKey and act method, but won't work.
if(Greenfoot.mousePressed(Move_Left.class))
        {
            this.moveLeft();
        }
       if(Greenfoot.mousePressed(Move_Right.class))
        {
            moveRight();
        }
This is the entire code of Puppy:
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.util.List;
import java.util.ArrayList;
/**
 * Write a description of class Puppy_Player here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Puppy_Player extends Actor
{
    private int vSpeed = 7;
    private int acceleration = 2;
    private int jumpStrenght = 20;
    public boolean jumping;
    private int speed = 4;
    private boolean onGrounds; 
    private int frame = 1;
    private boolean fell = false;
     private boolean gotHit;
    static GreenfootSound jump = new GreenfootSound("Jump.wav");
    static GreenfootSound die = new GreenfootSound("Die.mp3");
    
    
    private int lives;

    /**
     * Act - do whatever the Doors_Level_Select wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    { 
       checkKey();
       checkFall();
   
       GreenfootImage[] inAnimation = currentAnimation;
       int atFrame = frame;
       int dx = 0, dy = 0;
        if(Greenfoot.mousePressed(Move_Left.class)) dx--;
        if (Greenfoot.isKeyDown("right")) dx++;
        if (dx  == 0) // idle
         {
        if (idleLeftAnimation != currentAnimation && idleRightAnimation != currentAnimation)
            {
          if (runningRightAnimation == currentAnimation || jumpingRightAnimation == currentAnimation)
             currentAnimation = idleRightAnimation;
          else
             currentAnimation = idleLeftAnimation;
             frame = 0;
            }
        }
        else if (dx == 1 && currentAnimation != runningRightAnimation)
         {
            currentAnimation = runningRightAnimation;
            frame = 0;
         }
        else if (dx == -1 && currentAnimation != runningLeftAnimation)
         {
            currentAnimation = runningLeftAnimation;
            frame = 0;
         }

         setImage(currentAnimation[frame]);
         frame = (frame+1)%currentAnimation.length;
         

         
       if(getY() >= 540)
        {
            Scrooling_Worlds Scrooling_Worlds = (Scrooling_Worlds)getWorld();
            Scrooling_Worlds.resetCoins();
            die.play();
            if (getWorld() instanceof Mace_Level)
            {
                Greenfoot.setWorld(new GameOver_World());
                
            }
           
            if (getWorld() instanceof Saw_Level)
            {
                Greenfoot.setWorld(new GameOver_World());
            }
            if (getWorld() instanceof Orc_Level)
            {
                Greenfoot.setWorld(new GameOver_World());
            }
       }    
       
        if(getOneObjectAtOffset (0, getImage().getHeight() , Spike_Up.class)!= null)
       {
           Scrooling_Worlds Scrooling_Worlds = (Scrooling_Worlds)getWorld();
            Scrooling_Worlds.resetCoins();
            die.play();
            if (getWorld() instanceof Mace_Level)
            {
                Greenfoot.setWorld(new GameOver_World());    
            }
           
            if (getWorld() instanceof Saw_Level)
            {
                Greenfoot.setWorld(new GameOver_World());
            }
            if (getWorld() instanceof Orc_Level)
            {
                Greenfoot.setWorld(new GameOver_World());
            }
       }   
        
         
 
         if(getOneObjectAtOffset (0, getImage().getHeight() , Water.class)!= null)
       {
           Scrooling_Worlds Scrooling_Worlds = (Scrooling_Worlds)getWorld();
            Scrooling_Worlds.resetCoins();
            die.play();
            if (getWorld() instanceof Mace_Level)
            {
                Greenfoot.setWorld(new GameOver_World());
                
            }
           
            if (getWorld() instanceof Saw_Level)
            {
                Greenfoot.setWorld(new GameOver_World());
            }
            if (getWorld() instanceof Orc_Level)
            {
                Greenfoot.setWorld(new GameOver_World());
            }
       }    
       
        if(getOneObjectAtOffset (0, getImage().getHeight() , Spike_Up.class)!= null)
       {
           Scrooling_Worlds Scrooling_Worlds = (Scrooling_Worlds)getWorld();
            Scrooling_Worlds.resetCoins();
            die.play();
            if (getWorld() instanceof Mace_Level)
            {
                Greenfoot.setWorld(new GameOver_World());    
            }
           
            if (getWorld() instanceof Saw_Level)
            {
                Greenfoot.setWorld(new GameOver_World());
            }
            if (getWorld() instanceof Orc_Level)
            {
                Greenfoot.setWorld(new GameOver_World());
            }
       }   
       
        if(getOneObjectAtOffset (0, getImage().getHeight() , Spike_Down.class)!= null)
       {
           Scrooling_Worlds Scrooling_Worlds = (Scrooling_Worlds)getWorld();
            Scrooling_Worlds.resetCoins();
            die.play();
            if (getWorld() instanceof Mace_Level)
            {
                Greenfoot.setWorld(new GameOver_World()); 
            }
           
            if (getWorld() instanceof Saw_Level)
            {
                Greenfoot.setWorld(new GameOver_World());
            }
            if (getWorld() instanceof Orc_Level)
            {
                Greenfoot.setWorld(new GameOver_World());
            }
       }    
       
       
       
       
         if(getOneObjectAtOffset (0, getImage().getHeight() , Mace.class)!= null)
       {
           Scrooling_Worlds Scrooling_Worlds = (Scrooling_Worlds)getWorld();
           Scrooling_Worlds.resetCoins();
           die.play();
            if (getWorld() instanceof Mace_Level)
            {
                Greenfoot.setWorld(new GameOver_World());   
            }
        }
        
          if(getOneObjectAtOffset (0, getImage().getHeight() , Saw.class)!= null)
       {
           Scrooling_Worlds Scrooling_Worlds = (Scrooling_Worlds)getWorld();
           Scrooling_Worlds.resetCoins();
           die.play();
           if (getWorld() instanceof Saw_Level)
           {
                Greenfoot.setWorld(new GameOver_World());  
           }
        }
        
           if(getOneObjectAtOffset (0, getImage().getHeight() , Orc.class)!= null)
       {
           Scrooling_Worlds Scrooling_Worlds = (Scrooling_Worlds)getWorld();
            Scrooling_Worlds.resetCoins();
            die.play();
            
            if (getWorld() instanceof Orc_Level)
            {
                Greenfoot.setWorld(new GameOver_World());   
            }
        }
        
           
         if(getOneObjectAtOffset (0, getImage().getHeight() , Chest.class)!= null)
       {
           Scrooling_Worlds Scrooling_Worlds = (Scrooling_Worlds)getWorld();
            Scrooling_Worlds.resetCoins();
            die.play();
            if (getWorld() instanceof Orc_Level)
            {
                Greenfoot.setWorld(new YouWin_World());   
            }
        }
        
         if(getOneObjectAtOffset (0, getImage().getHeight()/8 , Water_Menu.class)!= null)
       {
            Greenfoot.setWorld(new Start_LevelSelect_World());   
        }

      
  }   

  public void checkFall()
   {
    if(onGround()) 
     {
        vSpeed = 0;
     } 
    else 
     {
        fall();
     } 
   }
    
   public boolean onGround()
   {
       Actor under = getOneObjectAtOffset(0,getImage().getHeight() /2  ,Grounds.class);
       return under != null;
   }
   
   public void fall()
   {
       setLocation(getX(), getY() + vSpeed);
       vSpeed = vSpeed + acceleration;
   }
   
   public void jump()
   {
       vSpeed = -jumpStrenght;
       speed = 6;
       jump.play();
       fall();
   }    
   
   public void moveRight()
   {
       setLocation(getX()+speed, getY());
   }   
   
   public void moveLeft()
   {
       setLocation(getX()-speed, getY());
   } 
   
   public void checkKey()
   {
        if(Greenfoot.mousePressed(Move_Left.class))
        {
            moveLeft();
        }
       if(Greenfoot.mousePressed(Move_Right.class))
        {
            moveRight();
        }
       if(Greenfoot.mousePressed(Move_Left.class))
        {
            moveLeft();
        }
       if (Greenfoot.isKeyDown("up") && onGround())
        {
            jump();     
        }
       if (Greenfoot.isKeyDown("down") && (isTouching(Door_Saw.class)))
       {
               Greenfoot.setWorld(new Saw_Level());
       }
       if (Greenfoot.isKeyDown("down") && (isTouching(Door_Mace.class)))
       {
               Greenfoot.setWorld(new Mace_Level());
       } 
       if (Greenfoot.isKeyDown("down") && (isTouching(Door_Orc.class)))
       {
               Greenfoot.setWorld(new Orc_Level());
       }
       
    }
        
        /** Animatie Alergare Dreapta*/
private final GreenfootImage[] runningRightAnimation =
{
    new GreenfootImage("Puupy_RR1.png" ),
    new GreenfootImage("Puupy_RR2.png"),
    new GreenfootImage("Puupy_RR3.png"),
    new GreenfootImage("Puupy_RR4.png"),
    new GreenfootImage("Puupy_RR5.png"),
    new GreenfootImage("Puupy_RR6.png"),
    new GreenfootImage("Puupy_RR7.png"),
    new GreenfootImage("Puupy_RR8.png"),
    new GreenfootImage("Puupy_RR9.png"),
    new GreenfootImage("Puupy_RR10.png"),
    new GreenfootImage("Puupy_RR11.png"),
    new GreenfootImage("Puupy_RR12.png"),
    new GreenfootImage("Puupy_RR13.png"),
    new GreenfootImage("Puupy_RR14.png"),
    new GreenfootImage("Puupy_RR15.png"),
    new GreenfootImage("Puupy_RR16.png"),
    new GreenfootImage("Puupy_RR17.png"),
    new GreenfootImage("Puupy_RR18.png")
};
 
/** Animatie Alergare Stanga */
private final GreenfootImage[] runningLeftAnimation =
{
    new GreenfootImage("Puupy_RL1.png"),
    new GreenfootImage("Puupy_RL2.png"),
    new GreenfootImage("Puupy_RL3.png"),
    new GreenfootImage("Puupy_RL4.png"),
    new GreenfootImage("Puupy_RL5.png"),
    new GreenfootImage("Puupy_RL6.png"),
    new GreenfootImage("Puupy_RL7.png"),
    new GreenfootImage("Puupy_RL8.png"),
    new GreenfootImage("Puupy_RL9.png"),
    new GreenfootImage("Puupy_RL10.png"),
    new GreenfootImage("Puupy_RL11.png"),
    new GreenfootImage("Puupy_RL12.png"),
    new GreenfootImage("Puupy_RL13.png"),
    new GreenfootImage("Puupy_RL14.png"),
    new GreenfootImage("Puupy_RL15.png"),
    new GreenfootImage("Puupy_RL16.png"),
    new GreenfootImage("Puupy_RL17.png"),
    new GreenfootImage("Puupy_RL18.png")
};
 
/** Animatie Saritura Dreapta*/
private final GreenfootImage[] jumpingRightAnimation =
{
    new GreenfootImage("Puppy_JumpRight1.png"),
    new GreenfootImage("Puppy_JumpRight2.png")
};
 
/** Animatie Saritura Stanga */
private final GreenfootImage[] jumpingLeftAnimation =
{
    new GreenfootImage("Puppy_JumpLeft1.png"),
    new GreenfootImage("Puppy_JumpLeft2.png")
};
 
/** Animatie Inactiv dreapta */
private final GreenfootImage[] idleRightAnimation =
{
    new GreenfootImage("Puupy_Inactive_Right1.png"),
    new GreenfootImage("Puupy_Inactive_Right2.png"),
    new GreenfootImage("Puupy_Inactive_Right3.png"),
    new GreenfootImage("Puupy_Inactive_Right4.png"),
    new GreenfootImage("Puupy_Inactive_Right5.png"),
    new GreenfootImage("Puupy_Inactive_Right6.png"),
    new GreenfootImage("Puupy_Inactive_Right7.png"),
    new GreenfootImage("Puupy_Inactive_Right8.png"),
    new GreenfootImage("Puupy_Inactive_Right9.png"),
    new GreenfootImage("Puupy_Inactive_Right10.png"),
    new GreenfootImage("Puupy_Inactive_Right11.png")
};
 
/** Animatie Inactiv Stamga */
private final GreenfootImage[] idleLeftAnimation =
{
    new GreenfootImage("Puupy_Inactive_Left1.png"),
    new GreenfootImage("Puupy_Inactive_Left2.png"),
    new GreenfootImage("Puupy_Inactive_Left3.png"),
    new GreenfootImage("Puupy_Inactive_Left4.png"),
    new GreenfootImage("Puupy_Inactive_Left5.png"),
    new GreenfootImage("Puupy_Inactive_Left6.png"),
    new GreenfootImage("Puupy_Inactive_Left7.png"),
    new GreenfootImage("Puupy_Inactive_Left8.png"),
    new GreenfootImage("Puupy_Inactive_Left9.png"),
    new GreenfootImage("Puupy_Inactive_Left10.png"),
    new GreenfootImage("Puupy_Inactive_Left10.png")
};
 
/** Animatia curenta */
private GreenfootImage[] currentAnimation = idleRightAnimation;
    }
danpost danpost

2018/3/7

#
I see at lines 39 and 40 that you change the code for left, but not for right.
LaurentiuRohan LaurentiuRohan

2018/3/7

#
danpost wrote...
I see at lines 39 and 40 that you change the code for left, but not for right.
Well changed now for right too, but still making anything.
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.util.List;
import java.util.ArrayList;
/**
 * Write a description of class Puppy_Player here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Puppy_Player extends Actor
{
    private int vSpeed = 7;
    private int acceleration = 2;
    private int jumpStrenght = 20;
    public boolean jumping;
    private int speed = 4;
    private boolean onGrounds; 
    private int frame = 1;
    private boolean fell = false;
     private boolean gotHit;
    static GreenfootSound jump = new GreenfootSound("Jump.wav");
    static GreenfootSound die = new GreenfootSound("Die.mp3");
     
     
    private int lives;
 
    /**
     * Act - do whatever the Doors_Level_Select wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    { 
       checkKey();
       checkFall();
    
       GreenfootImage[] inAnimation = currentAnimation;
       int atFrame = frame;
       int dx = 0, dy = 0;
        if(Greenfoot.mousePressed(Left.class)) dx--;
        if(Greenfoot.mousePressed(Right.class))dx++;
        if (dx  == 0) // idle
         {
        if (idleLeftAnimation != currentAnimation && idleRightAnimation != currentAnimation)
            {
          if (runningRightAnimation == currentAnimation || jumpingRightAnimation == currentAnimation)
             currentAnimation = idleRightAnimation;
          else
             currentAnimation = idleLeftAnimation;
             frame = 0;
            }
        }
        else if (dx == 1 && currentAnimation != runningRightAnimation)
         {
            currentAnimation = runningRightAnimation;
            frame = 0;
         }
        else if (dx == -1 && currentAnimation != runningLeftAnimation)
         {
            currentAnimation = runningLeftAnimation;
            frame = 0;
         }
 
         setImage(currentAnimation[frame]);
         frame = (frame+1)%currentAnimation.length;
          
 
          
       if(getY() >= 540)
        {
            Scrooling_Worlds Scrooling_Worlds = (Scrooling_Worlds)getWorld();
            Scrooling_Worlds.resetCoins();
            die.play();
            if (getWorld() instanceof Mace_Level)
            {
                Greenfoot.setWorld(new GameOver_World());
                 
            }
            
            if (getWorld() instanceof Saw_Level)
            {
                Greenfoot.setWorld(new GameOver_World());
            }
            if (getWorld() instanceof Orc_Level)
            {
                Greenfoot.setWorld(new GameOver_World());
            }
       }    
        
        if(getOneObjectAtOffset (0, getImage().getHeight() , Spike_Up.class)!= null)
       {
           Scrooling_Worlds Scrooling_Worlds = (Scrooling_Worlds)getWorld();
            Scrooling_Worlds.resetCoins();
            die.play();
            if (getWorld() instanceof Mace_Level)
            {
                Greenfoot.setWorld(new GameOver_World());    
            }
            
            if (getWorld() instanceof Saw_Level)
            {
                Greenfoot.setWorld(new GameOver_World());
            }
            if (getWorld() instanceof Orc_Level)
            {
                Greenfoot.setWorld(new GameOver_World());
            }
       }   
         
          
  
         if(getOneObjectAtOffset (0, getImage().getHeight() , Water.class)!= null)
       {
           Scrooling_Worlds Scrooling_Worlds = (Scrooling_Worlds)getWorld();
            Scrooling_Worlds.resetCoins();
            die.play();
            if (getWorld() instanceof Mace_Level)
            {
                Greenfoot.setWorld(new GameOver_World());
                 
            }
            
            if (getWorld() instanceof Saw_Level)
            {
                Greenfoot.setWorld(new GameOver_World());
            }
            if (getWorld() instanceof Orc_Level)
            {
                Greenfoot.setWorld(new GameOver_World());
            }
       }    
        
        if(getOneObjectAtOffset (0, getImage().getHeight() , Spike_Up.class)!= null)
       {
           Scrooling_Worlds Scrooling_Worlds = (Scrooling_Worlds)getWorld();
            Scrooling_Worlds.resetCoins();
            die.play();
            if (getWorld() instanceof Mace_Level)
            {
                Greenfoot.setWorld(new GameOver_World());    
            }
            
            if (getWorld() instanceof Saw_Level)
            {
                Greenfoot.setWorld(new GameOver_World());
            }
            if (getWorld() instanceof Orc_Level)
            {
                Greenfoot.setWorld(new GameOver_World());
            }
       }   
        
        if(getOneObjectAtOffset (0, getImage().getHeight() , Spike_Down.class)!= null)
       {
           Scrooling_Worlds Scrooling_Worlds = (Scrooling_Worlds)getWorld();
            Scrooling_Worlds.resetCoins();
            die.play();
            if (getWorld() instanceof Mace_Level)
            {
                Greenfoot.setWorld(new GameOver_World()); 
            }
            
            if (getWorld() instanceof Saw_Level)
            {
                Greenfoot.setWorld(new GameOver_World());
            }
            if (getWorld() instanceof Orc_Level)
            {
                Greenfoot.setWorld(new GameOver_World());
            }
       }    
        
        
        
        
         if(getOneObjectAtOffset (0, getImage().getHeight() , Mace.class)!= null)
       {
           Scrooling_Worlds Scrooling_Worlds = (Scrooling_Worlds)getWorld();
           Scrooling_Worlds.resetCoins();
           die.play();
            if (getWorld() instanceof Mace_Level)
            {
                Greenfoot.setWorld(new GameOver_World());   
            }
        }
         
          if(getOneObjectAtOffset (0, getImage().getHeight() , Saw.class)!= null)
       {
           Scrooling_Worlds Scrooling_Worlds = (Scrooling_Worlds)getWorld();
           Scrooling_Worlds.resetCoins();
           die.play();
           if (getWorld() instanceof Saw_Level)
           {
                Greenfoot.setWorld(new GameOver_World());  
           }
        }
         
           if(getOneObjectAtOffset (0, getImage().getHeight() , Orc.class)!= null)
       {
           Scrooling_Worlds Scrooling_Worlds = (Scrooling_Worlds)getWorld();
            Scrooling_Worlds.resetCoins();
            die.play();
             
            if (getWorld() instanceof Orc_Level)
            {
                Greenfoot.setWorld(new GameOver_World());   
            }
        }
         
            
         if(getOneObjectAtOffset (0, getImage().getHeight() , Chest.class)!= null)
       {
           Scrooling_Worlds Scrooling_Worlds = (Scrooling_Worlds)getWorld();
            Scrooling_Worlds.resetCoins();
            die.play();
            if (getWorld() instanceof Orc_Level)
            {
                Greenfoot.setWorld(new YouWin_World());   
            }
        }
         
         if(getOneObjectAtOffset (0, getImage().getHeight()/8 , Water_Menu.class)!= null)
       {
            Greenfoot.setWorld(new Start_LevelSelect_World());   
        }
 
       
  }   
 
  public void checkFall()
   {
    if(onGround()) 
     {
        vSpeed = 0;
     } 
    else
     {
        fall();
     } 
   }
     
   public boolean onGround()
   {
       Actor under = getOneObjectAtOffset(0,getImage().getHeight() /2  ,Grounds.class);
       return under != null;
   }
    
   public void fall()
   {
       setLocation(getX(), getY() + vSpeed);
       vSpeed = vSpeed + acceleration;
   }
    
   public void jump()
   {
       vSpeed = -jumpStrenght;
       speed = 6;
       jump.play();
       fall();
   }    
    
   public void moveRight()
   {
       setLocation(getX()+speed, getY());
   }   
    
   public void moveLeft()
   {
       setLocation(getX()-speed, getY());
   } 
    
   public void checkKey()
   {
        if(Greenfoot.mousePressed(Left.class))
        {
            moveLeft();
        }
       if(Greenfoot.mousePressed(Right.class))
        {
            moveRight();
        }
    }
    
    {
       if (Greenfoot.isKeyDown("up") && onGround())
        {
            jump();     
        }
       if (Greenfoot.isKeyDown("down") && (isTouching(Door_Saw.class)))
       {
               Greenfoot.setWorld(new Saw_Level());
       }
       if (Greenfoot.isKeyDown("down") && (isTouching(Door_Mace.class)))
       {
               Greenfoot.setWorld(new Mace_Level());
       } 
       if (Greenfoot.isKeyDown("down") && (isTouching(Door_Orc.class)))
       {
               Greenfoot.setWorld(new Orc_Level());
       }
        
    }
         
        /** Animatie Alergare Dreapta*/
private final GreenfootImage[] runningRightAnimation =
{
    new GreenfootImage("Puupy_RR1.png" ),
    new GreenfootImage("Puupy_RR2.png"),
    new GreenfootImage("Puupy_RR3.png"),
    new GreenfootImage("Puupy_RR4.png"),
    new GreenfootImage("Puupy_RR5.png"),
    new GreenfootImage("Puupy_RR6.png"),
    new GreenfootImage("Puupy_RR7.png"),
    new GreenfootImage("Puupy_RR8.png"),
    new GreenfootImage("Puupy_RR9.png"),
    new GreenfootImage("Puupy_RR10.png"),
    new GreenfootImage("Puupy_RR11.png"),
    new GreenfootImage("Puupy_RR12.png"),
    new GreenfootImage("Puupy_RR13.png"),
    new GreenfootImage("Puupy_RR14.png"),
    new GreenfootImage("Puupy_RR15.png"),
    new GreenfootImage("Puupy_RR16.png"),
    new GreenfootImage("Puupy_RR17.png"),
    new GreenfootImage("Puupy_RR18.png")
};
  
/** Animatie Alergare Stanga */
private final GreenfootImage[] runningLeftAnimation =
{
    new GreenfootImage("Puupy_RL1.png"),
    new GreenfootImage("Puupy_RL2.png"),
    new GreenfootImage("Puupy_RL3.png"),
    new GreenfootImage("Puupy_RL4.png"),
    new GreenfootImage("Puupy_RL5.png"),
    new GreenfootImage("Puupy_RL6.png"),
    new GreenfootImage("Puupy_RL7.png"),
    new GreenfootImage("Puupy_RL8.png"),
    new GreenfootImage("Puupy_RL9.png"),
    new GreenfootImage("Puupy_RL10.png"),
    new GreenfootImage("Puupy_RL11.png"),
    new GreenfootImage("Puupy_RL12.png"),
    new GreenfootImage("Puupy_RL13.png"),
    new GreenfootImage("Puupy_RL14.png"),
    new GreenfootImage("Puupy_RL15.png"),
    new GreenfootImage("Puupy_RL16.png"),
    new GreenfootImage("Puupy_RL17.png"),
    new GreenfootImage("Puupy_RL18.png")
};
  
/** Animatie Saritura Dreapta*/
private final GreenfootImage[] jumpingRightAnimation =
{
    new GreenfootImage("Puppy_JumpRight1.png"),
    new GreenfootImage("Puppy_JumpRight2.png")
};
  
/** Animatie Saritura Stanga */
private final GreenfootImage[] jumpingLeftAnimation =
{
    new GreenfootImage("Puppy_JumpLeft1.png"),
    new GreenfootImage("Puppy_JumpLeft2.png")
};
  
/** Animatie Inactiv dreapta */
private final GreenfootImage[] idleRightAnimation =
{
    new GreenfootImage("Puupy_Inactive_Right1.png"),
    new GreenfootImage("Puupy_Inactive_Right2.png"),
    new GreenfootImage("Puupy_Inactive_Right3.png"),
    new GreenfootImage("Puupy_Inactive_Right4.png"),
    new GreenfootImage("Puupy_Inactive_Right5.png"),
    new GreenfootImage("Puupy_Inactive_Right6.png"),
    new GreenfootImage("Puupy_Inactive_Right7.png"),
    new GreenfootImage("Puupy_Inactive_Right8.png"),
    new GreenfootImage("Puupy_Inactive_Right9.png"),
    new GreenfootImage("Puupy_Inactive_Right10.png"),
    new GreenfootImage("Puupy_Inactive_Right11.png")
};
  
/** Animatie Inactiv Stamga */
private final GreenfootImage[] idleLeftAnimation =
{
    new GreenfootImage("Puupy_Inactive_Left1.png"),
    new GreenfootImage("Puupy_Inactive_Left2.png"),
    new GreenfootImage("Puupy_Inactive_Left3.png"),
    new GreenfootImage("Puupy_Inactive_Left4.png"),
    new GreenfootImage("Puupy_Inactive_Left5.png"),
    new GreenfootImage("Puupy_Inactive_Left6.png"),
    new GreenfootImage("Puupy_Inactive_Left7.png"),
    new GreenfootImage("Puupy_Inactive_Left8.png"),
    new GreenfootImage("Puupy_Inactive_Left9.png"),
    new GreenfootImage("Puupy_Inactive_Left10.png"),
    new GreenfootImage("Puupy_Inactive_Left10.png")
};
  
/** Animatia curenta */
private GreenfootImage[] currentAnimation = idleRightAnimation;
    }
Super_Hippo Super_Hippo

2018/3/7

#
The 'mousePressed' method needs an object as the parameter, not a class. You can't click on a class.
LaurentiuRohan LaurentiuRohan

2018/3/8

#
danpost wrote...
I see at lines 39 and 40 that you change the code for left, but not for right.
At least solved the problem in another way. But now in Android Studio I get an error " incompatible types: Bitmap cannot be converted to BufferedImage" in these lines:
for (int i=0 ; i<numFrames ; i++) {

            GreenfootImage image = new GreenfootImage(decode.getFrame(i).getWidth(), decode.getFrame(i).getHeight());
            BufferedImage frame = image.getAwtImage();
            Graphics2D g = (Graphics2D)frame.getGraphics();
            g.drawImage(decode.getFrame(i), null, 0, 0);
            delay[i] = decode.getDelay(i);
            images[i] = image;
        }
How can I solve this?
You need to login to post a reply.
4
5
6
7