Cornell Cocos
Cornell Extensions to Cocos2d
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Friends | List of all members
RootLayer Class Reference

#include <CURootLayer.h>

Inheritance diagram for RootLayer:

Public Member Functions

virtual void setContentSize (const Size &size) override
 
void setBlendFunc (const BlendFunc &blendFunc) override
 
const BlendFunc & getBlendFunc () const override
 
virtual void draw (Renderer *renderer, const Mat4 &transform, uint32_t flags) override
 
virtual void cleanup () override
 
bool isActive () const
 
virtual void start ()
 
virtual void stop ()
 
virtual void update (float dt) override
 
void shutdown ()
 
virtual ~RootLayer (void)
 
virtual bool init () override
 
virtual bool initWithSize (const Size &size)
 
virtual bool initWithColor (const Color4B &color, const Size &size)
 

Public Attributes

CC_CONSTRUCTOR_ACCESS __pad0__: RootLayer(void)
 

Protected Member Functions

void clearRenderData ()
 
void updateColor (void) override
 
void updateBlendFunc (void)
 

Protected Attributes

Texture2D * _texture
 
BlendFunc _blendFunc
 
TrianglesCommand _command
 
TrianglesCommand::Triangles _triangles
 
bool _active
 

Friends

template<class T >
Scene * GameRoot::createScene ()
 
template<class T >
Scene * GameRoot::createScene (const Size &size)
 

Detailed Description

The top layer for the game scene graph.

Constructor & Destructor Documentation

RootLayer::~RootLayer ( void  )
virtual

Releases all resources allocated with this layer.

Member Function Documentation

void RootLayer::cleanup ( )
overridevirtual

Stops all running actions and schedulers

void RootLayer::clearRenderData ( )
protected

Clears the render data, releasing all vertices and indices.

void RootLayer::draw ( Renderer *  renderer,
const Mat4 &  transform,
uint32_t  flags 
)
overridevirtual

Sends drawing commands to the renderer

This method is overridden from Node, to draw the background node. It draws using the same commands as PolygonNode, making it more efficient than the built-in LayerColor.

Parameters
rendererReference to the render thread
transformThe accumulated transform from the parent
flagsSpecialized Cocos2d drawing flags
const BlendFunc& RootLayer::getBlendFunc ( ) const
inlineoverride

Returns the current blend function for this node

This is part of BlendProtocol.

Returns
the node blend function.
bool RootLayer::init ( )
overridevirtual

Intializes an root layer to fit the screen dimensions.

The layer will use the XNA background color for nostalgic reasons.

Returns
true if the layer is initialized properly, false otherwise.
bool RootLayer::initWithColor ( const Color4B &  color,
const Size &  size 
)
virtual

Intializes an root layer to fit the given color and dimensions.

Parameters
colorthe background color
sizethe size for the layer
Returns
true if the layer is initialized properly, false otherwise.
bool RootLayer::initWithSize ( const Size &  size)
virtual

Intializes an root layer to fit the given dimensions.

The layer will use the XNA background color for nostalgic reasons.

Parameters
sizethe size for the layer
Returns
true if the layer is initialized properly, false otherwise.
bool RootLayer::isActive ( ) const
inline

Returns true if this layer is active

An active layer is regularly receiving calls to update.

Returns
true if this layer is active
void RootLayer::setBlendFunc ( const BlendFunc &  blendFunc)
inlineoverride

Sets the blend function to the one specified

This is part of BlendProtocol.

Parameters
blendFuncthe new blend function.
void RootLayer::setContentSize ( const Size &  size)
overridevirtual

Sets the untransformed size of the layer.

The contentSize remains the same no matter how the layer is scaled or rotated. Typically this size is the same size as the screen.

Parameters
contentSizeThe untransformed size of the layer.
void RootLayer::shutdown ( )

Shutsdown the layer, forcing an exit from the application.

This is the method to call to cleanly quit the game.

virtual void RootLayer::start ( )
inlinevirtual

Starts the layer, allocating initial resources

This method is used to bootstrap the game. It should start up an asset manager and load initial assets.

virtual void RootLayer::stop ( )
inlinevirtual

Stops the layer, releasing all resources

This method is used to clean-up any allocation that occurred in either start or update. While Cocos2d does have rudimentary garbage collection, you still have to release any objects that you have retained.

virtual void RootLayer::update ( float  dt)
inlineoverridevirtual

Primary update method called every animation frame

This method is called every animation frame. There is no draw() or render() counterpoint to this method; drawing is done automatically in the scene graph. However, this method is responsible for updating any transforms in the scene graph.

Parameters
dtthe time in seconds since last update
void RootLayer::updateBlendFunc ( void  )
protected

Update the blend options for this node to use in a render pass

void RootLayer::updateColor ( void  )
overrideprotected

Updates the color for each vertices to match the node settings.

Friends And Related Function Documentation

template<class T >
Scene* GameRoot::createScene ( )
friend

Creates a new Scene object with class T as its root layer.

The scene object needs to be attached to a root layer. However, the designer needs to subclass RootLayer in order to define gameplay features. As the createScene() method associated with Layer is typically static, this means we need to define a new method for each subclass. This function uses templates to emulate a static method that works for any subclass.

Returns
an autoreleased scene with class T as its root layer
template<class T >
Scene* GameRoot::createScene ( const Size &  size)
friend

Creates a new Scene object with class T as its root layer.

The scene object needs to be attached to a root layer. However, the designer needs to subclass RootLayer in order to define gameplay features. As the createScene() method associated with Layer is typically static, this means we need to define a new method for each subclass. This function uses templates to emulate a static method that works for any subclass.

Parameters
sizethe size of the layer
Returns
an autoreleased scene with class T as its root layer

Member Data Documentation

bool RootLayer::_active
protected

Whether or not this layer is currently active (e.g. handling updates)

BlendFunc RootLayer::_blendFunc
protected

Blending function is required to implement BlendProtocol

TrianglesCommand RootLayer::_command
protected

The command for the Cocos2D rendering pipeline

Texture2D* RootLayer::_texture
protected

Texture to be applied to the polygon

TrianglesCommand::Triangles RootLayer::_triangles
protected

Rendering data representing a solid shape


The documentation for this class was generated from the following files: