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
Bug in setRotation method?
By stevetone, with 3 replies.
Last reply by danpost, almost 12 years ago:
stevetone wrote...
Is there an alternative method that I should be using to move in a more precise manner? It's not
that
important, as I am just bouncing ball objects off the world edge, but it would be nice to know if there is a more advanced technique to be learned.
There are several helper classes to produce smoother and more precise appearing movement. I have a QActor class in my
Asteroids w/improved QActor SuperClass
scenario. Plus there are other around.
save and load
By wc0708, with 7 replies.
Last reply by danpost, almost 12 years ago:
Since it appears you only have one object on any one location at a time, it would be easier to use one string where the position in the string determines the position in the grid. Then, you only need use one character to represent the type of object and the space character for an empty location to build the string (I used the last character in the name of the actor type since they were all different).
Lever to change movement speed
By Favna, with 2 replies.
Last reply by Favna, almost 12 years ago:
Works perfectly, thanks :)
Timer/Clock for a game
By ortizme93, with 8 replies.
Last reply by danpost, almost 12 years ago:
I found a couple of mistakes in my previous post. (1) line 4 for the button example should be: <Code Omitted>(2) at the end, I had referred to the first 7 lines of the button class -- well that would more correctly be 7 of the first 8 lines (all but line 7).
Help with assign a specific name
By SilentPenguin, with 3 replies.
Last reply by danpost, almost 12 years ago:
First off, you would not use the type when referring to a variable that is already declared. So this: <Code Omitted>would not have 'String' in it and you would need round brackets around the condition. So it would be this: <Code Omitted>However, there is no 'isalnum' method in the String class (or any method to check the general type of data stored within the string). All strings could be considered as being alpha-numeric strings; so the question itself is almost not worth asking. What might be important is wheth
How to make an actor move relative to the result of a dice
By SilentPenguin, with 3 replies.
Last reply by danpost, almost 12 years ago:
Line 15 in the roll method above will set the 'randNumber' variable to a number between 1 and 4 and line 17 sends that same value back to the calling statement (which is the last line of actual code within that post -- line 8 of the world class code, where it is saved in a variable called 'rollValue'). At that point you can use 'move(rollValue)' on the player to move. But you will need an array for the players in the game and an int field to track which one has the turn. For example:
Please Help Me. I don't really know what to do. -_-
By Anne2403, with 8 replies.
Last reply by Anne2403, almost 12 years ago:
@davmac hehe. I'm sorry about it. and thank you I will do what you said. I will take your advice. Sorry for the disturbance and also with @danpost aand @Erdrag1. Thank you and sorry again brothers.
Need help with Color detection and Offsets.
By Zwadouggie, with 3 replies.
Last reply by danpost, almost 12 years ago:
Zwadouggie wrote...
How does the declaring list work if you mind showing me an example.
It would be much easier to have the barriers set their own transparency dependent on a static field in your World subclass. If you would prefer to use a list to set the transparencies of all walls of a specific color, it would be a two part process. The steps would include: * get and iterate through a list of all Wall objects in the world while iterating through the list * if wall is color and wall transparency is zero, set wall transparency to 255 * if wall is not color and wall transparency i
Actor interacts with the edge of the world
By jnlrsl, with 2 replies.
Last reply by danpost, almost 12 years ago:
Change what you said to present tense, at the exact instant in time that is in question. That is, instead of saying, "When my character reaches the right edge, I want to switch worlds!" -- say "If my character is at the right edge, switch worlds (to whatever world).". Or, more specifically, "If the x-location of my character is equal to the right-most x-coordinate in the world, set the active world to a new world." This reads almost the way you would write the code.
Actor stops halfway at the edge of the world
By akshay1188, with 3 replies.
Last reply by akshay1188, almost 12 years ago:
Beautiful! Thank you Jonas. Dan, I will make sure to keep a check on all my actors that go off the edge of the world. Thank you so much.
Randomly drop crate code isn't working?
By Fuzzion, with 4 replies.
Last reply by danpost, almost 12 years ago:
It appears there are a couple of things that were not made clear by JimStewart in the comments. First, nowhere does he suggest that you add the MoveRandomly object into the world (however, later in the class he does say to uncomment some code to actual see the actor). The class indeed does extends Actor; however, in truth, it really is not an actor in itself and should probably not extend Actor. The other thing is that it is not stated that the MoveRandomly object that your actor creates should be held in an instance field. This is made evident, however, in the section where the method 'mo
Actor inside actor?
By akshay1188, with 2 replies.
Last reply by akshay1188, almost 12 years ago:
Thank you!
List add object exception?
By Dalvengyr, with 5 replies.
Last reply by Dalvengyr, almost 12 years ago:
Thanks guys for your help, it works correctly now :)
how to move in the facing direction
By nmichael221, with 3 replies.
Last reply by danpost, almost 12 years ago:
nmichael221 wrote...
yes, he turns left and he faces left. But after I stop pressing the left key he is facing left and moving right.
That did not answer my question. Nowhere was there an option to answer that he 'turns'. I ask whether the rotation of the actor changes or does the image of the actor change when it changes the direction it faces. Also, you should post the code you currently have for the actor. Use the 'code' link below the reply box to insert code into you posts.
Do i understand it right?
By Erdrag1, with 7 replies.
Last reply by danpost, almost 12 years ago:
I thought you wanted to add lettuce if no lettuce as left in the world. However, if you only have one lettuce in the world then at the time it is eaten, there will be none. So, either way, still. That is, in the "extends Actor", you can either call the method to add lettuce in the 'ifcansee' method OR you can still use separate from the 'ifcansee' method 'if (getWorld().getObjects(Lettuce.class).isEmpty())' to qualify when to call the 'createNewLettuce' method.
632
633
634
635
636
637
638
X