首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >cocos2dx 3.3动画实现

cocos2dx 3.3动画实现
EN

Stack Overflow用户
提问于 2015-05-13 13:30:04
回答 2查看 512关注 0票数 1

我是cocos2dx开发方面的新手,我几乎都是用cocos2dx语言学习安卓的所有基本级别的cocos2dx(Version3.3)。我向您展示了在cocos2dx.org上有很多更新。

在安卓系统中,我目前正在使用cocos2dx版本3.3开发俄罗斯方块游戏,我想知道实现令人敬畏的动画的最佳方式是什么,比如定时炸弹、炸弹爆炸、旋转游戏分数显示、弹出和随着游戏分数增加而消失的气球。我想知道在安卓系统中使用cocos2dx使用c++来实现动画。我们还需要制作支持多屏幕支持的游戏,我搜索了很多这些点无法在谷歌上找到很多信息。

我向初学者展示了声纳系统很好的支持,我们真的很感激,我看了声纳系统在YouTube上分享的所有视频。我在那里学到了很多。我想知道cocos2dx中安卓系统的高级动画。

我们寻求任何帮助都会感激的。

谢谢

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-05-18 07:06:18

这是我的应用程序。

代码语言:javascript
复制
#ifndef __APPMACROS_H__
#define __APPMACROS_H__

#include "cocos2d.h"



#define DESIGN_RESOLUTION_480X320    0
#define DESIGN_RESOLUTION_480X800    1
#define DESIGN_RESOLUTION_1024X768   2
#define DESIGN_RESOLUTION_1280X800   3
#define DESIGN_RESOLUTION_2048X1536  4

/* If you want to switch design resolution, change next line */
#define TARGET_DESIGN_RESOLUTION_SIZE  DESIGN_RESOLUTION_1280X800

typedef struct tagResource
{
    cocos2d::CCSize size;
    char directory[100];
}Resource;

static Resource smallResource  =  { CCSizeMake(480, 320),   "iphone" };
static Resource mysmallResource  =  { CCSizeMake(800, 480),   "iphone" };
static Resource mediumResource =  { CCSizeMake(1024, 768),  "ipad"   };
static Resource myResource =  { CCSizeMake(1280, 800),  "ipad" };
static Resource largeResource  =  { CCSizeMake(2048, 1536), "ipadhd" };

#if (TARGET_DESIGN_RESOLUTION_SIZE == DESIGN_RESOLUTION_480X320)
static cocos2d::CCSize designResolutionSize = cocos2d::CCSizeMake(480, 320);
#elif (TARGET_DESIGN_RESOLUTION_SIZE == DESIGN_RESOLUTION_480X800)
static cocos2d::CCSize designResolutionSize = cocos2d::CCSizeMake(800, 480);
#elif (TARGET_DESIGN_RESOLUTION_SIZE == DESIGN_RESOLUTION_1024X768)
static cocos2d::CCSize designResolutionSize = cocos2d::CCSizeMake(1024, 768);
#elif (TARGET_DESIGN_RESOLUTION_SIZE == DESIGN_RESOLUTION_2048X1536)
static cocos2d::CCSize designResolutionSize = cocos2d::CCSizeMake(2048, 1536);
#elif (TARGET_DESIGN_RESOLUTION_SIZE == DESIGN_RESOLUTION_1280X800)
static CCSize designResolutionSize = cocos2d::CCSizeMake(1280, 800);
#else
#error unknown target design resolution!
#endif

// The font size 24 is designed for small resolution, so we should change it to fit for current design resolution
#define TITLE_FONT_SIZE  (cocos2d::CCEGLView::sharedOpenGLView()->getDesignResolutionSize().width / myResource.size.width * 24)

#endif /* __APPMACROS_H__ */

现在我们可以在app委托中使用这个类了。所以我的应用程序代表看起来..。

代码语言:javascript
复制
#include "AppDelegate.h"
#include "MenuLayer.h"
#include "AppMacros.h"
#include "SimpleAudioEngine.h"
#include "cocos2d.h"


USING_NS_CC;


AppDelegate::AppDelegate() {

}

AppDelegate::~AppDelegate() {

}
void AppDelegate::initGLContextAttrs()
{
    //set OpenGL context attributions,now can only set six attributions:
    //red,green,blue,alpha,depth,stencil
    GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8};

    GLView::setGLContextAttrs(glContextAttrs);
}

bool AppDelegate::applicationDidFinishLaunching() {

    // initialize director
    auto director = Director::getInstance();
    auto glview = director->getOpenGLView();
    if(!glview) {
        glview = GLViewImpl::create("My Game");
        director->setOpenGLView(glview);
    }

    CCLOG("%s","applicationDidFinishLaunching ");
    // initialize director
//  CCDirector* pDirector = CCDirector::sharedDirector();
//  CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();

    director->setOpenGLView(glview);

    // Set the design resolution
    glview->setDesignResolutionSize(designResolutionSize.width,
            designResolutionSize.height, kResolutionFixedWidth);

    //CCSize frameSize = pEGLView->getFrameSize();
    CCSize frameSize = director->getVisibleSize();

    // if the frame's height is larger than the height of medium resource size, select large resource.
    if (frameSize.width > myResource.size.width) {

        director->setContentScaleFactor(
                largeResource.size.width / designResolutionSize.width);

    }
    // if the frame's height is larger than the height of small resource size, select medium resource.
    else if (frameSize.width > mediumResource.size.width) {

        director->setContentScaleFactor(
                myResource.size.width / designResolutionSize.width);

    } else if (frameSize.width > mysmallResource.size.width) {

        director->setContentScaleFactor(
                designResolutionSize.width / mediumResource.size.width);

    } else if (frameSize.width > smallResource.size.width) {

        director->setContentScaleFactor(
                designResolutionSize.width / mediumResource.size.width);

    }
    // if the frame's height is smaller than the height of medium resource size, select small resource.
    else {

        director->setContentScaleFactor(
                designResolutionSize.width / smallResource.size.width);

    }

    // turn on display FPS
    director->setDisplayStats(false);

    // set FPS. the default value is 1.0/60 if you don't call this
    director->setAnimationInterval(1.0 / 60);


    CCScene *pScene = MenuLayer::scene();


    director->runWithScene(pScene);



    return true;
}

// This function will be called when the app is inactive. When comes a phone call,it's be invoked too
void AppDelegate::applicationDidEnterBackground() {
    CCDirector::sharedDirector()->stopAnimation();

    // if you use SimpleAudioEngine, it must be pause
    CocosDenshion::SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();


}

// this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground() {
    CCDirector::sharedDirector()->startAnimation();

    // if you use SimpleAudioEngine, it must resume here
    CocosDenshion::SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();


}
票数 1
EN

Stack Overflow用户

发布于 2015-05-15 04:50:03

我也是cocos2dx 3.3的新手。我使用动画爆炸(爆炸)通过使用( .plist )粒子效果,首先,你需要一个动画的.plist文件。有一个在线编辑器来制作.plist文件。你可以在这里查一下链接。http://www.effecthub.com/particle2dx

现在您可以使用thiese代码行。

代码语言:javascript
复制
CCParticleSystemQuad *system = CCParticleSystemQuad::create("explodeEffect.plist");

system->setTexture(CCTextureCache::sharedTextureCache()->addImage("yourplayer.png"));
system->setDuration(0.05);
system->setScale(3.0f);
 system->setPosition(yourplayer->getPosition().x, yourplayer->getPosition().y);
this->addChild(system,1);
system->setAutoRemoveOnFinish(true);

这会帮你的

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30216371

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档