Recently I tried to write something we used to write with cocos2d-x 1. X.CodeAfter upgrading to 2.x, most of the Creation code is changed to create. After a search and replacement, most of the Code is OK, but this error occurs, I have been here for a long time:
Assertion failed: (getshaderprogram (), function draw, file/users/Limin/backup/point21/trunk/blackjackios/blackjack/libs/cocos2dx/sprite_nodes/ccsprite. CPP, line 579.
The reason for this is that we have a class that inherits ccsprite, but it does not have texture. It is only used to manage a bunch of child ccsprite and write the initialization code by ourselves.
Bool Toselfheadbox: Init (Fmgameuser* User ){
Initdata(User );
Return True;
}
Toselfheadbox*Toselfheadbox: Initselfheadbox (Fmgameuser* User ){
Toselfheadbox* Pret =
New Toselfheadbox();
If(Pret & pret->Init(User )){
Pret->Autorelease();
ReturnPret;
}
Cc_safe_delete(Pret );
Return Null;
}
The error message is that the shader is not specified. Later I studied the code of ccsprite for half a day and found the solution. The following code is added in init:
Bool Toselfheadbox: Init (Fmgameuser* User ){
If (! Initwithtexture (null, ccrectzero )){
Return false;
}
Initdata(User );
Return True;
}
solve the problem and initialize an empty texture.