Questions tagged [greenfoot]

Greenfoot is an environment that makes it very easy to create 2D animations and games using Java.

Greenfoot is designed for beginners and makes it easy for people who have never programmed before to create games and animations without worrying about dealing with any complexities such as threading, double buffering or swing.

After scenarios have been created they can easily be shared by using the Greenfoot Gallery.

Links:

Main site (download Greenfoot here)

Greenfoot Gallery (users scenarios are published here)

Greenroom (only open to teachers)

128 questions
1
vote
1 answer

Java remove objects

I have a world that is the GameScreen (20ish objects) which lays all objects as intended. However, when I get GameOver I want to be a blank canvas with just the background and some new objects(a couple objects), but all the existing objects from…
Ryan W
  • 39
  • 6
1
vote
0 answers

Using a String to Instantiate an object in Greenfoot?

So, as part of my college coursework we are working in teams to develop simplistic games in Greenfoot, partly to develop on teamwork skills, and partly for actual programming. Our game features a perlin/simplex generated map to render tessellated…
1
vote
1 answer

Greenfoot: Jumping and coming back down doesn't work

The player jumps but doesn't come back down, and if you hold the up arrow key, the player flies/floats, how can I fix this so the player falls back down? it would be good if source code is provided, but any help is great. import greenfoot.*;…
1
vote
2 answers

Cannot find symbol - method scroll()

I am working on a simple Mario side-scroller, and When I try to call the Scrolling objects' scroll() method, I get the Cannot find symbol - method scroll() error thrown. Please help! Here is the Subworld file import greenfoot.*; import…
Danlboon
  • 23
  • 4
1
vote
1 answer

Greenfoot Counter minus one

Hi i'm trying to decrease the counter with 1 in the public void minScore score++ adds the counter with 1 what is the equivalent to decrease the counter with 1 ? public class Counter extends Actor { private int score = 0; public void act() …
R.m
  • 19
  • 6
1
vote
1 answer

Greenfoot Actor not in World error

When my enemy gets to the bottom of the screen I want to remove and if the enemy gets hit by bullets i want to remove it. The error is : java.lang.IllegalStateException: Actor not in world. An attempt was made to use the actor's location while it is…
blembo
  • 117
  • 8
1
vote
1 answer

filename being a variable

I'm trying to make a variable as a filename. I want a generic command that when inherited by a subclass can then set a filename as the variable. The code compiles just fun but when I run it and I press the d or a key to move the avatar I get a…
power5000
  • 25
  • 1
  • 9
1
vote
1 answer

Java: Index out of bounds

I'm programming in Greenfoot for a school project and I keep getting this error: java.lang.IndexOutOfBoundsException: Index: 1, Size: 1 at java.util.ArrayList.rangeCheck(ArrayList.java:635) at java.util.ArrayList.get(ArrayList.java:411) at…
user4555460
1
vote
1 answer

Acces class methods from classes out of a list

Is it possible to access a getter from a class out of a List of classes? See my code: List words = getWorld().getObjects(Word.class); for (Object word : words) { if (word.getWord() == inputText) { System.out.println("Test"); …
wderoode
  • 63
  • 1
  • 5
1
vote
2 answers

Object wont detect edge of world in greenfoot

This is a greenfoot project I'm working on. It is supposed to make the object bounce when it nears the edge I was hoping someone would realize why this isn't working, it just falls from the top import greenfoot.*; // (World, Actor,…
Eric Och
  • 11
  • 1
1
vote
1 answer

Greenfoot: java.lang.ClassCastException: Obstacle cannot be cast to BallProjectile

Alright, so I get this error when I try to make it so that when BallProjectile collides with an obstacle, the ball stops and makes a new one. // Checks if the ball is colliding with an obstace, then stops it if it is BallProjectile…
Jack
  • 15
  • 7
1
vote
1 answer

How to Use an Instance from One Class in Another Class: Greenfoot

I'm using Greenfoot at the moment, learning Java. I'm very noobish when it comes to static/non-static, and I'm iffy on instances also. In Greenfoot, I have a world class, let's call it World. Now I have another class, named Car and one subclass,…
Zbrezi
  • 23
  • 5
1
vote
1 answer

compare user input with a string

I'm new at Java, I'm writing this simple program in Greenfoot. If I write "h" the program says "same", now after that I want to write "i" and get "same" too, basically I want to ignore "h" after I get "same" for it. I'm not sure how this is done. …
user2828007
1
vote
1 answer

How to delete lines in Greenfoot?

I drew lines by using the method drawLine(),now I want to delete the lines,how can I do? I can't find any methods in Greenfoot API.PLEASE HELP! import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) import…
user2002948
  • 63
  • 1
  • 1
  • 4
1
vote
1 answer

Greenfoot - mouse click and an object removes

new to Java here but i have been experimenting... I am trying to achieve this in Greenfoot: I want to have a mouse click on an object (Actor) and it disappears from the world. This is my code so far: public void act() { disappear(); …
jonprasetyo
  • 3,356
  • 3
  • 32
  • 48
1
2
3
8 9