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
We need help adding a counter to our game
By MJ_lol, with 3 replies.
Last reply by RcCookie, over 2 years ago:
You should probably create a class for that. It takes the image of whatever the popup should show. To measure time, there are two main ways of doing it: - Counting frames - Calculating the time since the object was added Both ways are about the same complexity. Here's how to do it: <Code Omitted>
Making a casting animation over my idle animation
By KCee, with 3 replies.
Last reply by Spock47, over 2 years ago:
Well, I think point 4 is the most important part: The act method is called about 60 times a second. In the example code I gave, the image gets changed every 10 frames, i.e. 10/60 = 1/6 of a second. It uses the cast images. Still, it was just an example code. Additionally, you call the move method, which itself calls the idle method. This happens every frame (so 60 times a second). In this method the image Index is increased and the image changed. This happens 60 times a second. Since there are two different idle images defined for each side, it will oscillate between the two idle images (at
accessing a private boolean from a seprate actor class
By malcolm098, with 2 replies.
Last reply by Spock47, over 2 years ago:
The typical way to make it possible to check the value of a private attribute is to add a getter-method: <Code Omitted>Now, the getter-method is public, so it can be called from outside the class. And since the attribute is private, the value can only be changed within the class and therefore is safe from "corruption". If you have a reference to an object of class FoundItem, you can now check whether this item is trash:
Snake
By ronald, with 3 replies.
Last reply by ronald, over 2 years ago:
ok i just figured out some of the danpost code, the images are 20 pixels so it couldn't work with my snake so I redid my snake with the entire code of danpost I have the impression that the danpost snake is slower in movement than mine, mine moves very quickly, I have no time to turn right or left I'm wondering is it due to the size of world or the size of pixels and I don't know what offset is?? I looked on google, no more
I need help, to put a "Game over" screen or an animation that says game over in greenfoot
By MR.UWU, with 62 replies.
Last reply by Spock47, over 2 years ago:
Well, you can just add the call to recoverHealth at the end of the if-statement of catch_gas like shown in my last comment. Still, danpost's idea to center all health bar-related things into an inner class, is a good idea to keep the overview. For that, you can basically just move the complete Gasolina source code into the inner class and add the catch_gas method at the outer level:
moving to an actor without turning
By Mauckenweg, with 5 replies.
Last reply by Mauckenweg, over 2 years ago:
But i used code you wrote in another discuss so with out
you
i wouldnt have been able to do it! THANKS ;)
NewPong
By ronald, with 25 replies.
Last reply by ronald, over 2 years ago:
thank you spock47 for this code I also had the idea of a snake Anyway, I'm going to try your code and another from snake I am also working on another project I am looking for how to access from an actor class a void method of another actor class, there are several ways to achieve this I had a little trouble understanding Thanks for your help
hello I need help with this getObjectsInRange method
By bañaperras, with 28 replies.
Last reply by bañaperras, over 2 years ago:
hey thanks for the help I have already finished my game it has been a good experience in the forum I feel very comfortable in this community thank you really soon I will upload it to the forum so you can see what I learned thanks to you I hope that if someone is in need can help see you soon :)
Help with transferring actor's instance variables
By Gabe8469, with 4 replies.
Last reply by Gabe8469, over 2 years ago:
Sweet, now it's working perfectly! Thanks alot for your help!
How do I make an exe from a greenfoot scenario?
By KOTerra, with 3 replies.
Last reply by RcCookie, over 2 years ago:
I've built the project for you:
https://drive.google.com/file/d/1NEnP8RrfqYHAkIsIpcSxmSAYJHINbUUz/view?usp=sharing
life or gasoline
By elvacan, with 4 replies.
Last reply by danpost, over 2 years ago:
elvacan wrote...
if you can pass me the code
With the int field: <Code Omitted>It might look something like this: <Code Omitted>
life bar
By elvacan, with 1 reply.
Replied to by RcCookie, over 2 years ago:
There is no general solution to a problem like this. But here is some useful information: If you want to do it the object oriented way, you may create a HealthBar class: <Code Omitted> To create a visual health bar, use GreenfootImage to set the objects image. Here are some important methods:
hi
By truck_hunt97, with 1 reply.
Replied to by Spock47, over 2 years ago:
Here is a source code that slows down all enemies by one movement point for 5 seconds when You collects a SlowDownObject. The SlowDownObject is consumed in the process. <Code Omitted>
achievements
By elvacan, with 14 replies.
Last reply by danpost, over 2 years ago:
RcCookie wrote...
RcCookie wrote...
Should be:
danpost wrote...
spawning actors on top of moving actors
By tedyy, with 2 replies.
Last reply by danpost, over 2 years ago:
The error occurs because
getObjects(Shit.class)
returns a
List
object, not a specific
Actor
object, and
getX()
and
getY()
are only declared in the
Actor
class as instance methods. That is, you cannot use those methods on a
List
instance. You must first make sure that the list is not empty. Then, if not, extract a ship from the list and use the methods on it.
32
33
34
35
36
37
38
X