We have just finished a essential guide to Cocos2d-x book in C++ and it is in English. It is currently being reviewed by the publisher and should be released September/October.
Refactor the animated sprite code to use less lines of code. Now it is
Vector<SpriteFrame*> animFrames(15);
char str[100] = {0};
for(int i = 1; i < 15; i++)
{
sprintf(str, âgrossini_dance_%02d.pngâ,i);
auto frame = SpriteFrame::create(str,Rect(0,0,40,40)); //we assume that the spritesâ dimentions are 40*40 rectangles.
animFrames.pushBack(frame);
}
just to create a vector of sprite frames. So better to refactor it and put it in an official cocos2d-x function?
Question, we are trying to implement moving Physics bodies using the built in Physics system and we want the bodies to remain at a constant velocity even when they collide with each other. How can we do this? We have been struggling with this. Help would be appreciated.
Looking forward to it!
Great news
you can set the weight to be very high, but it will still result in very slight deviation
another thing you could do is to store its velocity vector before impact, and set it to that value during the impact callback
What do you mean by super-animation
?
To be honest, the current AnySDK API design (inherited from plugin-x) is ugly, the only thing I satisfy is that, it works.
Weight as in mass?
Also how would you know what the velocity should be after as technically the direction has changed.
Good to hear somebody from the team agrees.
What I mean is this http://raymondlu1983.blog.com/super-animation-converter/ , I find it easy and much reliable than dragonbones for cocos2d-x.
I donât think itâs a good idea, you should pass lots of arguments to the function, eg. picture name, count, begin pos, end pos, rect and so onâŠ
Good! It looks convenient, Iâll try it.
And we would recommend this to developers if it was really good~~
Suggest:
- An Editor where have âScene Vá»ewâ and âGame Viewâ like Unity3D?
What Iâm doing is like this, and I also agree for better and simpler function call.
CCSprite* Utils::createAnimation(const char* pPlist,const char* pCommonName,uint32_t pStartFrame,uint32_t pEndFrame,float pFrameDelay,bool isLoop)
{
CCSpriteFrameCache* cacher = CCSpriteFrameCache::sharedSpriteFrameCache();
cacher->addSpriteFramesWithFile(pPlist);
const int kNumberOfFrames = pEndFrame + 1; CCArray* frames = new CCArray; frames->initWithCapacity(kNumberOfFrames); for( int i = pStartFrame; i < kNumberOfFrames; i++ ) { CCString* filename = CCString::createWithFormat("%s%d.png",pCommonName, i); frames->addObject(cacher->spriteFrameByName(filename->getCString())); }
CCSprite* sprite = new CCSprite; CCString* dummy = CCString::createWithFormat("%s1.png",pCommonName); sprite->initWithSpriteFrameName(dummy->getCString());
CCAnimation* anim = new CCAnimation; anim->initWithSpriteFrames(frames, pFrameDelay);
if(isLoop) sprite->runAction(CCRepeatForever::create(CCAnimate::create(anim))); else sprite->runAction(CCAnimate::create(anim));
//cacher->release(); return sprite;
}
I am interested in it I will try it
CocoStudio Scene Editor can view the game scene, even view it on your smart phone through QR code.
Thank you. I will try CocosStudio for Mac. Hope that release version will come soon.
Maybe this wonât relate to cocos2d-x 3.0 engine, but cocostudio need to be improved. Especially, the document and tutorial using cocostudio with cocos2d-x