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
Playing a sound when a key is pressed, then stopping it when the key is released?
By trulydevious, with 1 reply.
Replied to by danpost, about 15 hours ago:
trulydevious wrote...
I want to play a sound when my player is walking, this is the code I have for the checkMovement method. How do I make it to where the walking sound plays when I press w or a or s or d and then stops when I release the keys? << Code Omitted >>
Line 10 needs to outside the block (in the class itself, not in a method or constructor). I prefer the following to begin 4-way movement by key press:
Stuck in: "The world is being constructed"
By youngdisciple07, with no replies.
Hey, I have been stuck with a screen saying that the world is being constructed... I tried closing the program and reopening it and restarting my pc but to no avail... Here is my Background class: <Code Omitted> here is my counter class: <Code Omitted> here is my RecruitSkellyButton: import lang.stride.*; import java.util.*; import greenfoot.*; /** * */ public class RecruitSkellyButton extends Buttons { GreenfootImage button = new GreenfootImage("RecruitSkellyButton1.png"); GreenfootImage buttonHighlighted = new GreenfootImage("RecruitSkellyButton1Highlighted.png"); GreenfootImage buttonGrayed = new GreenfootImage("RecruitSkellyButton1BlackandWhite.png"); private Counter counter; public RecruitSkellyButton(Counter counter){ this.counter = counter; button.scale(150,109); buttonHighlighted.scale(150,109); buttonGrayed.scale(150,109); setImage(button); } /** * Act - do whatever the Option1_Button wants to do. This method is called whenever the 'Act' or 'Run' button gets pressed in the environment. PLACEHOLDER FOR RECRUIT SKELLY BUTTON */ public void act() { Background world = (Background) getWorld(); Counter counter = world.getCounter(); if (counter.getValue() < 5) { //check if the counter has enough gold setImage(buttonGrayed); } else if (counter.getValue() >= 5) { RecruitSkelly skelly1 = new RecruitSkelly(); setImage(button); if (Greenfoot.mouseMoved(this)) { setImage(buttonHighlighted); } if (Greenfoot.mouseClicked(this)) { Arrow arrow1 = new Arrow(); getWorld().addObject(arrow1, 163, 277); Arrow arrow2 = new Arrow(); getWorld().addObject(arrow2, 163, 125); } } } } Note: I get greeted with this terminal message whenever I open greenfoot: 2024-11-18 20:55:35.543 java +: chose IMKClient_Legacy 2024-11-18 20:55:35.544 java +: chose IMKInputSession_LegacyException in thread "AWT-EventQueue-0" java.lang.NegativeArraySizeException: -4 Any help would be appreciated!!
Return to the previous world, but in the same spot as they were in before they entered the current world?
By trulydevious, with 2 replies.
Last reply by trulydevious, 1 day ago:
Thank you! I ended up figuring it out!
Remove isnt working
By Vince361, with 1 reply.
Replied to by danpost, 6 days ago:
Vince361 wrote...
For some Reason instead of the Feuerball(Fireball) being removed, when hitting something a window opens itself with error codes because the code couldnt be carried out eventhough the return should stop the code from continuing. << Code Omitted >>
A
Feuerball
instance will only act when in the world. So,, it seems pointless for the first action taken to be asking if any of those instances are in the world (of course, the one acting is in the world). It would be much better to have objects it may hit to detect this object instead of the other way around. Tha
Why was greenfoot.export.GreenfootScenarioApplication deprecated?
By Trivaris, with no replies.
And now that it is, is there any other way to program in another IDE?
Could someone tell me where the mistake is?
By Shuotso, with 1 reply.
Replied to by Super_Hippo, 11 days ago:
I guess this code is in an Actor subclass. To add an object to the world, you need to call the addObject method on the world the actor is in. <Code Omitted>
Making an action happen when an actor lands on another actor's specific string?
By trulydevious, with 2 replies.
Last reply by trulydevious, 14 days ago:
Ohhh thank you that makes a lot of sense
Fixing text displaying + Players duplicating when moved
By trulydevious, with 2 replies.
Last reply by trulydevious, 16 days ago:
Thank you so much!
Microphone Permissions on Macbook
By mtranchida, with 3 replies.
Last reply by nccb, 17 days ago:
Just to let you know we've now found a solution. I've just swapped out the installers for the new 3.9.0 release on the download page with a version that should correctly request microphone permissions on Mac when you use the Sound Recorder.
How to make smoother movement in characters?
By Wolfy5039, with 8 replies.
Last reply by danpost, 19 days ago:
danpost wrote...
Simple fix: << Code Omitted >>
Sorry ... not quite so simple. The timer for respawning cannot be in the class of the instance for the actor removed from the world. It's
act
method will not be called to count the timer down. Since you will only ever have one instance of that actor at any one time, you can have the world run a respawn timer: (in CrabWorld)
Accessing a variable through another class.
By skitz00__, with 4 replies.
Last reply by danpost, 24 days ago:
Would it not be easier to have the
Cactus
class objects look for the
Bullet
class objects and control their own destiny? Here is an example class with a delay timer (a temporary immunity from taking hits for about one second)
Creating a board game like path?
By trulydevious, with 1 reply.
Replied to by danpost, 27 days ago:
trulydevious wrote...
For an assignment, I am trying to create a Candyland type game. I am trying to make the path but can't seem to get it right. I dont want a wavy path, just a basic path that allows players to land on it.
One idea is to have invisible "landing" pads for where a player CAN move a piece at that time. When a piece is dragged and released, if on a pad, it is accepted, else it snaps back to its starting place.
How do I find if a certain class is located at a certain location?
By nubnt_, with 1 reply.
Replied to by danpost, 29 days ago:
nubnt_ wrote...
How do I find if a certain class is located at a certain location?
From within your subclass of
World
, you can use the
getObjectsAt(int x, int y, Class clss)
method. This will return a list of actors of given type at that location. If you don't need the actor itself, just checking if the list is empty is enough: <Code Omitted>otherwise:
Help: Why can't I just get the X position of the mouse
By nubnt_, with 2 replies.
Last reply by nubnt_, 29 days ago:
Thanks. (sorry for the late reply)
Objects Generating In front of Existing Objects
By Gael, with 2 replies.
Last reply by Gael, 29 days ago:
Thank you very much! it worked great and had a better effect than I thought
1
2
3
4
X