资源简介
今后上传的资源都会免费提供下载,包括我开发的demo项目和游戏素材,技术体会都将上传。
代码片段和文件信息
#include “AppDelegate.h“
#include “HelloWorldScene.h“
USING_NS_CC;
static cocos2d::Size designResolutionSize = cocos2d::Size(960640);
static cocos2d::Size smallResolutionSize = cocos2d::Size(480 320);
static cocos2d::Size mediumResolutionSize = cocos2d::Size(1024 768);
static cocos2d::Size largeResolutionSize = cocos2d::Size(2048 1536);
AppDelegate::AppDelegate() {
}
AppDelegate::~AppDelegate()
{
}
//if you want a different contextjust modify the value of glContextAttrs
//it will takes effect on all platforms
void AppDelegate::initGLContextAttrs()
{
//set OpenGL context attributionsnow can only set six attributions:
//redgreenbluealphadepthstencil
GLContextAttrs glContextAttrs = {8 8 8 8 24 8};
GLView::setGLContextAttrs(glContextAttrs);
}
// If you want to use packages manager to install more packages
// don‘t modify or remove this function
static int register_all_packages()
{
return 0; //flag for packages manager
}
bool AppDelegate::applicationDidFinishLaunching() {
// initialize director
auto director = Director::getInstance();
auto glview = director->getOpenGLView();
if(!glview) {
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) || (CC_TARGET_PLATFORM == CC_PLATFORM_LINUX)
glview = GLViewImpl::createWithRect(“LiuJunLiang“ Rect(0 0 designResolutionSize.width designResolutionSize.height));
#else
glview = GLViewImpl::create(“LiuJunLiang“);
#endif
director->setOpenGLView(glview);
}
// 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.0f / 60);
// Set the design resolution
glview->setDesignResolutionSize(designResolutionSize.width designResolutionSize.height ResolutionPolicy::NO_BORDER);
Size frameSize = glview->getframeSize();
// if the frame‘s height is larger than the height of medium size.
if (frameSize.height > mediumResolutionSize.height)
{
director->setContentScaleFactor(MIN(largeResolutionSize.height/designResolutionSize.height largeResolutionSize.width/designResolutionSize.width));
}
// if the frame‘s height is larger than the height of small size.
else if (frameSize.height > smallResolutionSize.height)
{
director->setContentScaleFactor(MIN(mediumResolutionSize.height/designResolutionSize.height mediumResolutionSize.width/designResolutionSize.width));
}
// if the frame‘s height is smaller than the height of medium size.
else
{
director->setContentScaleFactor(MIN(smallResolutionSize.height/designResolutionSize.height smallResolutionSize.width/designResolutionSize.width));
}
register_all_packages();
// create a scene. it‘s an autorelease object
auto scene = HelloWorld::createScene();
// run
director->runWithScene(scene);
return true;
}
// This function
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2016-10-03 14:22 Classes\
文件 3594 2016-09-28 17:23 Classes\AppDelegate.cpp
文件 987 2016-09-24 17:02 Classes\AppDelegate.h
文件 1401 2016-10-01 21:50 Classes\golds.cpp
文件 259 2016-10-01 21:50 Classes\golds.h
文件 2488 2016-10-03 00:43 Classes\HelloWorldScene.cpp
文件 506 2016-09-28 18:47 Classes\HelloWorldScene.h
文件 428 2016-09-29 11:58 Classes\heroMiner.cpp
文件 304 2016-09-28 23:08 Classes\heroMiner.h
文件 15724 2016-10-03 14:11 Classes\mainGameScene.cpp
文件 1779 2016-10-02 23:51 Classes\mainGameScene.h
文件 4358 2016-10-02 22:51 Classes\pauseMenu.cpp
文件 832 2016-10-02 22:12 Classes\pauseMenu.h
文件 2702 2016-10-02 15:41 Classes\settingMenu.cpp
文件 628 2016-09-28 18:29 Classes\settingMenu.h
文件 689 2016-09-29 12:05 Classes\startGameti
文件 342 2016-09-29 11:58 Classes\startGameti
- 上一篇:C++API中文版CHM
- 下一篇:WOA鲸鱼优化算法 C++实现
评论
共有 条评论