Error assertion failed after cocos2d-x upgrade 2.0: (getshaderprogram (), function draw,

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.