Greenfoot actor10/30/2022 Protected Actor getOneIntersectingObject( cls) Return an object that intersects this object. Parameters: r - Radius of the cirle (in pixels) cls - Class of objects to look for (passing 'null' will find all objects). Object's centre is less than or equal to r. cls) Return all objects within range 'r' around this object.Īn object is within range if the distance between its centre and this Returns: List of objects at the given offset. cls - Class of objects to look for (passing 'null' will find all dy - y-coordinate relative to this objects location. Parameters: dx - X-coordinate relative to this objects location. cls) Return all objects that intersect the given location (relative to this diagonal - If true, include diagonal steps. Parameters: distance - Distance (in cells) in which to look for other objects. Inspect four cells, (1,true) will inspect eight cells. Thus, a distance/diagonal specification of (1,false) will Steps may be only in the four mainĭirections, or may include diagonal steps, depending on the 'diagonal' Thus, it is most useful in scenarios where objects are contained in aĪll cells that can be reached in the number of steps given in 'distance'įrom this object are considered. Method considers only logical location, ignoring extent of the image. cls) Return the neighbours to this object within a given distance. Parameters: cls - Class of objects to look for (passing 'null' will find all objects). NOTE: Does not take rotation into consideration. Graphical extent of objects into consideration. Protected getIntersectingObjects( cls) Return all the objects that intersect this object. Modified to change the object's appearance. Public greenfoot.GreenfootImage getImage() Returns the image used to represent this Actor. Throws: - If there is no world instantiated. Returns: The height of the object, or -1 if it has no image. That an object's image overlaps vertically. Public int getHeight() Return the height of the object. Parameters: world - The world the object was added to. This method can be overridden to implementĬustom behavoiur when the actor is inserted into the world. Protected void addedToWorld(greenfoot.World world) This method will be called by the Greenfoot system when the object hasīeen inserted into the world. At each action step in the environment,Įach object's act method is invoked, in unspecified order. Public void act() The act method is called by the greenfoot framework to give objects aĬhance to perform some action. Methods inherited from class Ĭlone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait Set an image for this object from an image file. Set the image for this object to the specified image. Return the y-coordinate of the object's current location.Ĭheck whether this object intersects with another given object. Return the x-coordinate of the object's current location. Return the world that this object lives in. Return the current rotation of the object. Return one object that is located at the specified cell (relative to this Return an object that intersects this object. Return all objects within range 'r' around this object. Return all objects that intersect the given location (relative to this Return the neighbours to this object within a given distance. Return all the objects that intersect this object. Returns the image used to represent this Actor. This method will be called by the Greenfoot system when the object has The act method is called by the greenfoot framework to give objects a The method here is empty, and subclasses normally provide their own implementations. Is called when the 'Act' or 'Play' buttons are activated in the Greenfoot interface. One of the most important aspects of this class is the 'act' method. SetLocation(getX(), getY()-(int)(Greenfoot.Public abstract class Actor extends Īn Actor is an object that exists in the Greenfoot world.Įvery Actor has a location in the world, and an appearance (that is:Īn Actor is not normally instantiated, but instead used as a superclass SetLocation(getX(), getY()+(int)(Greenfoot.getRandomNumber(25)+acceleration)) checks if it is near the bottom of the world (Y is reversed so at the top of the world Y is high) If(getY()>(getWorld().getHeight())-50 & direction= true ) * the 'Act' or 'Run' button gets pressed in the environment.īoolean direction=true //assigns the fall direction (true is down false is up) * Act - do whatever the Asteroid wants to do. I was hoping someone would realize why this isn't working, it just falls from the top import greenfoot.* // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) It is supposed to make the object bounce when it nears the edge This is a greenfoot project I'm working on.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |