17 #ifndef __CU_ROOT_LAYER_H__
18 #define __CU_ROOT_LAYER_H__
21 #include <renderer/CCTrianglesCommand.h>
26 #pragma mark Static Constructor Template
43 Scene* createScene() {
44 T* layer =
new (std::nothrow)T();
45 if (layer && layer->init()) {
49 auto scene = Scene::create();
51 scene->addChild(layer);
56 CC_SAFE_DELETE(layer);
75 Scene* createScene(
const Size& size) {
76 T* layer =
new (std::nothrow)T();
77 if (layer && layer->init(size)) {
81 auto scene = Scene::create();
83 scene->addChild(layer);
88 CC_SAFE_DELETE(layer);
94 #pragma mark Root Layer
98 class CC_DLL
RootLayer:
public Layer,
public BlendProtocol {
100 #pragma mark Internal Helpers
122 void clearRenderData();
127 void updateColor(
void)
override;
132 void updateBlendFunc(
void);
136 #pragma mark Attribute Accessors
145 virtual void setContentSize(
const Size & size)
override;
154 void setBlendFunc(
const BlendFunc &blendFunc)
override { _blendFunc = blendFunc; }
176 virtual void draw(Renderer *renderer,
const Mat4& transform, uint32_t flags)
override;
181 virtual void cleanup()
override;
184 #pragma mark Primary Designer Methods
227 CCASSERT(_active,
"Update called on inactive root layer");
239 CC_CONSTRUCTOR_ACCESS:
240 #pragma mark Initializers
261 virtual bool init()
override;
272 virtual bool initWithSize(
const Size& size);
282 virtual bool initWithColor(
const Color4B& color,
const Size& size);
297 friend Scene* GameRoot::createScene();
314 friend Scene* GameRoot::createScene(
const Size& size);
Definition: CURootLayer.h:98
Texture2D * _texture
Definition: CURootLayer.h:107
bool isActive() const
Definition: CURootLayer.h:192
virtual void start()
Definition: CURootLayer.h:200
const BlendFunc & getBlendFunc() const override
Definition: CURootLayer.h:163
virtual void stop()
Definition: CURootLayer.h:212
BlendFunc _blendFunc
Definition: CURootLayer.h:109
virtual void update(float dt) override
Definition: CURootLayer.h:226
TrianglesCommand _command
Definition: CURootLayer.h:112
bool _active
Definition: CURootLayer.h:117
Definition: CURootLayer.h:29
TrianglesCommand::Triangles _triangles
Definition: CURootLayer.h:114
void setBlendFunc(const BlendFunc &blendFunc) override
Definition: CURootLayer.h:154