java.lang.Objectgreenfoot.Actor
ThreadActor
public abstract class ThreadActor
class of Threadfoot
Counterpart of Greenfoot-class Actor. Working with Threadfoot you should use always this class instead of class Actor.
Remark 1: If you override the method "addedToWorld" in a derived class you have to call the ThreadActor-method "addedToWorld" within that method!
Constructor Summary | |
---|---|
ThreadActor()
Creates a ThreadActor-Object with an internal Thread-Object |
Method Summary | |
---|---|
void |
act()
meaningless in Threadfoot |
protected void |
addedToWorld(greenfoot.World world)
This method is called by the Greenfoot system when the object has been inserted into the world. |
greenfoot.GreenfootImage |
getImage()
Returns the image used to represent this Actor. |
protected java.util.List |
getIntersectingObjects(java.lang.Class cls)
Return all the objects that intersect this object. |
protected java.util.List |
getNeighbours(int distance,
boolean diagonal,
java.lang.Class cls)
Return the neighbours to this object within a given distance. |
protected java.util.List |
getObjectsAtOffset(int dx,
int dy,
java.lang.Class cls)
Return all objects that intersect the given location (relative to this object's location). |
protected java.util.List |
getObjectsInRange(int radius,
java.lang.Class cls)
Return all objects within range 'radius' around this object. |
protected greenfoot.Actor |
getOneIntersectingObject(java.lang.Class cls)
Return an object that intersects this object. |
protected greenfoot.Actor |
getOneObjectAtOffset(int dx,
int dy,
java.lang.Class cls)
Return one object that is located at the specified cell (relative to this objects location). |
int |
getRotation()
Return the current rotation of the object. |
java.lang.Thread |
getThread()
Return the internal Thread-Object |
greenfoot.World |
getWorld()
Return the world that this object lives in. |
int |
getX()
Return the x-coordinate of the object's current location. |
int |
getY()
Return the y-coordinate of the object's current location. |
protected boolean |
intersects(greenfoot.Actor other)
Check whether this object intersects with another given object. |
void |
run()
This method does nothing. |
void |
setImage(greenfoot.GreenfootImage image)
Set the image for this object to the specified image. |
void |
setImage(java.lang.String filename)
Set an image for this object from an image file. |
void |
setLocation(int x,
int y)
Assign a new location for this object. |
void |
setRotation(int rotation)
Set the rotation of the object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ThreadActor()
Method Detail |
---|
public final void act()
act
in class greenfoot.Actor
Actor.act()
protected void addedToWorld(greenfoot.World world)
If you override this method in a derived class you have to call this method within that method!
addedToWorld
in class greenfoot.Actor
world
- The world the object was added to.public greenfoot.GreenfootImage getImage()
getImage
in class greenfoot.Actor
protected java.util.List getIntersectingObjects(java.lang.Class cls)
getIntersectingObjects
in class greenfoot.Actor
cls
- Class of objects to look for (passing 'null' will find all
objects).protected java.util.List getNeighbours(int distance, boolean diagonal, java.lang.Class cls)
All cells that can be reached in the number of steps given in 'distance' from this object are considered. Steps may be only in the four main directions, or may include diagonal steps, depending on the 'diagonal' parameter. Thus, a distance/diagonal specification of (1,false) will inspect four cells, (1,true) will inspect eight cells.
getNeighbours
in class greenfoot.Actor
distance
- Distance (in cells) in which to look for other objects.diagonal
- If true, include diagonal steps.cls
- Class of objects to look for (passing 'null' will find all
objects).
protected java.util.List getObjectsAtOffset(int dx, int dy, java.lang.Class cls)
getObjectsAtOffset
in class greenfoot.Actor
dx
- X-coordinate relative to this objects location.dy
- y-coordinate relative to this objects location.cls
- Class of objects to look for (passing 'null' will find all
objects).
protected java.util.List getObjectsInRange(int radius, java.lang.Class cls)
getObjectsInRange
in class greenfoot.Actor
radius
- Radius of the circle (in cells)cls
- Class of objects to look for (passing 'null' will find all
objects).protected greenfoot.Actor getOneIntersectingObject(java.lang.Class cls)
getOneIntersectingObject
in class greenfoot.Actor
cls
- Class of objects to look for (passing 'null' will find all
objects).protected greenfoot.Actor getOneObjectAtOffset(int dx, int dy, java.lang.Class cls)
getOneObjectAtOffset
in class greenfoot.Actor
dx
- X-coordinate relative to this objects location.dy
- y-coordinate relative to this objects location.cls
- Class of objects to look for (passing 'null' will find all
objects).
public int getRotation()
getRotation
in class greenfoot.Actor
setRotation(int)
public java.lang.Thread getThread()
public greenfoot.World getWorld()
getWorld
in class greenfoot.Actor
public int getX() throws java.lang.IllegalStateException
getX
in class greenfoot.Actor
java.lang.IllegalStateException
- If the actor has not been added into a world.public int getY()
getY
in class greenfoot.Actor
java.lang.IllegalStateException
- If the actor has not been added into a world.protected boolean intersects(greenfoot.Actor other)
intersects
in class greenfoot.Actor
public void run()
run
in interface java.lang.Runnable
public void setImage(greenfoot.GreenfootImage image)
setImage
in class greenfoot.Actor
image
- The image.setImage(String)
public void setImage(java.lang.String filename) throws java.lang.IllegalArgumentException
setImage
in class greenfoot.Actor
filename
- The name of the image file.
java.lang.IllegalArgumentException
- If the image can not be loaded.public void setLocation(int x, int y)
setLocation
in class greenfoot.Actor
x
- Location index on the x-axisy
- Location index on the y-axis
java.lang.IllegalStateException
- If the actor has not been added into a world.public void setRotation(int rotation)
setRotation
in class greenfoot.Actor
rotation
- The rotation in degrees.