cocos2d-x

How to resize the the animating sprite in cocos2d-x

久未见 提交于 2019-12-13 05:04:06
问题 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

Cocos2dx 2.1.4 Game, Continuos FPS drop and never recovers

[亡魂溺海] 提交于 2019-12-13 04:50:33
问题 I am creating a game using cocos2dx 2.1.4. Its FPS drops continuously , and never recover. Please find the details as follows Background about the way I am doing things:- Its game about scrolling down some shapes, each shape is made up of some square blocks.I have 7 kind of blocks. All loaded in a Sprite Sheet and using these blocks from this sprite sheet I create a shape. A level file is consist of these shapes. I load two levels at the same time one onscreen and another off screen to make

everyplay causes my screen size change

不想你离开。 提交于 2019-12-13 04:45:13
问题 used cocos2d-x(version:"cocos2d-2.1beta3-x-2.1.1") under xcode I set CCEGLView::sharedOpenGLView()->setDesignResolutionSize(960, 640, kResolutionShowAll) to make my game fit different devices. With Everyplay effect on, my screen size will change auto, only happened when test on real machine, but no such bug when I use kResolutionExactFit. However, I need to use kResolutionShowAll. With iphone4 it works all well,but with ipad and iphone 5(I think all devices except screen size is 960*640) have

Is Cocos2d-x a good development platform for games? [closed]

喜你入骨 提交于 2019-12-13 04:43:27
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . I have just learnt Cocos2d, but i am not an expert on it. But a friend told me to learn Cocos2d-x. Should i prefer Cocos2d-x on

Cocos 2d 2.0 shouldAutorotate not working?

帅比萌擦擦* 提交于 2019-12-13 02:25:12
问题 I'm having some issues. I have a cocos2d game I'm just about done developing. However I've run into a problem where I need to enable portrait orientation in my apps plist for game center sign in to work without throwing a SIGABRT error. So once I enable that from my app's build summary page (Or add it to the info.plist file as a supported orientation) it works fine. But then anytime in my game if you turn the iPhone it will flip to portrait mode if it senses you turned it that way. I've tried

Cocos2dx Android: Get data from file(assets/*) failed

天涯浪子 提交于 2019-12-13 01:54:29
问题 Where do you need to add your images in your Cocos2dx Android project (in Eclipse)? They're currently in the 'Resources' folder like what is mentioned on Ray Wenderlich's blog, but I get an error when I run it in the emulator: "get data from (assets/myFileName) failed" for each image. I also added these images to the assets folder in Eclipse, and it makes no difference. It works fine on the iOS side. Any suggestions? 回答1: I believe you need to run ./build_native.sh in your android folder

How to access Physics World in Layer

拟墨画扇 提交于 2019-12-13 01:29:27
问题 I need to create joint between two bodies in layer. Joints are to be added in physics world. How can i access physics world in layer? 回答1: My JavaScript implementation. Hope it will help. var space; function initPhysics() { space = new cp.Space(); space.gravity = cp.v(0, -800); space.iterations = 30; space.sleepTimeThreshold = Infinity; space.collisionSlop = Infinity; } function addJoints() { chainTableJoint1 = new cp.PivotJoint(chainEnd1, tableBackBody, cp.v.add(cp.v(chainEnd1.getPos().x,

cocos2d-x convert UIImage to CCSprite

女生的网名这么多〃 提交于 2019-12-13 00:41:44
问题 has anyone an idea how to convert a UIImage to cocos2d-x CCSprite. My latest attempt was was: 1. Store the UIImage as png on the phone 2. Load the png as a CCSprite [UIImagePNGRepresentation(photo) writeToFile:imagePath atomically:true]; CCSprite *sprite = CCSprite::spriteWithFile(imagePath); But this crashed in CCObject retain function void CCObject::retain(void) { CCAssert(m_uReference > 0, "reference count should greater than 0"); ++m_uReference; } And I do not understand how Walzer Wangs

Errors while building class cocos2d-x

前提是你 提交于 2019-12-12 23:33:32
问题 I added class GraphicsScene.h: #pragma once #include "cocos2d.h" class GraphicsScene : public cocos2d::Layer { public: static cocos2d::Scene* createScene(); virtual bool init(); CREATE_FUNC(GraphicsScene); }; Then #include "GraphicsScene.h" USING_NS_CC; Scene* GraphicsScene::createScene() { auto scene = Scene::create(); auto layer = GraphicsScene::create(); scene->addChild(layer); return scene; } bool GraphicsScene::init() { if ( !Layer::init() ) { return false; } auto sprite = Sprite::create

Created many CCSprits but when triggering ccTouchBegan gives the last one allways

时光总嘲笑我的痴心妄想 提交于 2019-12-12 21:26:22
问题 UPDATE i changed to more simpler example Ok , now i really puzzled i simplified the class as as i was reading on the net the suggestion was to extend CCNode better then CCSprite and keep it as member of the CCNode so here is the very simpleminded example based on the Hello cpp. the problem remine the same , when touching any of the Gem instances i get printed the last Gem added , why ?? i expect that each Touchwill give me the correct instance that have bean touched ( i print id and name ) Im