Home » Source Code » cocos2dx+socket » AppDelegate.cpp

AppDelegate.cpp ( File view )

  • By 云飞 2013-10-30
  • View(s):166
  • Download(s):5
  • Point(s): 2
			#include "AppDelegate.h"

#include "cocos2d.h"
#include "HelloWorldScene.h"

#include "CCEGLView.h"

USING_NS_CC;

AppDelegate::AppDelegate() {



}

AppDelegate::~AppDelegate() {


}

bool AppDelegate::initInstance() {

	bool bRet = false;
	do {

#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)

		// Initialize OpenGLView instance, that release by CCDirector when application terminate.
		// The HelloWorld is designed as HVGA.
		CCEGLView * pMainWnd = new CCEGLView();
		CC_BREAK_IF(! pMainWnd
				|| ! pMainWnd->Create(TEXT("cocos2d: Hello World"), 480, 320));

#endif  // CC_PLATFORM_WIN32
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)

		// OpenGLView initialized in testsAppDelegate.mm on ios platform, nothing need to do here.

#endif  // CC_PLATFORM_IOS
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)

		// OpenGLView initialized in HelloWorld/android/jni/helloworld/main.cpp
		// the default setting is to create a fullscreen view
		// if you want to use auto-scale, please enable view->create(320,480) in main.cpp
		// if the resources under '/sdcard" or other writeable path, set it.
		// warning: the audio source should in assets/
		// cocos2d::CCFileUtils::setResourcePath("/sdcard");

#endif  // CC_PLATFORM_ANDROID
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WOPHONE)

		// Initialize OpenGLView instance, that release by CCDirector when application terminate.
		// The HelloWorld is designed as HVGA.
		CCEGLView* pMainWnd = new CCEGLView(this);
		CC_BREAK_IF(! pMainWnd || ! pMainWnd->Create(320,480, WM_WINDOW_ROTATE_MODE_CW));

#ifndef _TRANZDA_VM_  
		// on wophone emulator, we copy resources files to Work7/NEWPLUS/TDA_DATA/Data/ folder instead of zip file
		cocos2d::CCFileUtils::setResource("HelloWorld.zip");
#endif

#endif  // CC_PLATFORM_WOPHONE
#if (CC_TARGET_PLATFORM == CC_PLATFORM_AIRPLAY)
		// MaxAksenov said it's NOT a very elegant solution. I agree, haha
		CCDirector::sharedDirector()->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft);
#endif
#if (CC_TARGET_PLATFORM == CC_PLATFORM_LINUX)

		// Initialize OpenGLView instance, that release by CCDirector when application terminate.
		// The HelloWorld is designed as HVGA.
		CCEGLView * pMainWnd = new CCEGLView();
		CC_BREAK_IF(! pMainWnd
				|| ! pMainWnd->Create("cocos2d: Hello World", 800, 480,480, 320));

		CCFileUtils::setResourcePath("../Resource/");

#endif  // CC_PLATFORM_LINUX

#if (CC_TARGET_PLATFORM == CC_PLATFORM_BADA)

		CCEGLView * pMainWnd = new CCEGLView();
		CC_BREAK_IF(! pMainWnd|| ! pMainWnd->Create(this, 480, 320));
		pMainWnd->setDeviceOrientation(Osp::Ui::ORIENTATION_LANDSCAPE);
		CCFileUtils::setResourcePath("/Res/");

#endif  // CC_PLATFORM_BADA

		bRet = true;
	
} while (0);
	return bRet;

}

bool AppDelegate::applicationDidFinishLaunching() {

	// initialize director
	CCDirector *pDirector = CCDirector::sharedDirector();

	pDirector->setOpenGLView(&CCEGLView::sharedOpenGLView());

	// enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices.
//     pDirector->enableRetinaDisplay(true);

	// turn on display FPS
	pDirector->setDisplayFPS(true);

	// pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft);

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

	// create a scene. it's an autorelease object
	CCScene *pScene = HelloWorld::scene();

	// run
	pDirector->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()->pause();

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

}

// this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground() {

	CCDirector::sharedDirector()->resume();

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

}
			
...
Expand> <Close

Want complete source code? Download it here

Point(s): 2

Download
0 lines left, continue to read
Sponsored links

File list

Tips: You can preview the content of files by clicking file names^_^
Name Size Date
ChatClient.cpp513.00 B14-01-12 18:00
ChatClient.vcproj4.58 kB12-01-12 15:43
ChatClient.vcproj.PCoS-20111206OT.Administrator.user1.39 kB14-01-12 18:40
ODSocket.cpp3.69 kB12-01-12 16:37
ODSocket.h1.61 kB12-01-12 13:43
ReadMe.txt1.29 kB10-01-12 16:26
stdafx.cpp297.00 B10-01-12 16:26
stdafx.h320.00 B10-01-12 16:26
targetver.h765.00 B10-01-12 16:26
ChatClient.sln896.00 B10-01-12 16:26
ChatClient.suo14.00 kB14-01-12 18:40
Android.mk880.00 B12-01-12 17:39
readme.doc170.00 kB14-01-12 18:40
HelloWorld.mkb291.00 B01-12-11 18:36
Main.cpp250.00 B01-12-11 18:36
Main.h42.00 B01-12-11 18:36
AndroidManifest.xml1.13 kB01-12-11 18:36
build_native.sh605.00 B01-12-11 18:36
default.properties364.00 B01-12-11 18:36
R.java867.00 B01-12-11 18:36
Android.mk303.00 B01-12-11 18:36
Application.mk148.00 B01-12-11 18:36
Android.mk534.00 B01-12-11 18:36
main.cpp993.00 B01-12-11 18:36
list.sh362.00 B01-12-11 18:36
icon.png7.17 kB01-12-11 18:36
icon.png2.24 kB01-12-11 18:36
icon.png4.00 kB01-12-11 18:36
game_demo.xml578.00 B01-12-11 18:36
helloworld_demo.xml595.00 B01-12-11 18:36
strings.xml112.00 B01-12-11 18:36
ApplicationDemo.java2.37 kB01-12-11 18:36
Cocos2dxAccelerometer.java3.17 kB01-12-11 18:36
Cocos2dxActivity.java7.47 kB01-12-11 18:36
Cocos2dxBitmap.java11.16 kB01-12-11 18:36
Cocos2dxGLSurfaceView.java13.50 kB01-12-11 18:36
Cocos2dxMusic.java6.06 kB01-12-11 18:36
Cocos2dxRenderer.java4.70 kB01-12-11 18:36
Cocos2dxSound.java7.63 kB01-12-11 18:36
Cocos2dxTypefaces.java1.71 kB01-12-11 18:36
.badaprj171.00 B01-12-11 18:36
.cproject77.53 kB01-12-11 18:36
.project2.91 kB01-12-11 18:36
application.xml622.00 B01-12-11 18:36
MainMenu.png15.87 kB01-12-11 18:36
Splash.png84.47 kB01-12-11 18:36
manifest.xml871.00 B01-12-11 18:36
.badaprj260.00 B01-12-11 18:36
.cproject75.58 kB01-12-11 18:36
.project3.06 kB01-12-11 18:36
application.xml866.00 B01-12-11 18:36
Splash_type2.png29.58 kB01-12-11 18:36
Splash_type3.png34.29 kB01-12-11 18:36
Splash_type4.png84.47 kB01-12-11 18:36
test_type2.png8.00 kB01-12-11 18:36
test_type3.png8.00 kB01-12-11 18:36
test_type4.png12.04 kB01-12-11 18:36
manifest.xml779.00 B01-12-11 18:36
HelloWorldEntry.cpp1.23 kB01-12-11 18:36
Android.mk760.00 B01-12-11 18:36
AppDelegate.cpp4.05 kB23-12-11 11:12
AppDelegate.h1.09 kB01-12-11 18:36
HelloWorldScene.cpp4.26 kB14-01-12 18:18
HelloWorldScene.h899.00 B07-01-12 18:56
ODSocket.cpp3.69 kB12-01-12 17:11
ODSocket.h1.63 kB12-01-12 18:58
sdBall.cpp2.14 kB10-01-12 18:09
sdBall.h571.00 B22-12-11 19:54
sdDangBan.cpp2.51 kB14-01-12 18:05
sdDangBan.h725.00 B22-12-11 19:54
AppController.h1.45 kB01-12-11 18:36
AppController.mm4.93 kB01-12-11 18:36
HelloWorld-Info.plist963.00 B01-12-11 18:36
project.pbxproj132.52 kB01-12-11 18:36
HelloWorld_Prefix.pch189.00 B01-12-11 18:36
main.m368.00 B01-12-11 18:36
RootViewController.h1.36 kB01-12-11 18:36
RootViewController.mm2.61 kB01-12-11 18:36
project.pbxproj137.45 kB01-12-11 18:36
.cproject141.13 kB01-12-11 18:36
.project2.77 kB01-12-11 18:36
main.cpp213.00 B01-12-11 18:36
main.h114.00 B01-12-11 18:36
Makefile977.00 B01-12-11 18:36
postCompiled.sh804.00 B01-12-11 18:36
app.config.txt90.00 B01-12-11 18:36
app.icf139.00 B01-12-11 18:36
background.png477.73 kB22-12-11 19:30
Ball.png3.35 kB21-12-11 14:14
CloseNormal.png5.12 kB01-12-11 18:36
CloseSelected.png6.02 kB01-12-11 18:36
DangBan.png9.23 kB21-12-11 15:15
HelloWorld.png27.88 kB21-12-11 16:38
Icon.png9.11 kB01-12-11 18:36
HelloWorld.win32.vcproj5.21 kB12-01-12 17:16
HelloWorld.win32.vcproj.PCoS-20111206OT.Administrator.user1.44 kB14-01-12 18:17
HelloWorld.win32.vcproj.user487.00 B01-12-11 18:36
HelloWorld.win32.vcxproj7.01 kB01-12-11 18:36
HelloWorld.win32.vcxproj.filters1.18 kB01-12-11 18:36
HelloWorld.win32.vcxproj.user764.00 B01-12-11 18:36
main.cpp408.00 B01-12-11 18:36
main.h277.00 B01-12-11 18:36
HelloWorld.TMK33.03 kB01-12-11 18:36
HelloWorld.wophone.vcproj6.34 kB01-12-11 18:36
HelloWorld.wophone.vcproj.user1.40 kB01-12-11 18:36
HelloWorldUnicodeScript.h250.00 B01-12-11 18:36
HelloWorldUnicodeScript_str.h604.00 B01-12-11 18:36
main.cpp389.00 B01-12-11 18:36
Makefile.ARM2.07 kB01-12-11 18:36
NewDeleteOp.cpp2.05 kB01-12-11 18:36
HelloWorld.upiproj40.80 kB01-12-11 18:36
install.xml380.00 B01-12-11 18:36
TG3AppDllEntry.cpp5.27 kB01-12-11 18:36
TG3AppDllEntry.h1.39 kB01-12-11 18:36
ODSocket.cpp3.69 kB12-01-12 16:37
ODSocket.h1.61 kB12-01-12 13:43
ReadMe.txt1.27 kB10-01-12 16:34
Server.cpp701.00 B14-01-12 18:00
Server.vcproj4.53 kB12-01-12 16:24
Server.vcproj.PCoS-20111206OT.Administrator.user1.39 kB14-01-12 18:40
stdafx.cpp293.00 B10-01-12 16:34
stdafx.h320.00 B10-01-12 16:34
targetver.h765.00 B10-01-12 16:34
Server.sln884.00 B10-01-12 16:35
Server.suo18.00 kB14-01-12 18:40
<application>0.00 B14-01-12 18:39
<application>0.00 B14-01-12 18:39
<lib>0.00 B14-01-12 18:39
<cocos2dx>0.00 B14-01-12 18:39
<cocos2dx>0.00 B14-01-12 18:39
<org>0.00 B14-01-12 18:39
<helloworld>0.00 B14-01-12 18:39
<drawable-hdpi>0.00 B14-01-12 18:39
<drawable-ldpi>0.00 B14-01-12 18:39
<drawable-mdpi>0.00 B14-01-12 18:39
<layout>0.00 B14-01-12 18:39
<values>0.00 B14-01-12 18:39
<org>0.00 B14-01-12 18:39
<Icons>0.00 B14-01-12 18:39
<Icons>0.00 B14-01-12 18:39
<gen>0.00 B14-01-12 18:39
<jni>0.00 B14-01-12 18:39
<res>0.00 B14-01-12 18:39
<src>0.00 B14-01-12 18:39
<sdk1.0>0.00 B14-01-12 18:39
<sdk2.0>0.00 B14-01-12 18:39
<src>0.00 B14-01-12 18:39
<HelloWorld.xcodeproj>0.00 B14-01-12 18:39
<HelloWorld.xcodeproj>0.00 B14-01-12 18:39
<pak>0.00 B14-01-12 18:39
<ChatClient>0.00 B14-01-12 18:41
<airplay>0.00 B14-01-12 18:39
<android>0.00 B14-01-12 18:39
<bada>0.00 B14-01-12 18:39
<Classes>0.00 B14-01-12 18:39
<ios>0.00 B14-01-12 18:39
<iphone>0.00 B14-01-12 18:39
<Linux>0.00 B14-01-12 18:39
<Resource>0.00 B14-01-12 18:39
<win32>0.00 B14-01-12 18:42
<wophone>0.00 B14-01-12 18:39
<Server>0.00 B14-01-12 18:41
<PCClient>0.00 B14-01-12 18:41
<HelloWorld>0.00 B14-01-12 18:39
<PCServer>0.00 B14-01-12 18:41
...
Sponsored links

AppDelegate.cpp (1.05 MB)

Need 2 point
Your Point(s)

Your Point isn't enough.

Get point immediately by PayPal

More(Debit card / Credit card / PayPal Credit / Online Banking)

Submit your source codes. Get more point

LOGIN

Don't have an account? Register now
Need any help?
Mail to: support@codeforge.com

切换到中文版?

CodeForge Chinese Version
CodeForge English Version

Where are you going?

^_^"Oops ...

Sorry!This guy is mysterious, its blog hasn't been opened, try another, please!
OK

Warm tip!

CodeForge to FavoriteFavorite by Ctrl+D