This site requires JavaScript, please enable it in your browser!
Greenfoot
Username
Password
Remember Me?
Sign Up, Lost Password
Activity
About
Documentation
Download
Discuss
Scenarios
Discussions
You need to login to take part
Current Discussions
Problem with a cannot find symbol error
By Volatile_Matter, with no replies.
I have an actor called "MEANBIRD", and I want that actor to point and move towards an actor called "TURDLE". There will be more than one iteration of TURDLE on the screen at a time. My code is <Code Omitted> and it returns the error "cannot find symbol - variable TURDLE". I imagine my mistake is simple, but I do not understand what my error is. I want several different birds on the screen going towards several different turtles; is it possible to do this? To have the birds going to the nearest turtle?
Menu music
By Excelsior, with 1 reply.
Replied to by danpost, over 12 years ago:
You must create a reference to the sound as a GreenfootSound object and retain it in a field, using methods of the
GreenfootSound
class to control the music.
cannot find symbol - variable Actor
By nicole1996, with 1 reply.
Replied to by danpost, over 12 years ago:
Line 102 has a semi-colon after the word 'Actor' which should not be there.
How to set up an educational Pac-Man game
By Aspire_Seven, with 7 replies.
Last reply by danpost, over 12 years ago:
My Pac-Man clone is
here
(it is called 'Pakman') and its source code is published.
Ending the game
By Tarasovych, with 8 replies.
Last reply by Tarasovych, over 12 years ago:
danpost wrote...
Make that line the first line in the 'if' block (I had edited my code post above -- take a look).
THANK YOU VERY MUCH!
Detecting the way an actor is facing
By patrick26, with 1 reply.
Replied to by danpost, over 12 years ago:
If this is in reference to your Bowser and Fireball classes, as you have it now, only the direction Bowser is facing can be determined; and only by which image it currently is using. It would be a lot easier if your 'left-facing' images were just upside-down 'right facing' images (in both classes). Then rotating 180 and switching images would give the proper image and movement both. Without using upside-down right-facing images, I do not see much help for the Fireball class with your SPEED field being static. If more than one fireball can be in the world at one time, then the 'static'
Help with Shooting
By patrick26, with 3 replies.
Last reply by danpost, over 12 years ago:
It would do good to have fields in both of these classes to track the horizontal direction of movement of these actors. 'setRotation(360)' is equivalent to 'setRotation(0)' -- therefore, all four of your 'setRotation statements in the 'act' method of Bowser can be removed.
Possible loss of precision
By Pointifix, with 2 replies.
Last reply by Pointifix, over 12 years ago:
ah ok thanks
Movement Troubles
By hugtvy, with 8 replies.
Last reply by hugtvy, over 12 years ago:
cheers that worked
Help me with game, please!
By Tarasovych, with 7 replies.
Last reply by danpost, over 12 years ago:
hugtvy wrote...
and then somehow make another counter to actually project it so bumpcounter(-50) instead of 1 but im not entirely sure
You do not need another counter. To project the score, use can use <Code Omitted>The first way will project zero when the bumpCounter reaches 49. The second way will project zero when the bumpCounter reaches 0.
Adding an object back to the world after it is removed
By patrick26, with 1 reply.
Replied to by davmac, over 12 years ago:
Yes, this is trivial. You just need to retain a reference to the object (eg. in a variable) and then use the standard addObject(...) method to add it back to the world. You can do it from a world or actor class (if from an actor, you use getWorld().addObject(...), of course). <Code Omitted>
Shooting problems
By patrick26, with no replies.
Hi, My actor Bowser is unable to shoot a fireball in the direction it is facing. Does anyone know how to do this? Please note that the image 'fireball1.png' is facing right and I have another image called 'fireball2.png' facing left. Here is my Bowser code: import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class Fireball here. * * @author (your name) * @version (a version number or a date) */ public class Fireball extends Actor { private static final int SPEED=10; /** * Act - do whatever the Fireball wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() {move(SPEED); if(getX()>getWorld().getWidth()-3) { getWorld().removeObject(this); } else { Actor kingboo = getOneIntersectingObject(Kingboo.class); if(kingboo !=null) { getWorld().addObject(new Explosion(),getX(),getY()); getWorld().removeObject(kingboo); getWorld().removeObject(this); } } } public Fireball() { setImage("fireball1.png"); } } Here is my Fireball code: import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class Fireball here. * * @author (your name) * @version (a version number or a date) */ public class Fireball extends Actor { private static final int SPEED=10; /** * Act - do whatever the Fireball wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() {move(SPEED); if(getX()>getWorld().getWidth()-3) { getWorld().removeObject(this); } else { Actor kingboo = getOneIntersectingObject(Kingboo.class); if(kingboo !=null) { getWorld().addObject(new Explosion(),getX(),getY()); getWorld().removeObject(kingboo); getWorld().removeObject(this); } } } public Fireball() { setImage("fireball1.png"); } }
Help with counter system
By patrick26, with 4 replies.
Last reply by patrick26, over 12 years ago:
It worked! Thank you so much! :)
Using getObjectsAtOffset to check for other objects in front or behind
By blorange2, with 3 replies.
Last reply by danpost, over 12 years ago:
Using getObjectsAtOffset is out of the question. If your actor can be facing any direction, the horizontal axis and vertical axis will not align with the direction the actor is looking and the offsets used in the method will not (unless the rotation of your actor happens to be zero) refer to the same location that you want to look at. There are two ways I can immediately think to do this: (1) have your actor personally inspect the area ahead <Code Omitted>If you have some actors that
counter help
By hugtvy, with 25 replies.
Last reply by danpost, over 12 years ago:
hugtvy wrote...
that worked, haha thank you soo much, youve helped my game come a long way! dont think i have any other issues but if I do should i contact you on here or make a new discussion?
If this issue is resolved, then another discussion thread would be more appropriate for other issues.
717
718
719
720
721
722
723
X