2D rendering base. More...
Inherits Polycode::EventDispatcher.
Public Member Functions | |
Screen () | |
Default constructor. | |
ScreenEntity * | addChild (ScreenEntity *newEntity) |
Adds a ScreenEntity to the 2d rendering pipeline. | |
virtual ScreenEntity * | removeChild (ScreenEntity *entityToRemove) |
Removes a ScreenEntity from the screen's render list. | |
void | setScreenOffset (Number x, Number y) |
Sets the screen's offset. | |
Vector2 | getScreenOffset () const |
Returns the screen's offset. | |
ScreenEntity * | getEntityAt (Number x, Number y) |
Returns the entity at specified point. | |
void | setNormalizedCoordinates (bool newVal, Number yCoordinateSize=1.0f) |
Changes the screen's coordinate system. | |
void | setScreenShader (const String &shaderName) |
Sets the shader material to use for post processing on this screen. | |
void | clearScreenShader () |
Removes the current screen shader for this screen. | |
void | handleEvent (Event *event) |
This method gets called by an EventDispatcher that the handler is listening to if the dispatching event's code matches the code that handler is listening for. | |
void | sortChildren () |
Sorts the screen's children based on their z index. | |
bool | hasFilterShader () const |
Returns true if the screen has a shader applied to it. | |
ScreenEntity * | getRootEntity () |
Returns the root entity. | |
const std::vector < ShaderBinding * > & | getLocalShaderOptions () const |
Returns the local shader options for the camera post processing material. | |
Material * | getScreenShaderMaterial () const |
Returns the shader material applied to the camera. | |
Public Attributes | |
bool | enabled |
If set to false, the screen will not be rendered or updated. | |
bool | processTouchEventsAsMouse |
If set to true, will process touch events as mouse clicks. | |
bool | ownsChildren |
If ownsChildren is set to true, the scene will delete its children upon destruction (defaults to false). |
2D rendering base.
The Screen is the container for all 2D rendering in Polycode. Screens are automatically rendered and need only be instantiated to immediately add themselves to the rendering pipeline. Each screen has a root entity.
ScreenEntity * Screen::addChild | ( | ScreenEntity * | newEntity | ) |
Adds a ScreenEntity to the 2d rendering pipeline.
newEntity | Entity to add. |
ScreenEntity * Screen::getEntityAt | ( | Number | x, | |
Number | y | |||
) |
Returns the entity at specified point.
This is a deprecated method which does not take rotation or scale into account. Please use the 2d physics and collision module for proper collision detection.
ScreenEntity* Polycode::Screen::getRootEntity | ( | ) | [inline] |
Returns the root entity.
The root entity can be used to transform the entire screen and change its color.
Vector2 Screen::getScreenOffset | ( | ) | const |
Returns the screen's offset.
void Screen::handleEvent | ( | Event * | event | ) | [virtual] |
This method gets called by an EventDispatcher that the handler is listening to if the dispatching event's code matches the code that handler is listening for.
Typically, you subclass EventHandler and implement the handleEvent method to handle specific events.
Reimplemented from Polycode::EventHandler.
ScreenEntity * Screen::removeChild | ( | ScreenEntity * | entityToRemove | ) | [virtual] |
Removes a ScreenEntity from the screen's render list.
entityToRemove | Entity to remove. |
void Screen::setNormalizedCoordinates | ( | bool | newVal, | |
Number | yCoordinateSize = 1.0f | |||
) |
Changes the screen's coordinate system.
By default, screens' dimensions are in pixels. To accommodate changing resolutions without changing the dimensions of a screen's content, you can call this method to make it use normalized coordinates.
newVal | If true, the screen will use normalized coordinates, if false, it will use pixel coordinates. | |
yCoordinateSize | The normalized size of the screen vertically. The horizontal size will be calculated based on the resolution. |
void Screen::setScreenOffset | ( | Number | x, | |
Number | y | |||
) |
Sets the screen's offset.
You can also translate the root entity to do the same thing.
x | New x offset. | |
y | New y offset. |
void Screen::setScreenShader | ( | const String & | shaderName | ) |
Sets the shader material to use for post processing on this screen.
shaderName | Name of the shader material to use. |
If set to true, will process touch events as mouse clicks.
Defaults to false.