天道酬勤,学无止境

ccsprite

Swift Cocos2d3.x CCSprite applyImpulse not giving proper jump

I am using Cocos2d3.x with SpriteBuilder in Swift language. I want to make some animation like bouncing ball on Polls as seen in this GIF: https://www.dropbox.com/s/43vwlbjoazaxe7u/jumpyBall_15_jul_15.gif?dl=0 If you have noticed in the GIF file, each second jump is half of the previous jump. So, it seems pattern of 1,0.5,1,0.5,1,0.5,... Following are my settings: Polls: Physics Enabled Density: 1.0 Static Body Collision Type: Platform Circle: Physics Enabled Density: 1.0 Dynamic Body Collision: hero Affected by gravity MainScene: func ccPhysicsCollisionBegin(pair: CCPhysicsCollisionPair

2022-03-25 22:43:38    分类:问答    swift   cocos2d-iphone   custom-controls   ccsprite   spritebuilder

[cocos2dx android]Rendering CCSprite using raw data from Bitmap

I am trying to fetch an image from a URL into a Bitmap and then using the raw data from the Bitmap am trying to create a CCSprite. The issue here is that the image is corrupted when I display the sprite. I created a standalone android only application(no cocos2dx) and used the same code to fetch and display the Bitmap and its displayed correctly. Any reason why the image is not being properly rendered in cocos2dx? My code to fetch the image from the URL is: String urlString = "http://www.mathewingram.com/work/wp-content/themes/thesis/rotator/335f69c5de_small.jpg";//http://graph.facebook.com/"

2022-03-14 18:11:16    分类:问答    android   bitmap   cocos2d-x   ccsprite

CCSprite Fadeout with children

I'm using a CCSprite with a few other CCSprite objects added as children, the other animations I'm using (scale and rotate) work great and the children are animated too. But when I'm using CCFadeOut, it only fades the parent. I've read that fadeout doesn't apply to the children. Is there any way other than iterating over every child and calling the fadeout on each of them?

2022-03-10 11:53:05    分类:问答    objective-c   ccsprite

Cocos2d: Is it ok to have a pointer to a parent's class pointer?

Silly question. Cocos2d is build around the parent-child hierarchy. I was wondering if it is ok to have a parent class (e.g. GameScene) and initialize a child class (e.g. SpriteHandler) with a pointer to a member of the parent class (e.g. CCSpriteBatchNode*). I am trying to do this to optimize the number of CCSpriteBatchNodes. Here is a code snippet of my main class (GameScene style). #import <Foundation/Foundation.h> #import "cocos2d.h" enum ShooterSceneLayerTags { HudLayerTag = 0, }; @interface ShooterScene : CCLayer { CCSpriteBatchNode* sharedSpriteBatchNode; } -(id)

2022-02-16 00:24:29    分类:问答    pointers   opengl-es   cocos2d-iphone   ccsprite

如何在 cocos2d-x 中调整动画精灵的大小(How to resize the the animating sprite in cocos2d-x)

问题 我想更改正在动画的 Sprite 的大小。 我怎样才能做到这一点 ? 我试图通过使用 setScale 属性来改变它的大小,但它在这里不起作用。 我在哪里做错了? CCArray* frames = CCArray::createWithCapacity(3); CCSpriteFrameCache* frameCache = CCSpriteFrameCache::sharedSpriteFrameCache(); char file[100] = {0}; for (int i = 0; i < 3; i++) { sprintf(file, "bird%d.png", i); CCSpriteFrame* frame = frameCache->spriteFrameByName(file); frames->addObject(frame); } CCAnimation* animation = CCAnimation::createWithSpriteFrames(frames, 0.1); CCAnimate* animate = CCAnimate::create(animation); CCRepeatForever* repeat = CCRepeatForever::create(animate); bird->runAction(repeat)

2022-02-14 16:19:57    分类:技术分享    cocos2d-x   ccsprite   ccspritebatchnode   cocos2d-x-2.x

How to resize the the animating sprite in cocos2d-x

I want to change the size of a Sprite which is animating. How can I do this ? I tried to change its size by using setScale property but it is not working here. where I am doing wrong ? CCArray* frames = CCArray::createWithCapacity(3); CCSpriteFrameCache* frameCache = CCSpriteFrameCache::sharedSpriteFrameCache(); char file[100] = {0}; for (int i = 0; i < 3; i++) { sprintf(file, "bird%d.png", i); CCSpriteFrame* frame = frameCache->spriteFrameByName(file); frames->addObject(frame); } CCAnimation* animation = CCAnimation::createWithSpriteFrames(frames, 0.1); CCAnimate* animate = CCAnimate::create

2022-02-14 13:04:02    分类:问答    cocos2d-x   ccsprite   ccspritebatchnode   cocos2d-x-2.x

Cocos2d:CCSprite 子类中的 CCSprite initWithFile 崩溃(Cocos2d: CCSprite initWithFile in CCSprite subclass crashes)

问题 我有自定义 CCSprite 子类的 cocos2d 项目: MyCustomSprite.h: #import "cocos2d.h" @interface MyCustomSprite : CCSprite @end MyCustomSprite.m: #import "MyCustomSprite.h" @implementation MyCustomSprite - (id)init { self = [super initWithFile:@"index.png"]; return self; } @end 由于某些奇怪的原因,此代码将因“EXC_BAD_ACCESS”而崩溃。 但尽管如此,如果我像往常一样初始化超级,然后从 CCSprite 的 initWithFile 和 initWithTexture 编写代码,它会正常工作: self = [super init]; if (self) { // Code from CCSprite.m - initWithFile CCTexture2D *texture = [[CCTextureCache sharedTextureCache] addImage: @"index.png"]; CGRect rect = CGRectZero; rect.size = texture.contentSize; //

2022-02-08 22:19:04    分类:技术分享    objective-c   cocos2d-iphone   ccsprite