使用cocos2d-x編程debug記錄

Debug Records

1.      Error when read data from xmlfile?

Trace it I find:

In file CCSAXParser.cpp

         intresultxmlSAXUserParseMemory( &saxHandlerthispBuffersize);

         if ( result != 0 )

         {

                   returnfalse;

         }

In this code it the result!=0 and returnedfrom here.

 

But the other little game program doesn’treturn from here.

 

So I think the error is in the xml filesand find:

<?xml version="1.0"encoding="UTF_8"?>

 

The UTF_8 is wrong

 

Should be:

<?xml version="1.0"encoding="UTF-8"?>

 

2.      Error when add a button to thelayer.

It cannot receive the touch event.

Reason: Forgot to add the button to Menu,then add the Menu to the layer.

 

3.      File open error!!!

Fogget to trim the return after the filename in SqlLite database.

 

4.      Coordinate Error!!

Somegthing is wrong with the coordinate ofthe data of the rectangle read from the TMX files.

 

Little Summary:

Most of the bugs result from data errors orcarelessness when coding,

So,

Make sure the data is right next time andbe more careful when coding,

What’s else learn more techniques.

 

5.      Cannot use the class whose headfile I have included?

We can just see we cannot directly use it,but we can use it indirectly.

Add the namespace!!! Like CocosDenshion::SimpleAudioEngine.

Or and usingnamespace CocosDenshion at the beginning of the file.

Bug like this kind should be avoid at thebeginning.

 

6.      When use the schedule(schedule_selector(CategoryLogic::playWinSound),0.5f);

The callback function cannot be const and musthave a parameter with the type ccTime.


發佈了32 篇原創文章 · 獲贊 10 · 訪問量 11萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章