An object is created from a class by use of the 'new' keyword placed before the class name which is then followed by a set of parenthesis (round brackets). When needed, set its location, rotation and length and have it move a distance of half its length then call a method of the line-of-sight class to get any information required (like number of intersectors - if only 2, the targeting and the targeted, then the line of sight is clear). You can create multiple Correct objects from the class. As far as a line-of-sight actor, have each actor of the class create its own line-of-sight actor for it to use. The state of the Lifebar object being in the world or not can be used, in part, to determine if it may need removed or added. Correct is the name of a class which describes an object it is a Class object, not a Correct object. The world can also maintain a field for a single Lifebar object whose image can be adjusted as needed. This means having a field to hold the Monsters object the mouse was last on. (World, Actor, GreenfootImage, and Greenfoot) import import java.awt. I am trying to make it when I pick up a Goldasteroid the score will add up 5 and if I destroy an Alienship the score will add 10 points here is what I have: ScoreBoard: import greenfoot. So, knowing which Monsters object the mouse was last on would be helpful on subsequent act cycles. I need help on trying to get my score counter to work I have looked at many other forums for this and still nothing. Next, there would also be no change if the mouse moved but also remained over the same Monsters object. Another thing is that no checking needs to be done unless the mouse actually move on that act cycle (if no change in mouse position, there would be no change in the existence of the Lifebar obect). Therefore, it is better to place the main code for controlling the Lifebar object(s) in the world class where you can check all monsters at one time instead of each one individually. For one thing, each Monsters object in the world will execute the act method given each act cycle - meaning that only the last Monsters object acted on will determine whether a Lifebar object remains in the world or not (with your code as given). Syntax: addObject(greenfoot.Actor object, int x, int. Instead of dealing with all the issues that currently exist, I think it best to try to explain some basics. To automatically create an Actor method in the world when your World class is initialized use this method. You have several issues with the codes given (some of which could not be verified until the code for the act method was given). But this will only work if you only got one instance of this object in your world, because static variables have got the same value for all instances of the object. Vellyxenya wrote.and all my methods are public, should I name them static?Absolutely not - at least not as is. Then you can excess this value like you are trying to do.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |