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

2013/12/9

How to resize Actor

Lautima Lautima

2013/12/9

#
I am new to greenfoot and my actors: Bee1 is a bit too big, How do I get the actor to scale down? import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class Bee2 here. * * @author (your name) * @version (a version number or a date) */ public class Bee2 extends Actor { /** * Act - do whatever the Bee2 wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { // Add your action code here. } } Can you please show me where you would add the code and where I can change the coordinates. Thank you so much, I have been stuck on this for hours
Lautima Lautima

2013/12/9

#
I am getting an <identifier>expected ... help import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class Bee2 here. * * @author (your name) * @version (a version number or a date) */ public class Bee2 extends Actor { /** * Act - do whatever the Bee2 wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public class Bee2 extends Actor { public Bee2(); GreenfootImage image = getImage(); image.scale(30, 30); <---------------------------------- There is a problem here it shows right after the e in scale setImage(image); }
danpost danpost

2013/12/9

#
You have a semi-colon immediately after your constructor declaration statement public Bee2(); Change the semi-colon to an open curly bracket to show where the code for the constructor starts. Then, make sure you have matching brackets throughout the class.
Lautima Lautima

2013/12/9

#
Thanks I got past that part now I have another problem popping up. It says " class Bee2 is already defined in package unnamed package" on this line Public class Bee2 extends actor import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class Bee2 here. * * @author (your name) * @version (a version number or a date) */ public class Bee2 extends Actor { /** * Act - do whatever the Bee2 wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public class Bee2 extends Actor <---------- { public Bee2(){ GreenfootImage image = getImage(); image.scale(30, 30); setImage(image); } }}
Lautima Lautima

2013/12/9

#
I figured the problem out but it now says I have a duplicate class: Bee2 the error is in the same area.
Lautima Lautima

2013/12/9

#
Can I get someone to please just implement it into my code and explain what they did after?
danpost danpost

2013/12/9

#
Your class should look like this:
import greenfoot.*;

public class Bee2 extends Actor
{
    public Bee2()
    {    
        GreenfootImage image = getImage();  
        image.scale(30, 30);
        setImage(image);
    }
}
All I did was removed the one duplicate line that was throwing the compiler and adjusted the bracketing.
You need to login to post a reply.