I am new in cocos2dx development.I almost learn all basic level of cocos2dx (version 3.3) in android using cpp language. I showing that there are lots of update over cocos2dx.org.
In android I am currently developing the tetris game using cocos2dx version 3.3, I want to know what is the best way to achieve awesome animation such like ticking bombs, bomb explosion, spinning game score display, popping up and disappearing balloons with game score increments. I was wondering about animation implementation cocos2dx in android using c++. We also need to make game that support the multiscreen support, I had search lots all these points could not able to find much information over the google.
I show sonar system support nicely for beginner level, we really appreciate it , I had watched all videos shared by sonar system over the YouTube. I learn lot over there. I want to know the advance level animation in android in cocos2dx.
We looking any help will appreciate.
Thank you
here is my appmacros.h filr ..
#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__ */
now we can use this class in appdelegate.. so my appdelegate looks like...
#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();
}