-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
449 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
CocoGUILIB/CocoGUILIB/CGraphics/CClipAbleLayerGradient.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
// | ||
// CClipAbleLayerGradient.cpp | ||
// Test | ||
// | ||
// Created by cai wenzhi on 13-6-18. | ||
// | ||
// | ||
|
||
#include "CClipAbleLayerGradient.h" | ||
|
||
using namespace cocos2d; | ||
|
||
namespace cs { | ||
|
||
CClipAbleLayerGradient* CClipAbleLayerGradient::create(const cocos2d::ccColor4B &colorStart,const cocos2d::ccColor4B &colorEnd){ | ||
CClipAbleLayerGradient * pLayer = new CClipAbleLayerGradient(); | ||
if( pLayer && pLayer->initWithColor(colorStart,colorEnd)) | ||
{ | ||
pLayer->autorelease(); | ||
return pLayer; | ||
} | ||
CC_SAFE_DELETE(pLayer); | ||
return NULL; | ||
} | ||
|
||
CClipAbleLayerGradient* CClipAbleLayerGradient::create(){ | ||
CClipAbleLayerGradient * pLayer = new CClipAbleLayerGradient(); | ||
if( pLayer && pLayer->init()) | ||
{ | ||
pLayer->autorelease(); | ||
return pLayer; | ||
} | ||
CC_SAFE_DELETE(pLayer); | ||
return NULL; | ||
} | ||
|
||
bool CClipAbleLayerGradient::init() | ||
{ | ||
if (CCLayerGradient::init()) | ||
{ | ||
// this->setCascadeOpacityEnabled(true); | ||
// this->setCascadeColorEnabled(true); | ||
|
||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
void CClipAbleLayerGradient::visit(){ | ||
if (this->m_bClipAble) { | ||
glEnable(GL_SCISSOR_TEST); | ||
CCPoint local = this->convertToWorldSpace(CCPointZero); | ||
|
||
if (this->m_bEnableCustomArea) { | ||
CCEGLView::sharedOpenGLView()->setScissorInPoints(local.x, local.y, this->m_fScissorWidth, this->m_fScissorHeight); | ||
}else{ | ||
CCSize s = this->boundingBox().size; | ||
CCEGLView::sharedOpenGLView()->setScissorInPoints(local.x, local.y, s.width, s.height); | ||
} | ||
|
||
CCLayerColor::visit(); | ||
glDisable(GL_SCISSOR_TEST); | ||
}else { | ||
CCLayerColor::visit(); | ||
} | ||
} | ||
|
||
void CClipAbleLayerGradient::setClipAble(bool able) | ||
{ | ||
this->m_bClipAble = able; | ||
} | ||
|
||
void CClipAbleLayerGradient::setColorEnable(bool enable) | ||
{ | ||
this->m_bColorEnable = enable; | ||
} | ||
|
||
bool CClipAbleLayerGradient::getColorEnable() | ||
{ | ||
return this->m_bColorEnable; | ||
} | ||
|
||
void CClipAbleLayerGradient::setClipRect(const cocos2d::CCRect &rect) | ||
{ | ||
|
||
} | ||
|
||
void CClipAbleLayerGradient::setClipSize(float width, float height) | ||
{ | ||
this->m_bEnableCustomArea = true; | ||
this->m_fScissorWidth = width; | ||
this->m_fScissorHeight = height; | ||
} | ||
|
||
void CClipAbleLayerGradient::draw() | ||
{ | ||
// to head off the draw call | ||
if (this->m_bColorEnable) { | ||
CCLayerColor::draw(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// | ||
// CClipAbleLayerGradient.h | ||
// Test | ||
// | ||
// Created by cai wenzhi on 13-6-18. | ||
// | ||
// | ||
|
||
#ifndef __Test__CClipAbleLayerGradient__ | ||
#define __Test__CClipAbleLayerGradient__ | ||
|
||
#include "cocos2d.h" | ||
|
||
namespace cs { | ||
class CClipAbleLayerGradient : public cocos2d::CCLayerGradient { | ||
public: | ||
CClipAbleLayerGradient():m_bClipAble(false),m_fScissorX(0.0),m_fScissorY(0.0),m_fScissorWidth(0.0),m_fScissorHeight(0.0),m_bEnableCustomArea(false),m_bColorEnable(false){}; | ||
virtual ~CClipAbleLayerGradient(){}; | ||
static CClipAbleLayerGradient* create(const cocos2d::ccColor4B &colorStart,const cocos2d::ccColor4B &colorEnd); | ||
static CClipAbleLayerGradient* create(); | ||
bool init(); | ||
virtual void visit(); | ||
void setClipAble(bool able); | ||
void setColorEnable(bool enable); | ||
bool getColorEnable(); | ||
void setClipRect(const cocos2d::CCRect &rect); | ||
void setClipSize(float width,float height); | ||
virtual void draw(); | ||
protected: | ||
bool m_bClipAble; | ||
float m_fScissorX; | ||
float m_fScissorY; | ||
float m_fScissorWidth; | ||
float m_fScissorHeight; | ||
bool m_bEnableCustomArea; | ||
bool m_bColorEnable; | ||
}; | ||
} | ||
|
||
#endif /* defined(__Test__CClipAbleLayerGradient__) */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.