Wednesday, April 22, 2015

C++: Find string within a string

There is a string::find function that is pretty straightforward to use. The key thing to note here is that when it's not found the return value is "string::npos".

Reference: http://www.cplusplus.com/reference/string/string/find/

C++: Constructing a std::string from std::vector

std::vector<char> is actually a vector of the characters that make up the string.

There is a constructor for std::string that can be used for this i.e. std::string s(v.begin(),v.end());

Reference: http://stackoverflow.com/questions/5115166/how-to-construct-a-stdstring-from-a-stdvectorchar

Monday, April 20, 2015

Coco2D-X: long Values on iOS

"long" isn't guaranteed to be 64 bits on iOS. To be sure that there won't be overflow, use int64_t.

Reference http://stackoverflow.com/questions/13604137/definition-of-int64-t

Friday, April 17, 2015

Cocos2D-X List of Actions

Quick reference here: http://www.cocos2d-x.org/wiki/Actions

Cocos2D-X FadeIn and FadeOut Not Applying to Children of a Sprite

The default behaviour for Cocos2D-X during a FadeIn / FadeOut action is that the only the Sprite will fade in/out, and if it has children, they will be unaffected.

In order for a FadeIn / FadeOut action to apply to the children of a Sprite, call "setCascadeOpacityEnabled(true)" on the parent Sprite.

Reference: http://discuss.cocos2d-x.org/t/fadein-and-fadeout-does-not-apply-to-children-even-in-3-3-final/19079