es.ucm.look.data
Class WorldEntity

java.lang.Object
  extended by es.ucm.look.data.WorldEntity
All Implemented Interfaces:
Drawable2D, Drawable3D

public class WorldEntity
extends java.lang.Object
implements Drawable2D, Drawable3D

A world entity


Constructor Summary
WorldEntity(EntityData data)
           
 
Method Summary
 void addCameraListener(CameraListener c)
          Adds a camera listener to this entity, and makes this entity focusable
 void addTouchListener(TouchListener t)
          Adds a touch listener to this entity, and makes this entity touchable
 void cameraEntered()
          Camera pointed to this entity
 void cameraExited()
          Camera pointed to this entity
 void draw(Canvas c)
          Draws the element in the canvas
 void draw(GL10 gl)
          Draws the element in the canvas
 void drawTouchableArea(Canvas c, Paint p)
          Fills the touchable zone for the drawable only with the the given Paint.
 boolean equals(java.lang.Object o)
           
 EntityData getData()
          Returns entity's data
 Drawable2D getDrawable2D()
           
 Drawable3D getDrawable3D()
           
 int getId()
          Returns the entity's id
 Point3 getLocation()
          Returns the entity's position
 float getRadius()
          Returns the entity's radius
 java.lang.String getType()
          Returns entity's type
 void init2D()
          Initializes 2D appearance.
 void init3D()
          Initializes 3D appearance.
 boolean isEnable()
           
 boolean isFocusable()
          Return whether this entity is focusable
 boolean isTouchable()
           
 boolean isVisible()
           
 void setDrawable2D(Drawable2D drawable2d)
           
 void setDrawable3D(Drawable3D drawable3d)
           
 void setEnable(boolean enable)
          Sets if this entity is enabled to receive events
 void setFocusable(boolean focusable)
          Sets if this entity is focusable
 void setRadius(float radius)
           
 void setTouchable(boolean touchable)
          Sets if this entity is touchable.
 void setVisible(boolean visible)
          Sets if this entity is visible
 boolean touch(MotionEvent event)
          Entity receives a touch event
 void update(long elapsed)
          Updates the drawable
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WorldEntity

public WorldEntity(EntityData data)
Method Detail

addCameraListener

public void addCameraListener(CameraListener c)
Adds a camera listener to this entity, and makes this entity focusable

Parameters:
c - the camera listener

addTouchListener

public void addTouchListener(TouchListener t)
Adds a touch listener to this entity, and makes this entity touchable

Parameters:
t - the touch listener

cameraEntered

public void cameraEntered()
Camera pointed to this entity


cameraExited

public void cameraExited()
Camera pointed to this entity


draw

public void draw(Canvas c)
Description copied from interface: Drawable2D
Draws the element in the canvas

Specified by:
draw in interface Drawable2D
Specified by:
draw in interface Drawable3D
Parameters:
c - the canvas

draw

public void draw(GL10 gl)
Description copied from interface: Drawable2D
Draws the element in the canvas

Specified by:
draw in interface Drawable2D
Specified by:
draw in interface Drawable3D
Parameters:
gl - the canvas

drawTouchableArea

public void drawTouchableArea(Canvas c,
                              Paint p)
Description copied from interface: Drawable2D
Fills the touchable zone for the drawable only with the the given Paint. This method is used processing screen touches. It can be empty if drawable is not receiving touch events

Specified by:
drawTouchableArea in interface Drawable2D
Parameters:
c - the canvas
p - the paint

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

getData

public EntityData getData()
Returns entity's data

Returns:

getDrawable2D

public Drawable2D getDrawable2D()
Returns:
the drawable2D

getDrawable3D

public Drawable3D getDrawable3D()
Returns:
the drawable3D

getId

public int getId()
Returns the entity's id

Returns:
the id

getLocation

public Point3 getLocation()
Returns the entity's position

Returns:

getRadius

public float getRadius()
Returns the entity's radius

Returns:
the entity's radius

getType

public java.lang.String getType()
Returns entity's type

Returns:

init2D

public void init2D()
Initializes 2D appearance. Must be overridden for inheriting classes


init3D

public void init3D()
Initializes 3D appearance. Must be overridden for inheriting classes


isEnable

public boolean isEnable()
Returns:
If this entity is enabled to receive events

isFocusable

public boolean isFocusable()
Return whether this entity is focusable

Returns:
if this entity is focusable

isTouchable

public boolean isTouchable()
Returns:
if this entity is touchable

isVisible

public boolean isVisible()
Returns:
If this entity is visible

setDrawable2D

public void setDrawable2D(Drawable2D drawable2d)
Parameters:
drawable2d - the drawable2D to set

setDrawable3D

public void setDrawable3D(Drawable3D drawable3d)
Parameters:
drawable3d - the drawable3D to set

setEnable

public void setEnable(boolean enable)
Sets if this entity is enabled to receive events

Parameters:
enable - if this entity is enabled to receive events

setFocusable

public void setFocusable(boolean focusable)
Sets if this entity is focusable

Parameters:
focusable - if this entity is focusable

setRadius

public void setRadius(float radius)

setTouchable

public void setTouchable(boolean touchable)
Sets if this entity is touchable.

Parameters:
touchable - If true, it'll receive touch events

setVisible

public void setVisible(boolean visible)
Sets if this entity is visible

Parameters:
visible -

touch

public boolean touch(MotionEvent event)
Entity receives a touch event

Parameters:
action - touch's action
Returns:
true if the event was processed by the entity

update

public void update(long elapsed)
Description copied from interface: Drawable2D
Updates the drawable

Specified by:
update in interface Drawable2D
Specified by:
update in interface Drawable3D
Parameters:
elapsed - elapsed time since last updated