Posts Tagged ‘CCNumber’
CCX Extensions
March 24, 2012
Leave a comment
Hey guys. I was pretty irritated by the fact that there was no NSNumber style class in cocos2dx. This made it impossible to use CCDictionary to transport ints and doubles.
To solve it, I wrote a small template class which is based on CCObject and can be used smoothly with CCDictionary and CCArray.
Link:
CCX Extensions
Example:
first: CCXNumber<unsigned long long> *veryLong = CCXNumber<unsigned long long>::numberWithValue(13013123.2312132); myCoolDict->setObject(veryLong, "key"); later: CCXNumber<unsigned long long> *storedLong = static_cast<CCXNumber<unsigned long long> *>(myCoolDict->objectForKey("key")); CCLog("%llu", storedLong->getValue());
Have fun