This commit is contained in:
Ming 2010-11-13 03:40:41 +00:00
parent 416a319344
commit cf6a4fd261
8 changed files with 3776 additions and 0 deletions

View File

@ -0,0 +1,66 @@
/*
* HelloWorld.cpp
* HelloWorld
*
* Created by Walzer on 10-11-12.
* Copyright 2010 __MyCompanyName__. All rights reserved.
*
*/
#include "HelloWorld.h"
using namespace cocos2d;
class MyLayer : public CCLayer {
public:
bool init()
{
if (! CCLayer::init())
{
return false;
}
this->setIsTouchEnabled(true);
return true;
}
void ccTouchesEnded(NSSet *pTouches, UIEvent *pEvent)
{
CCDirector::sharedDirector()->end();
}
LAYER_NODE_FUNC(MyLayer);
};
HelloWorld::HelloWorld()
{
}
bool HelloWorld::initCocos2d()
{
// init director
CCDirector::sharedDirector()->setOpenGLView(new CCXEGLView());
CCDirector::sharedDirector()->setDisplayFPS(true);
// load image texture and get window size
CCTexture2D *pTextrue = CCTextureCache::sharedTextureCache()->addImage("helloworld.png");
CGSize size = CCDirector::sharedDirector()->getWinSize();
// create sprite instance
CCSprite *pSprite = CCSprite::spriteWithTexture(pTextrue);
pSprite->setPosition(CGPoint(size.width / 2, size.height / 2));
// create layer instance
CCLayer *pLayer = MyLayer::node();
pLayer->addChild(pSprite);
// create scene and add layer to scene
CCScene *pScene = CCScene::node();
pScene->addChild(pLayer);
// add scene to director
CCDirector::sharedDirector()->runWithScene(pScene);
return true;
}

View File

@ -0,0 +1,23 @@
/*
* HelloWorld.h
* HelloWorld
*
* Created by Walzer on 10-11-12.
* Copyright 2010 __MyCompanyName__. All rights reserved.
*
*/
#ifndef __HELLOWORLD_H__
#define __HELLOWORLD_H__
#include "cocos2d.h"
class HelloWorld : public cocos2d::CCXApplication {
public:
HelloWorld();
virtual bool initCocos2d();
};
#endif // __HELLOWORLD_H__

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1 @@
ff523c8cfd1e30462a063fec9ef90fabb35fd58d

View File

@ -0,0 +1,14 @@
//
// iphone_testAppDelegate.h
// iphone_test
//
// Created by Walzer on 10-11-10.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//
@interface AppController : NSObject <UIAccelerometerDelegate, UIAlertViewDelegate, UITextFieldDelegate,UIApplicationDelegate> {
UIWindow *window;
}
@end

View File

@ -0,0 +1,98 @@
//
// iphone_testAppDelegate.m
// iphone_test
//
// Created by Walzer on 10-11-10.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "HelloWorldAppDelegate.h"
#import "cocos2d.h"
#import "EAGLView.h"
#import "HelloWorld.h"
@implementation AppController
#pragma mark -
#pragma mark Application lifecycle
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
// Add the view controller's view to the window and display.
window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]];
EAGLView *__glView = [EAGLView viewWithFrame: [window bounds]
pixelFormat: kEAGLColorFormatRGBA8
depthFormat: 0
preserveBackbuffer: NO];
[window addSubview: __glView];
[window makeKeyAndVisible];
HelloWorld app;
app.run();
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application {
/*
Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
*/
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
/*
Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
If your application supports background execution, called instead of applicationWillTerminate: when the user quits.
*/
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
/*
Called as part of transition from the background to the inactive state: here you can undo many of the changes made on entering the background.
*/
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
/*
Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
*/
}
- (void)applicationWillTerminate:(UIApplication *)application {
/*
Called when the application is about to terminate.
See also applicationDidEnterBackground:.
*/
}
#pragma mark -
#pragma mark Memory management
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
/*
Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later.
*/
}
- (void)dealloc {
[super dealloc];
}
@end
int main(int argc, char *argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
UIApplicationMain(argc, argv, nil, @"AppController");
[pool release];
return 0;
}

View File

@ -0,0 +1,8 @@
//
// Prefix header for all source files of the 'HelloWorld' target in the 'HelloWorld' project
//
#ifdef __OBJC__
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#endif