-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
130 changed files
with
7,785 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>HelloWorld</name> | ||
<comment></comment> | ||
<projects> | ||
<project>HelloWorld_dx</project> | ||
<project>HelloWorld_j</project> | ||
</projects> | ||
<buildSpec> | ||
</buildSpec> | ||
<natures> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#include "AppDelegate.h" | ||
|
||
#include "cocos2d.h" | ||
#include "HelloWorldScene.h" | ||
|
||
USING_NS_CC; | ||
|
||
AppDelegate::AppDelegate() | ||
{ | ||
|
||
} | ||
|
||
AppDelegate::~AppDelegate() | ||
{ | ||
} | ||
|
||
bool AppDelegate::applicationDidFinishLaunching() | ||
{ | ||
// initialize director | ||
CCDirector *pDirector = CCDirector::sharedDirector(); | ||
pDirector->setOpenGLView(CCEGLView::sharedOpenGLView()); | ||
|
||
// turn on display FPS | ||
pDirector->setDisplayStats(true); | ||
|
||
// 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(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#ifndef _APP_DELEGATE_H_ | ||
#define _APP_DELEGATE_H_ | ||
|
||
#include "CCApplication.h" | ||
|
||
/** | ||
@brief The cocos2d Application. | ||
The reason for implement as private inheritance is to hide some interface call by CCDirector. | ||
*/ | ||
class AppDelegate : private cocos2d::CCApplication | ||
{ | ||
public: | ||
AppDelegate(); | ||
virtual ~AppDelegate(); | ||
|
||
/** | ||
@brief Implement CCDirector and CCScene init code here. | ||
@return true Initialize success, app continue. | ||
@return false Initialize failed, app terminate. | ||
*/ | ||
virtual bool applicationDidFinishLaunching(); | ||
|
||
/** | ||
@brief The function be called when the application enter background | ||
@param the pointer of the application | ||
*/ | ||
virtual void applicationDidEnterBackground(); | ||
|
||
/** | ||
@brief The function be called when the application enter foreground | ||
@param the pointer of the application | ||
*/ | ||
virtual void applicationWillEnterForeground(); | ||
}; | ||
|
||
#endif // _APP_DELEGATE_H_ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
#include "HelloWorldScene.h" | ||
#include "SimpleAudioEngine.h" | ||
|
||
using namespace cocos2d; | ||
using namespace CocosDenshion; | ||
|
||
CCScene* HelloWorld::scene() | ||
{ | ||
// 'scene' is an autorelease object | ||
CCScene *scene = CCScene::create(); | ||
|
||
// 'layer' is an autorelease object | ||
HelloWorld *layer = HelloWorld::create(); | ||
|
||
// add layer as a child to scene | ||
scene->addChild(layer); | ||
|
||
// return the scene | ||
return scene; | ||
} | ||
|
||
// on "init" you need to initialize your instance | ||
bool HelloWorld::init() | ||
{ | ||
////////////////////////////// | ||
// 1. super init first | ||
if ( !CCLayer::init() ) | ||
{ | ||
return false; | ||
} | ||
|
||
///////////////////////////// | ||
// 2. add a menu item with "X" image, which is clicked to quit the program | ||
// you may modify it. | ||
|
||
// add a "close" icon to exit the progress. it's an autorelease object | ||
CCMenuItemImage *pCloseItem = CCMenuItemImage::create( | ||
"CloseNormal.png", | ||
"CloseSelected.png", | ||
this, | ||
menu_selector(HelloWorld::menuCloseCallback) ); | ||
pCloseItem->setPosition( ccp(CCDirector::sharedDirector()->getWinSize().width - 20, 20) ); | ||
|
||
// create menu, it's an autorelease object | ||
CCMenu* pMenu = CCMenu::create(pCloseItem, NULL); | ||
pMenu->setPosition( CCPointZero ); | ||
this->addChild(pMenu, 1); | ||
|
||
///////////////////////////// | ||
// 3. add your codes below... | ||
|
||
// add a label shows "Hello World" | ||
// create and initialize a label | ||
CCLabelTTF* pLabel = CCLabelTTF::create("Hello World", "Thonburi", 34); | ||
|
||
// ask director the window size | ||
CCSize size = CCDirector::sharedDirector()->getWinSize(); | ||
|
||
// position the label on the center of the screen | ||
pLabel->setPosition( ccp(size.width / 2, size.height - 20) ); | ||
|
||
// add the label as a child to this layer | ||
this->addChild(pLabel, 1); | ||
|
||
// add "HelloWorld" splash screen" | ||
CCSprite* pSprite = CCSprite::create("HelloWorld.png"); | ||
|
||
// position the sprite on the center of the screen | ||
pSprite->setPosition( ccp(size.width/2, size.height/2) ); | ||
|
||
// add the sprite as a child to this layer | ||
this->addChild(pSprite, 0); | ||
|
||
return true; | ||
} | ||
|
||
void HelloWorld::menuCloseCallback(CCObject* pSender) | ||
{ | ||
CCDirector::sharedDirector()->end(); | ||
|
||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) | ||
exit(0); | ||
#endif | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#ifndef __HELLOWORLD_SCENE_H__ | ||
#define __HELLOWORLD_SCENE_H__ | ||
|
||
#include "cocos2d.h" | ||
|
||
class HelloWorld : public cocos2d::CCLayer | ||
{ | ||
public: | ||
// Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone | ||
virtual bool init(); | ||
|
||
// there's no 'id' in cpp, so we recommand to return the exactly class pointer | ||
static cocos2d::CCScene* scene(); | ||
|
||
// a selector callback | ||
void menuCloseCallback(CCObject* pSender); | ||
|
||
// implement the "static node()" method manually | ||
CREATE_FUNC(HelloWorld); | ||
}; | ||
|
||
#endif // __HELLOWORLD_SCENE_H__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# leafsoar 的代码示例 | ||
|
||
源代码路径: ./Classes | ||
|
||
资源文件路径: ./Resources | ||
|
||
详情请见博文 | ||
|
||
Eclipse 组织跨平台开发 Cocos2d-x 游戏 <http://blog.leafsoar.com/archives/2013/04-23-16.html> | ||
|
||
Eclipse Cocos2d-x 开发自动管理 <http://blog.leafsoar.com/archives/2013/04-24-12.html> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> | ||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/> | ||
<classpathentry kind="src" path="gen"/> | ||
<classpathentry kind="output" path="bin/classes"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/gen | ||
/assets | ||
/bin | ||
/libs | ||
/obj |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>HelloWorld_j</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>com.android.ide.eclipse.adt.ApkBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>com.android.ide.eclipse.adt.AndroidNature</nature> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.leafsoar.game" | ||
android:versionCode="1" | ||
android:versionName="1.0"> | ||
|
||
<uses-sdk android:minSdkVersion="8"/> | ||
|
||
<application android:label="@string/app_name" | ||
android:debuggable="true" | ||
android:icon="@drawable/icon"> | ||
|
||
<activity android:name=".HelloWorld" | ||
android:label="@string/app_name" | ||
android:screenOrientation="landscape" | ||
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" | ||
android:configChanges="orientation"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
<supports-screens android:largeScreens="true" | ||
android:smallScreens="true" | ||
android:anyDensity="true" | ||
android:normalScreens="true"/> | ||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# This file is used to override default values used by the Ant build system. | ||
# | ||
# This file must be checked into Version Control Systems, as it is | ||
# integral to the build system of your project. | ||
|
||
# This file is only used by the Ant script. | ||
|
||
# You can use this to override default values such as | ||
# 'source.dir' for the location of your java source folder and | ||
# 'out.dir' for the location of your output folder. | ||
|
||
# You can also use it define how the release builds are signed by declaring | ||
# the following properties: | ||
# 'key.store' for the location of your keystore and | ||
# 'key.alias' for the name of the key to use. | ||
# The password will be asked during the build when you use the 'release' target. | ||
|
Oops, something went wrong.