Forums » C++ Framework » lightning extension »
| Tix Lo | lightning extension | ||||
|---|---|---|---|---|---|
|
Added by Tix Lo over 1 year ago
Dear Sirs, I port the lightning source to cocos2d-x platform according to http://www.cocos2d-iphone.org/forum/topic/370/page/2 the lightning implementation is by using glVertexPointer, and so it looks like a little simple. Maybe someone will need or improve them to more like the lightning effect. CCLightning.h (1.6 kB) CCLightning.cpp (5.5 kB) HelloWorldScene.h (764 Bytes) HelloWorldScene.cpp (2.8 kB) |
||||
| Zhe Wang | RE: lightning extension | ||||
|
Added by Zhe Wang over 1 year ago
Cool! Enjoy Coding, Enjoy Life. |
||||
| nuwan nara | RE: lightning extension | ||||
|
Added by nuwan nara over 1 year ago
yep.. nice work... but i couldn't use it.. coz it gives me a compiler error.. on
CCLightning* CCLightning::lightningWithStrikePoint(CCPoint strikePoint)
{
CCLightning* lightning = new CCLightning(); >>>>>>>>>>>error: allocating an object of abstract class type 'CCLightning'
if (lightning && lightning->initWithStrikePoint(strikePoint))
{
lightning->autorelease();
return lightning;
}
CC_SAFE_DELETE(lightning);
return NULL;
}
CCLightning* CCLightning::lightningWithStrikePoint(CCPoint strikePoint,CCPoint strikePoint2)
{
CCLightning* lightning = new CCLightning(); >>>>>>>>>>>error: allocating an object of abstract class type 'CCLightning'
if (lightning && lightning->initWithStrikePoint(strikePoint,strikePoint2))
{
lightning->autorelease();
return lightning;
}
CC_SAFE_DELETE(lightning);
return NULL;
}
error: allocating an object of abstract class type 'CCLightning' |
||||
| Tix Lo | RE: lightning extension | ||||
|
Added by Tix Lo over 1 year ago
sorry, I missed something and will fix it tomorrow |
||||
| nuwan nara | RE: lightning extension | ||||
|
Added by nuwan nara over 1 year ago
No worries mate.. looking fwd it to... |
||||
| Dany Menko | RE: lightning extension | ||||
|
Added by Dany Menko over 1 year ago
This is amazing! You just gave me so many ideas for amazing games I could do! |
||||
| Tix Lo | RE: lightning extension | ||||
|
Added by Tix Lo over 1 year ago
Hi, I checked the source again and found they work fine. Because CCLightning inherited CCRGBAProtocol, it had to
CCLightning implemented them, too. CCLightning.h CCLightning.cpp
There is a compiling error if those virtual functions are wrong. Could you check the files you downloaded again? best regards. nuwan nara wrote:
|
||||
| winipcfg winipcfg | RE: lightning extension | ||||
|
Added by winipcfg winipcfg over 1 year ago
I use Microsoft Visual Studio. The behavior of compiler may be somehow different so you may not reproduce the issue. 1>cclightning.h : warning C4819: The file contains a character that cannot be represented in the current code page (950). Save the file in Unicode format to prevent data loss 1>cclightning.cpp(19): error C2057: expected constant expression 1>cclightning.cpp(19): error C2466: cannot allocate an array of constant size 0 1>cclightning.cpp(19): error C2133: 'vertices' : unknown size 1>cclightning.cpp(22): warning C4018: '<' : signed/unsigned mismatch 1>cclightning.cpp(74): warning C4244: '+=' : conversion from 'double' to 'float', possible loss of data 1>cclightning.cpp(76): warning C4244: '+=' : conversion from 'double' to 'float', possible loss of data 1>cclightning.cpp(106): error C2259: 'cocos2d::CCLightning' : cannot instantiate abstract class 1> due to following members: 1> 'void cocos2d::CCRGBAProtocol::setIsOpacityModifyRGB(bool)' : is abstract 1> d:\projects\library\cocos2d-1.0.1-x-0.11.0\cocos2dx\include\ccprotocols.h(66) : see declaration of 'cocos2d::CCRGBAProtocol::setIsOpacityModifyRGB' 1> 'bool cocos2d::CCRGBAProtocol::getIsOpacityModifyRGB(void)' : is abstract 1> d:\projects\library\cocos2d-1.0.1-x-0.11.0\cocos2dx\include\ccprotocols.h(71) : see declaration of 'cocos2d::CCRGBAProtocol::getIsOpacityModifyRGB' 1>cclightning.cpp(118): error C2259: 'cocos2d::CCLightning' : cannot instantiate abstract class 1> due to following members: 1> 'void cocos2d::CCRGBAProtocol::setIsOpacityModifyRGB(bool)' : is abstract 1> d:\projects\library\cocos2d-1.0.1-x-0.11.0\cocos2dx\include\ccprotocols.h(66) : see declaration of 'cocos2d::CCRGBAProtocol::setIsOpacityModifyRGB' 1> 'bool cocos2d::CCRGBAProtocol::getIsOpacityModifyRGB(void)' : is abstract 1> d:\projects\library\cocos2d-1.0.1-x-0.11.0\cocos2dx\include\ccprotocols.h(71) : see declaration of 'cocos2d::CCRGBAProtocol::getIsOpacityModifyRGB' |
||||
| Angus Comrie | RE: lightning extension | ||||
|
Added by Angus Comrie over 1 year ago
There are actually 6 functions the CRGBA protocol requires. If your class has no children, you can simply use something like
//CCRGBAProtocol
CC_SYNTHESIZE(GLubyte, m_cOpacity, Opacity);
CC_SYNTHESIZE_PASS_BY_REF(ccColor3B, m_tColor, Color);
CC_SYNTHESIZE(bool, m_bIsOpacityModifyRGB, IsOpacityModifyRGB);
However, if your class has children (eg, a layer or a control or something like that), then you need to also pass through the colours to children. Normally, it follows this sort of method:
//CRGBA protocol
void CCControl::setColor(const ccColor3B& color)
{
m_tColor=color;
CCObject* child;
CCArray* children=getChildren();
CCARRAY_FOREACH(children, child)
{
CCRGBAProtocol* pNode = dynamic_cast<CCRGBAProtocol*>(child);
if (pNode)
{
pNode->setColor(m_tColor);
}
}
}
const ccColor3B& CCControl::getColor(void)
{
return m_tColor;
}
void CCControl::setOpacity(GLubyte opacity)
{
m_cOpacity = opacity;
CCObject* child;
CCArray* children=getChildren();
CCARRAY_FOREACH(children, child)
{
CCRGBAProtocol* pNode = dynamic_cast<CCRGBAProtocol*>(child);
if (pNode)
{
pNode->setOpacity(opacity);
}
}
}
GLubyte CCControl::getOpacity()
{
return m_cOpacity;
}
void CCControl::setIsOpacityModifyRGB(bool opacityModifyRGB)
{
m_bIsOpacityModifyRGB=opacityModifyRGB;
CCObject* child;
CCArray* children=getChildren();
CCARRAY_FOREACH(children, child)
{
CCRGBAProtocol* pNode = dynamic_cast<CCRGBAProtocol*>(child);
if (pNode)
{
pNode->setIsOpacityModifyRGB(opacityModifyRGB);
}
}
}
bool CCControl::getIsOpacityModifyRGB()
{
return m_bIsOpacityModifyRGB;
}
|
||||
| Ivan Fedorov | RE: lightning extension | ||||
|
Added by Ivan Fedorov 3 months ago
it just was for opengl 1 |
(1-9/9)
