mirror of https://github.com/axmolengine/axmol.git
issue #208
This commit is contained in:
parent
7cadac921c
commit
31809a3774
|
@ -1 +1 @@
|
|||
6a4882425e5bc97c493d65b3d57d7704d7d89b6d
|
||||
dcf33885794fe98f449903755c50a2d7e7e1c42d
|
|
@ -52,14 +52,14 @@ HelloWorld::HelloWorld()
|
|||
{
|
||||
}
|
||||
|
||||
bool HelloWorld::initCocos2d()
|
||||
bool HelloWorld::applicationDidFinishLaunching()
|
||||
{
|
||||
// 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");
|
||||
CCTexture2D *pTextrue = CCTextureCache::sharedTextureCache()->addImage("images/helloworld.png");
|
||||
CGSize size = CCDirector::sharedDirector()->getWinSize();
|
||||
|
||||
// create sprite instance
|
||||
|
|
|
@ -28,10 +28,8 @@
|
|||
|
||||
class HelloWorld : public cocos2d::CCXApplication {
|
||||
public:
|
||||
HelloWorld();
|
||||
|
||||
virtual bool initCocos2d();
|
||||
|
||||
HelloWorld();
|
||||
virtual bool applicationDidFinishLaunching();
|
||||
};
|
||||
|
||||
#endif // __HELLOWORLD_H__
|
||||
|
|
|
@ -39,14 +39,14 @@
|
|||
#define cpfceil ceilf
|
||||
#endif
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
//#if TARGET_OS_IPHONE
|
||||
// CGPoints are structurally the same, and allow
|
||||
// easy interoperability with other iPhone libraries
|
||||
#import <CoreGraphics/CGGeometry.h>
|
||||
typedef CGPoint cpVect;
|
||||
#else
|
||||
//#import <CoreGraphics/CGGeometry.h>
|
||||
//typedef CGPoint cpVect;
|
||||
//#else
|
||||
typedef struct cpVect{cpFloat x,y;} cpVect;
|
||||
#endif
|
||||
//#endif
|
||||
|
||||
typedef unsigned int cpHashValue;
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ THE SOFTWARE.
|
|||
#define CCX_PLATFORM_WIN32
|
||||
#elif defined (_ANDROID)
|
||||
#define CCX_PLATFORM_ANDROID
|
||||
#elif (defined(__IPHONE_2_0) || defined(__IPHONE_2_1) || defined(__IPHONE_2_2) || defined(__IPHONE_3_0) || defined(__IPHONE_3_1) || defined(__IPHONE_3_2) || defined(__IPHONE_4_0))
|
||||
#elif defined (TARGET_OS_IPHONE) || defined(TARGET_IPHONE_SIMULATOR)
|
||||
#define CCX_PLATFORM_IPHONE
|
||||
#endif
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ public:
|
|||
@return true Initialize success, app continue.
|
||||
@return false Initialize failed, app terminate.
|
||||
*/
|
||||
virtual bool initCocos2d() = 0;
|
||||
virtual bool applicationDidFinishLaunching() = 0;
|
||||
|
||||
/**
|
||||
@brief Get status bar rectangle in EGLView window.
|
||||
|
@ -61,7 +61,7 @@ public:
|
|||
@brief Get current applicaiton instance.
|
||||
@return Current application instance pointer.
|
||||
*/
|
||||
static CCXApplication * getSharedApplication();
|
||||
static CCXApplication * sharedApplication();
|
||||
};
|
||||
|
||||
} // end of namespace cocos2d
|
||||
|
|
|
@ -85,14 +85,14 @@ namespace cocos2d {
|
|||
|
||||
void CCXApplication::run()
|
||||
{
|
||||
initCocos2d();
|
||||
applicationDidFinishLaunching();
|
||||
[[CCDirectorCaller sharedDirectorCaller] startMainLoop];
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Implement static class member
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
CCXApplication * CCXApplication::getSharedApplication()
|
||||
CCXApplication * CCXApplication::sharedApplication()
|
||||
{
|
||||
return s_pApplication;
|
||||
}
|
||||
|
|
|
@ -38,9 +38,7 @@ static unsigned char *s_pStrData;
|
|||
|
||||
static void initWithString(const char *content, const char *fontName, float size)
|
||||
{
|
||||
NSUInteger width,
|
||||
height,
|
||||
i;
|
||||
NSUInteger width, height;
|
||||
CGContextRef context;
|
||||
unsigned char* data;
|
||||
CGColorSpaceRef colorSpace;
|
||||
|
@ -51,34 +49,19 @@ static void initWithString(const char *content, const char *fontName, float size
|
|||
NSString *name;
|
||||
|
||||
alignment = UITextAlignmentCenter;
|
||||
string = [NSString stringWithUTF8String:content];
|
||||
//name = [NSString stringWithUTF8String:fontName];
|
||||
name = @"Arial";
|
||||
string = [[NSString alloc]initWithCString:content];
|
||||
name = @"Thonburi";
|
||||
dimensions = [string sizeWithFont:[UIFont fontWithName:name size:size]];
|
||||
|
||||
width = dimensions.width;
|
||||
if((width != 1) && (width & (width - 1))) {
|
||||
i = 1;
|
||||
while(i < width)
|
||||
i *= 2;
|
||||
width = i;
|
||||
}
|
||||
height = dimensions.height;
|
||||
if((height != 1) && (height & (height - 1))) {
|
||||
i = 1;
|
||||
while(i < height)
|
||||
i *= 2;
|
||||
height = i;
|
||||
}
|
||||
|
||||
height = dimensions.height;
|
||||
|
||||
colorSpace = CGColorSpaceCreateDeviceRGB();
|
||||
//data = calloc(height, width);
|
||||
data = new unsigned char[height * width * 4];
|
||||
memset(data, 0, height * width * 4);
|
||||
context = CGBitmapContextCreate(data, width, height, 8, width * 4, colorSpace, kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);
|
||||
CGColorSpaceRelease(colorSpace);
|
||||
|
||||
//CGContextSetGrayFillColor(context, 1.0f, 1.0f);
|
||||
CGContextSetRGBFillColor(context, 1, 1, 1, 1);
|
||||
CGContextTranslateCTM(context, 0.0f, height);
|
||||
CGContextScaleCTM(context, 1.0f, -1.0f); //NOTE: NSString draws in UIKit referential i.e. renders upside-down compared to CGBitmapContext referential
|
||||
|
@ -97,8 +80,8 @@ static void initWithString(const char *content, const char *fontName, float size
|
|||
CGContextRelease(context);
|
||||
|
||||
s_pStrData = data;
|
||||
s_nWidth = width;
|
||||
s_nHeight = height;
|
||||
s_nWidth = dimensions.width;
|
||||
s_nHeight = dimensions.height;
|
||||
}
|
||||
|
||||
namespace cocos2d {
|
||||
|
|
|
@ -54,7 +54,7 @@ static const char* static_fullPathFromRelativePath(const char *pszRelativePath)
|
|||
inDirectory:imageDirectory];
|
||||
if (fullpath == nil)
|
||||
fullpath = relPath;
|
||||
|
||||
const char *temp = [fullpath UTF8String];
|
||||
return [fullpath UTF8String];
|
||||
}
|
||||
|
||||
|
|
|
@ -217,19 +217,9 @@ static bool static_initWithImage(const char* path)
|
|||
|
||||
//CCConfiguration *conf = [CCConfiguration sharedConfiguration];
|
||||
cocos2d::CCConfiguration *conf = cocos2d::CCConfiguration::sharedConfiguration();
|
||||
|
||||
#if CC_TEXTURE_NPOT_SUPPORT
|
||||
//if( [conf supportsNPOT] ) {
|
||||
if (conf->supportsNPOT()) {
|
||||
POTWide = CGImageGetWidth(CGImage);
|
||||
POTHigh = CGImageGetHeight(CGImage);
|
||||
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
POTWide = nextPOT(CGImageGetWidth(CGImage));
|
||||
POTHigh = nextPOT(CGImageGetHeight(CGImage));
|
||||
}
|
||||
|
||||
POTWide = CGImageGetWidth(CGImage);
|
||||
POTHigh = CGImageGetHeight(CGImage);
|
||||
|
||||
unsigned maxTextureSize = conf->getMaxTextureSize();
|
||||
if( POTHigh > maxTextureSize || POTWide > maxTextureSize ) {
|
||||
|
|
|
@ -66,6 +66,7 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved.
|
|||
#import <OpenGLES/EAGLDrawable.h>
|
||||
#import <OpenGLES/ES1/gl.h>
|
||||
#import <OpenGLES/ES1/glext.h>
|
||||
#import <CoreFoundation/CoreFoundation.h>
|
||||
|
||||
#import "ESRenderer.h"
|
||||
|
||||
|
@ -86,6 +87,8 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved.
|
|||
|
||||
CGSize size_;
|
||||
BOOL discardFramebufferSupported_;
|
||||
@private
|
||||
CFMutableDictionaryRef touchesIntergerDict;
|
||||
}
|
||||
|
||||
/** creates an initializes an EAGLView with a frame and 0-bit depth buffer, and a RGB565 color buffer */
|
||||
|
@ -115,11 +118,14 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved.
|
|||
/** OpenGL context */
|
||||
@property(nonatomic,readonly) EAGLContext *context;
|
||||
|
||||
@property(readonly) CFMutableDictionaryRef touchesIntergerDict;
|
||||
|
||||
/** EAGLView uses double-buffer. This method swaps the buffers */
|
||||
-(void) swapBuffers;
|
||||
|
||||
- (CGRect) convertRectFromViewToSurface:(CGRect)rect;
|
||||
- (CGPoint) convertPointFromViewToSurface:(CGPoint)point;
|
||||
- (id) init;
|
||||
|
||||
-(int) getWidth;
|
||||
-(int) getHeight;
|
||||
|
|
|
@ -72,6 +72,7 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved.
|
|||
//CLASS IMPLEMENTATIONS:
|
||||
|
||||
static EAGLView *view;
|
||||
static cocos2d::CCTouch *s_pTouches[4];
|
||||
|
||||
@interface EAGLView (Private)
|
||||
-(BOOL) setupSurface;
|
||||
|
@ -82,6 +83,7 @@ static EAGLView *view;
|
|||
@synthesize surfaceSize=size_;
|
||||
@synthesize pixelFormat=pixelformat_, depthFormat=depthFormat_;
|
||||
@synthesize context=context_;
|
||||
@synthesize touchesIntergerDict;
|
||||
|
||||
+ (Class) layerClass
|
||||
{
|
||||
|
@ -100,7 +102,7 @@ static EAGLView *view;
|
|||
|
||||
+ (id) viewWithFrame:(CGRect)frame pixelFormat:(NSString*)format depthFormat:(GLuint)depth preserveBackbuffer:(BOOL)retained
|
||||
{
|
||||
return [[[self alloc] initWithFrame:frame pixelFormat:format depthFormat:depth preserveBackbuffer:retained] autorelease];
|
||||
return [[[[self alloc] init]initWithFrame:frame pixelFormat:format depthFormat:depth preserveBackbuffer:retained] autorelease];
|
||||
}
|
||||
|
||||
+ (id) sharedEGLView
|
||||
|
@ -108,6 +110,12 @@ static EAGLView *view;
|
|||
return view;
|
||||
}
|
||||
|
||||
- (id) init
|
||||
{
|
||||
touchesIntergerDict = CFDictionaryCreateMutable(kCFAllocatorDefault, 4, NULL, NULL);
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id) initWithFrame:(CGRect)frame
|
||||
{
|
||||
return [self initWithFrame:frame pixelFormat:kEAGLColorFormatRGB565 depthFormat:0 preserveBackbuffer:NO];
|
||||
|
@ -191,6 +199,7 @@ static EAGLView *view;
|
|||
|
||||
- (void) dealloc
|
||||
{
|
||||
CFRelease(touchesIntergerDict);
|
||||
[renderer_ release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
@ -257,14 +266,18 @@ static EAGLView *view;
|
|||
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
cocos2d::NSSet set;
|
||||
int i = 0;
|
||||
for (UITouch *touch in touches) {
|
||||
cocos2d::CCTouch *pCocosTouch = new cocos2d::CCTouch();
|
||||
s_pTouches[i] = new cocos2d::CCTouch();
|
||||
|
||||
float x = [touch locationInView: [touch view]].x;
|
||||
float y = [touch locationInView: [touch view]].y;
|
||||
pCocosTouch->SetTouchInfo(0, x, y);
|
||||
s_pTouches[i] ->SetTouchInfo(0, x, y);
|
||||
|
||||
CFDictionaryAddValue(touchesIntergerDict, touch, [NSNumber numberWithInt:i]);
|
||||
|
||||
set.addObject(pCocosTouch);
|
||||
pCocosTouch->release();
|
||||
set.addObject(s_pTouches[i]);
|
||||
++i;
|
||||
}
|
||||
|
||||
cocos2d::CCDirector::sharedDirector()->getOpenGLView()->touchesBegan(&set);
|
||||
|
@ -274,13 +287,23 @@ static EAGLView *view;
|
|||
{
|
||||
cocos2d::NSSet set;
|
||||
for (UITouch *touch in touches) {
|
||||
cocos2d::CCTouch *pCocosTouch = new cocos2d::CCTouch();
|
||||
NSNumber *index = (NSNumber*)CFDictionaryGetValue(touchesIntergerDict, touch);
|
||||
if (! index) {
|
||||
// if the index doesn't exist, it is an error
|
||||
return;
|
||||
}
|
||||
|
||||
cocos2d::CCTouch *pTouch = s_pTouches[[index intValue]];
|
||||
if (! pTouch) {
|
||||
// if the pTouch is null, it is an error
|
||||
return;
|
||||
}
|
||||
|
||||
float x = [touch locationInView: [touch view]].x;
|
||||
float y = [touch locationInView: [touch view]].y;
|
||||
pCocosTouch->SetTouchInfo(0, x, y);
|
||||
pTouch->SetTouchInfo(0, x, y);
|
||||
|
||||
set.addObject(pCocosTouch);
|
||||
pCocosTouch->release();
|
||||
set.addObject(pTouch);
|
||||
}
|
||||
|
||||
cocos2d::CCDirector::sharedDirector()->getOpenGLView()->touchesMoved(&set);
|
||||
|
@ -290,13 +313,25 @@ static EAGLView *view;
|
|||
{
|
||||
cocos2d::NSSet set;
|
||||
for (UITouch *touch in touches) {
|
||||
cocos2d::CCTouch *pCocosTouch = new cocos2d::CCTouch();
|
||||
NSNumber *index = (NSNumber*)CFDictionaryGetValue(touchesIntergerDict, touch);
|
||||
if (! index) {
|
||||
// if the index doesn't exist, it is an error
|
||||
return;
|
||||
}
|
||||
|
||||
cocos2d::CCTouch *pTouch = s_pTouches[[index intValue]];
|
||||
if (! pTouch) {
|
||||
// if the pTouch is null, it is an error
|
||||
return;
|
||||
}
|
||||
|
||||
float x = [touch locationInView: [touch view]].x;
|
||||
float y = [touch locationInView: [touch view]].y;
|
||||
pCocosTouch->SetTouchInfo(0, x, y);
|
||||
pTouch->SetTouchInfo(0, x, y);
|
||||
|
||||
set.addObject(pCocosTouch);
|
||||
pCocosTouch->release();
|
||||
set.addObject(pTouch);
|
||||
CFDictionaryRemoveValue(touchesIntergerDict, touch);
|
||||
pTouch->release();
|
||||
}
|
||||
|
||||
cocos2d::CCDirector::sharedDirector()->getOpenGLView()->touchesEnded(&set);
|
||||
|
@ -305,13 +340,25 @@ static EAGLView *view;
|
|||
{
|
||||
cocos2d::NSSet set;
|
||||
for (UITouch *touch in touches) {
|
||||
cocos2d::CCTouch *pCocosTouch = new cocos2d::CCTouch();
|
||||
NSNumber *index = (NSNumber*)CFDictionaryGetValue(touchesIntergerDict, touch);
|
||||
if (! index) {
|
||||
// if the index doesn't exist, it is an error
|
||||
return;
|
||||
}
|
||||
|
||||
cocos2d::CCTouch *pTouch = s_pTouches[[index intValue]];
|
||||
if (! pTouch) {
|
||||
// if the pTouch is null, it is an error
|
||||
return;
|
||||
}
|
||||
|
||||
float x = [touch locationInView: [touch view]].x;
|
||||
float y = [touch locationInView: [touch view]].y;
|
||||
pCocosTouch->SetTouchInfo(0, x, y);
|
||||
pTouch->SetTouchInfo(0, x, y);
|
||||
|
||||
set.addObject(pCocosTouch);
|
||||
pCocosTouch->release();
|
||||
set.addObject(pTouch);
|
||||
CFDictionaryRemoveValue(touchesIntergerDict, touch);
|
||||
pTouch->release();
|
||||
}
|
||||
|
||||
cocos2d::CCDirector::sharedDirector()->getOpenGLView()->touchesCancelled(&set);
|
||||
|
|
|
@ -296,10 +296,7 @@ bool CCTexture2D::initPremultipliedATextureWithImage(UIImage *image, unsigned in
|
|||
|
||||
tempData = (void*)(image->getData());
|
||||
NSAssert(tempData != NULL, "NULL image data.");
|
||||
#ifdef CCX_PLATFORM_IPHONE
|
||||
data = new UINT8[POTHigh * POTWide * 4];
|
||||
memcpy(data, tempData, POTHigh * POTWide * 4);
|
||||
#else
|
||||
|
||||
if(image->width() == POTWide && image->height() == POTHigh)
|
||||
{
|
||||
data = new UINT8[POTHigh * POTWide * 4];
|
||||
|
@ -318,7 +315,7 @@ bool CCTexture2D::initPremultipliedATextureWithImage(UIImage *image, unsigned in
|
|||
memcpy(pTargetData+POTWide*4*y, pPixelData+(image->width())*4*y, (image->width())*4);
|
||||
}
|
||||
}
|
||||
#endif // IPHONE
|
||||
|
||||
break;
|
||||
case kCCTexture2DPixelFormat_RGB888:
|
||||
tempData = (void*)(image->getData());
|
||||
|
|
|
@ -26,6 +26,8 @@ bool AppDelegate::applicationDidFinishLaunching()
|
|||
#elif defined(CCX_PLATFORM_WIN32)
|
||||
if (!(m_pMainWnd = new CCXEGLView()) ||
|
||||
! m_pMainWnd->Create(L"cocos2d-win32", 320, 480) )
|
||||
#elif defined(CCX_PLATFORM_IPHONE)
|
||||
if (!(m_pMainWnd = new CCXEGLView()))
|
||||
#else
|
||||
#error
|
||||
#endif
|
||||
|
@ -39,7 +41,7 @@ bool AppDelegate::applicationDidFinishLaunching()
|
|||
pDirector->setOpenGLView(m_pMainWnd);
|
||||
pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft);
|
||||
// pDirector->setDeviceOrientation(kCCDeviceOrientationPortrait);
|
||||
pDirector->setDisplayFPS(true);
|
||||
// pDirector->setDisplayFPS(true);
|
||||
|
||||
#if defined(CCX_PLATFORM_UPHONE)
|
||||
// set the resource path
|
||||
|
@ -50,7 +52,7 @@ bool AppDelegate::applicationDidFinishLaunching()
|
|||
// SHOW SPLASH SCREEN
|
||||
|
||||
// load background image texture and get window size
|
||||
CCTexture2D * pSplashTexture = CCTextureCache::sharedTextureCache()->addImage("Images/HelloWorld.png");
|
||||
CCTexture2D * pSplashTexture = CCTextureCache::sharedTextureCache()->addImage("b1.png");
|
||||
CGSize size = CCDirector::sharedDirector()->getWinSize();
|
||||
|
||||
// splash sprite
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
//
|
||||
// iphoneAppDelegate.h
|
||||
// iphone
|
||||
//
|
||||
// Created by Walzer on 10-11-16.
|
||||
// Copyright 2010 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface AppController : NSObject <UIApplicationDelegate> {
|
||||
UIWindow *window;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
@ -0,0 +1,96 @@
|
|||
//
|
||||
// iphoneAppDelegate.m
|
||||
// iphone
|
||||
//
|
||||
// Created by Walzer on 10-11-16.
|
||||
// Copyright 2010 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
#import "iphoneAppDelegate.h"
|
||||
|
||||
#import "EAGLView.h"
|
||||
#import "cocos2d.h"
|
||||
#import "AppDelegate.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];
|
||||
|
||||
[[UIApplication sharedApplication] setStatusBarHidden:true];
|
||||
|
||||
AppDelegate 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 {
|
||||
[window release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
||||
@end
|
|
@ -0,0 +1 @@
|
|||
7b21db099fbaa9489431748794fa4df2593ac7e3
|
|
@ -0,0 +1,8 @@
|
|||
//
|
||||
// Prefix header for all source files of the 'iphone' target in the 'iphone' project
|
||||
//
|
||||
|
||||
#ifdef __OBJC__
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
#endif
|
|
@ -0,0 +1,17 @@
|
|||
//
|
||||
// main.m
|
||||
// iphone
|
||||
//
|
||||
// Created by Walzer on 10-11-16.
|
||||
// Copyright 2010 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
|
||||
int retVal = UIApplicationMain(argc, argv, nil, @"AppController");
|
||||
[pool release];
|
||||
return retVal;
|
||||
}
|
|
@ -1,20 +1,20 @@
|
|||
#include "Box2dView.h"
|
||||
#include "GLES-Render.h"
|
||||
#include "Test.h"
|
||||
|
||||
#include "Box2dView.h"
|
||||
#include "GLES-Render.h"
|
||||
#include "Test.h"
|
||||
|
||||
#define kAccelerometerFrequency 30
|
||||
#define FRAMES_BETWEEN_PRESSES_FOR_DOUBLE_CLICK 10
|
||||
|
||||
extern int g_totalEntries;
|
||||
extern int g_totalEntries;
|
||||
|
||||
Settings settings;
|
||||
|
||||
enum
|
||||
{
|
||||
kTagBox2DNode,
|
||||
};
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
// MenuLayer
|
||||
|
@ -25,16 +25,16 @@ enum
|
|||
IDC_NEXT = 100,
|
||||
IDC_BACK,
|
||||
IDC_RESTART
|
||||
};
|
||||
|
||||
MenuLayer::MenuLayer(void)
|
||||
{
|
||||
}
|
||||
|
||||
MenuLayer::~MenuLayer(void)
|
||||
{
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
MenuLayer::MenuLayer(void)
|
||||
{
|
||||
}
|
||||
|
||||
MenuLayer::~MenuLayer(void)
|
||||
{
|
||||
}
|
||||
|
||||
MenuLayer* MenuLayer::menuWithEntryID(int entryId)
|
||||
{
|
||||
MenuLayer* pLayer = new MenuLayer();
|
||||
|
@ -75,7 +75,7 @@ bool MenuLayer::initWithEntryID(int entryId)
|
|||
|
||||
addChild(menu, 1);
|
||||
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
void MenuLayer::restartCallback(NSObject* sender)
|
||||
|
@ -145,17 +145,17 @@ void MenuLayer::ccTouchMoved(CCTouch* touch, UIEvent* event)
|
|||
CCNode *node = getChildByTag( kTagBox2DNode );
|
||||
CGPoint currentPos = node->getPosition();
|
||||
node->setPosition( ccpAdd(currentPos, diff) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
// Box2DView
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
Box2DView::Box2DView(void)
|
||||
{
|
||||
}
|
||||
|
||||
Box2DView::Box2DView(void)
|
||||
{
|
||||
}
|
||||
|
||||
Box2DView* Box2DView::viewWithEntryID(int entryId)
|
||||
{
|
||||
Box2DView* pView = new Box2DView();
|
||||
|
@ -175,7 +175,7 @@ bool Box2DView::initWithEntryID(int entryId)
|
|||
m_entry = g_testEntries + entryId;
|
||||
m_test = m_entry->createFcn();
|
||||
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string Box2DView::title()
|
||||
|
@ -192,19 +192,19 @@ void Box2DView::draw()
|
|||
{
|
||||
CCLayer::draw();
|
||||
|
||||
// Default GL states: GL_TEXTURE_2D, GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY
|
||||
// Needed states: GL_VERTEX_ARRAY,
|
||||
// Unneeded states: GL_TEXTURE_2D, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
|
||||
// Default GL states: GL_TEXTURE_2D, GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY
|
||||
// Needed states: GL_VERTEX_ARRAY,
|
||||
// Unneeded states: GL_TEXTURE_2D, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
|
||||
m_test->m_world->DrawDebugData();
|
||||
|
||||
// restore default GL states
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
|
||||
// restore default GL states
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
}
|
||||
|
||||
Box2DView::~Box2DView()
|
||||
|
@ -247,14 +247,14 @@ void Box2DView::ccTouchEnded(CCTouch* touch, UIEvent* event)
|
|||
m_test->MouseUp(b2Vec2(nodePosition.x,nodePosition.y));
|
||||
}
|
||||
|
||||
// void Box2DView::accelerometer(UIAccelerometer* accelerometer, UIAcceleration* acceleration)
|
||||
// {
|
||||
// //// Only run for valid values
|
||||
// //if (acceleration.y!=0 && acceleration.x!=0)
|
||||
// //{
|
||||
// // if (test) test->SetGravity((float)-acceleration.y,(float)acceleration.x);
|
||||
// //}
|
||||
// }
|
||||
// void Box2DView::accelerometer(UIAccelerometer* accelerometer, UIAcceleration* acceleration)
|
||||
// {
|
||||
// //// Only run for valid values
|
||||
// //if (acceleration.y!=0 && acceleration.x!=0)
|
||||
// //{
|
||||
// // if (test) test->SetGravity((float)-acceleration.y,(float)acceleration.x);
|
||||
// //}
|
||||
// }
|
||||
|
||||
|
||||
void Box2dTestBedScene::runThisTest()
|
||||
|
|
|
@ -417,7 +417,7 @@ void ChipmunkTestScene::runThisTest()
|
|||
void ChipmunkTestLayer::init()
|
||||
{
|
||||
CCLayer::init();
|
||||
CCLayer::setIsTouchEnabled(TRUE);
|
||||
CCLayer::setIsTouchEnabled(true);
|
||||
|
||||
demoIndex = 0;
|
||||
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
#include "ClickAndMoveTest.h"
|
||||
#include "../testResource.h"
|
||||
|
||||
#include "ClickAndMoveTest.h"
|
||||
#include "../testResource.h"
|
||||
|
||||
enum
|
||||
{
|
||||
kTagSprite = 1,
|
||||
};
|
||||
|
||||
void ClickAndMoveTestScene::runThisTest()
|
||||
{
|
||||
CCLayer* pLayer = new MainLayer();
|
||||
pLayer->autorelease();
|
||||
|
||||
addChild(pLayer);
|
||||
CCDirector::sharedDirector()->replaceScene(this);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
void ClickAndMoveTestScene::runThisTest()
|
||||
{
|
||||
CCLayer* pLayer = new MainLayer();
|
||||
pLayer->autorelease();
|
||||
|
||||
addChild(pLayer);
|
||||
CCDirector::sharedDirector()->replaceScene(this);
|
||||
}
|
||||
|
||||
MainLayer::MainLayer()
|
||||
{
|
||||
setIsTouchEnabled(true);
|
||||
|
@ -34,9 +34,9 @@ MainLayer::MainLayer()
|
|||
CCFadeIn::actionWithDuration(1),
|
||||
CCFadeOut::actionWithDuration(1),
|
||||
NULL) )
|
||||
) );
|
||||
}
|
||||
|
||||
) );
|
||||
}
|
||||
|
||||
void MainLayer::ccTouchesEnded(NSSet *pTouches, UIEvent *pEvent)
|
||||
{
|
||||
NSSetIterator it = pTouches->begin();
|
||||
|
@ -55,9 +55,9 @@ void MainLayer::ccTouchesEnded(NSSet *pTouches, UIEvent *pEvent)
|
|||
if( a < 0 )
|
||||
{
|
||||
if( o < 0 )
|
||||
at = 180 + abs(at);
|
||||
at = 180 + std::abs((int)at);
|
||||
else
|
||||
at = 180 - abs(at);
|
||||
at = 180 - std::abs((int)at);
|
||||
}
|
||||
|
||||
s->runAction( CCRotateTo::actionWithDuration(1, at) );
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
#include "LayerTest.h"
|
||||
#include "../testResource.h"
|
||||
|
||||
#include "LayerTest.h"
|
||||
#include "../testResource.h"
|
||||
|
||||
enum
|
||||
{
|
||||
kTagLayer = 1,
|
||||
};
|
||||
|
||||
static int sceneIdx = -1;
|
||||
|
||||
static int sceneIdx = -1;
|
||||
|
||||
#define MAX_LAYER 3
|
||||
|
||||
CCLayer* createTestLayer(int nIndex)
|
||||
|
@ -52,22 +52,22 @@ CCLayer* restartTestAction()
|
|||
pLayer->autorelease();
|
||||
|
||||
return pLayer;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
// LayerTest
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
|
||||
LayerTest::LayerTest(void)
|
||||
{
|
||||
}
|
||||
|
||||
LayerTest::~LayerTest(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
LayerTest::LayerTest(void)
|
||||
{
|
||||
}
|
||||
|
||||
LayerTest::~LayerTest(void)
|
||||
{
|
||||
}
|
||||
|
||||
std::string LayerTest::title()
|
||||
{
|
||||
return "No title";
|
||||
|
@ -153,7 +153,7 @@ void LayerTest1::updateSize(CCTouch*touch)
|
|||
|
||||
CGSize s = CCDirector::sharedDirector()->getWinSize();
|
||||
|
||||
CGSize newSize = CGSizeMake( abs( touchLocation.x - s.width/2)*2, abs(touchLocation.y - s.height/2)*2);
|
||||
CGSize newSize = CGSizeMake( std::abs( (int)(touchLocation.x - s.width/2)*2), abs((int)(touchLocation.y - s.height/2)*2));
|
||||
|
||||
CCColorLayer* l = (CCColorLayer*) getChildByTag(kTagLayer);
|
||||
|
||||
|
@ -224,56 +224,56 @@ std::string LayerTest2::title()
|
|||
//
|
||||
//------------------------------------------------------------------
|
||||
|
||||
LayerTestBlend::LayerTestBlend()
|
||||
{
|
||||
CGSize s = CCDirector::sharedDirector()->getWinSize();
|
||||
CCColorLayer* layer1 = CCColorLayer::layerWithColor( ccc4(255, 255, 255, 80) );
|
||||
|
||||
CCSprite* sister1 = CCSprite::spriteWithFile(s_pPathSister1);
|
||||
CCSprite* sister2 = CCSprite::spriteWithFile(s_pPathSister2);
|
||||
|
||||
addChild(sister1);
|
||||
addChild(sister2);
|
||||
addChild(layer1, 100, kTagLayer);
|
||||
|
||||
sister1->setPosition( CGPointMake( 160, s.height/2) );
|
||||
sister2->setPosition( CGPointMake( 320, s.height/2) );
|
||||
|
||||
schedule( schedule_selector(LayerTestBlend::newBlend), 1.0f);
|
||||
}
|
||||
|
||||
void LayerTestBlend::newBlend(ccTime dt)
|
||||
{
|
||||
CCColorLayer *layer = (CCColorLayer*)getChildByTag(kTagLayer);
|
||||
|
||||
GLenum src;
|
||||
GLenum dst;
|
||||
|
||||
if( layer->getBlendFunc().dst == GL_ZERO )
|
||||
{
|
||||
src = CC_BLEND_SRC;
|
||||
dst = CC_BLEND_DST;
|
||||
}
|
||||
else
|
||||
{
|
||||
src = GL_ONE_MINUS_DST_COLOR;
|
||||
dst = GL_ZERO;
|
||||
}
|
||||
|
||||
ccBlendFunc bf = {src, dst};
|
||||
layer->setBlendFunc( bf );
|
||||
}
|
||||
|
||||
|
||||
std::string LayerTestBlend::title()
|
||||
{
|
||||
return "ColorLayer: blend";
|
||||
}
|
||||
|
||||
void LayerTestScene::runThisTest()
|
||||
{
|
||||
CCLayer* pLayer = nextTestAction();
|
||||
addChild(pLayer);
|
||||
|
||||
CCDirector::sharedDirector()->replaceScene(this);
|
||||
}
|
||||
LayerTestBlend::LayerTestBlend()
|
||||
{
|
||||
CGSize s = CCDirector::sharedDirector()->getWinSize();
|
||||
CCColorLayer* layer1 = CCColorLayer::layerWithColor( ccc4(255, 255, 255, 80) );
|
||||
|
||||
CCSprite* sister1 = CCSprite::spriteWithFile(s_pPathSister1);
|
||||
CCSprite* sister2 = CCSprite::spriteWithFile(s_pPathSister2);
|
||||
|
||||
addChild(sister1);
|
||||
addChild(sister2);
|
||||
addChild(layer1, 100, kTagLayer);
|
||||
|
||||
sister1->setPosition( CGPointMake( 160, s.height/2) );
|
||||
sister2->setPosition( CGPointMake( 320, s.height/2) );
|
||||
|
||||
schedule( schedule_selector(LayerTestBlend::newBlend), 1.0f);
|
||||
}
|
||||
|
||||
void LayerTestBlend::newBlend(ccTime dt)
|
||||
{
|
||||
CCColorLayer *layer = (CCColorLayer*)getChildByTag(kTagLayer);
|
||||
|
||||
GLenum src;
|
||||
GLenum dst;
|
||||
|
||||
if( layer->getBlendFunc().dst == GL_ZERO )
|
||||
{
|
||||
src = CC_BLEND_SRC;
|
||||
dst = CC_BLEND_DST;
|
||||
}
|
||||
else
|
||||
{
|
||||
src = GL_ONE_MINUS_DST_COLOR;
|
||||
dst = GL_ZERO;
|
||||
}
|
||||
|
||||
ccBlendFunc bf = {src, dst};
|
||||
layer->setBlendFunc( bf );
|
||||
}
|
||||
|
||||
|
||||
std::string LayerTestBlend::title()
|
||||
{
|
||||
return "ColorLayer: blend";
|
||||
}
|
||||
|
||||
void LayerTestScene::runThisTest()
|
||||
{
|
||||
CCLayer* pLayer = nextTestAction();
|
||||
addChild(pLayer);
|
||||
|
||||
CCDirector::sharedDirector()->replaceScene(this);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef _MENU_TEST_H_
|
||||
#define _MENU_TEST_H_
|
||||
#ifndef _MENU_TEST_H_
|
||||
#define _MENU_TEST_H_
|
||||
|
||||
////----#include "cocos2d.h"
|
||||
#include "../testBasic.h"
|
||||
|
@ -11,37 +11,37 @@ protected:
|
|||
|
||||
public:
|
||||
MenuLayer1(void);
|
||||
~MenuLayer1();
|
||||
~MenuLayer1();
|
||||
|
||||
public:
|
||||
void menuCallback(NSObject* pSender);
|
||||
void menuCallbackConfig(NSObject* pSender);
|
||||
void menuCallbackDisabled(NSObject* pSender);
|
||||
void menuCallbackEnable(NSObject* pSender);
|
||||
void menuCallback2(NSObject* pSender);
|
||||
void onQuit(NSObject* pSender);
|
||||
|
||||
void menuCallback(NSObject* pSender);
|
||||
void menuCallbackConfig(NSObject* pSender);
|
||||
void menuCallbackDisabled(NSObject* pSender);
|
||||
void menuCallbackEnable(NSObject* pSender);
|
||||
void menuCallback2(NSObject* pSender);
|
||||
void onQuit(NSObject* pSender);
|
||||
|
||||
//CREATE_NODE(MenuLayer1);
|
||||
};
|
||||
|
||||
class MenuLayer2 : public CCLayer
|
||||
{
|
||||
protected:
|
||||
CGPoint m_centeredMenu;
|
||||
BOOL m_alignedH;
|
||||
CGPoint m_centeredMenu;
|
||||
bool m_alignedH;
|
||||
|
||||
void alignMenusH();
|
||||
void alignMenusV();
|
||||
void alignMenusH();
|
||||
void alignMenusV();
|
||||
|
||||
public:
|
||||
MenuLayer2(void);
|
||||
~MenuLayer2();
|
||||
~MenuLayer2();
|
||||
|
||||
public:
|
||||
void menuCallback(NSObject* pSender);
|
||||
void menuCallbackOpacity(NSObject* pSender);
|
||||
void menuCallbackAlign(NSObject* pSender);
|
||||
|
||||
void menuCallback(NSObject* pSender);
|
||||
void menuCallbackOpacity(NSObject* pSender);
|
||||
void menuCallbackAlign(NSObject* pSender);
|
||||
|
||||
//CREATE_NODE(MenuLayer2);
|
||||
};
|
||||
|
||||
|
@ -52,13 +52,13 @@ protected:
|
|||
|
||||
public:
|
||||
MenuLayer3(void);
|
||||
~MenuLayer3();
|
||||
~MenuLayer3();
|
||||
|
||||
public:
|
||||
void menuCallback(NSObject* pSender);
|
||||
void menuCallback2(NSObject* pSender);
|
||||
void menuCallback3(NSObject* pSender);
|
||||
|
||||
void menuCallback(NSObject* pSender);
|
||||
void menuCallback2(NSObject* pSender);
|
||||
void menuCallback3(NSObject* pSender);
|
||||
|
||||
//CREATE_NODE(MenuLayer3);
|
||||
};
|
||||
|
||||
|
@ -66,12 +66,12 @@ class MenuLayer4 : public CCLayer
|
|||
{
|
||||
public:
|
||||
MenuLayer4(void);
|
||||
~MenuLayer4();
|
||||
~MenuLayer4();
|
||||
|
||||
public:
|
||||
void menuCallback(NSObject* pSender);
|
||||
void backCallback(NSObject* pSender);
|
||||
|
||||
void menuCallback(NSObject* pSender);
|
||||
void backCallback(NSObject* pSender);
|
||||
|
||||
//CREATE_NODE(MenuLayer4);
|
||||
};
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef _SPRITE_TEST_H_
|
||||
#define _SPRITE_TEST_H_
|
||||
#ifndef _SPRITE_TEST_H_
|
||||
#define _SPRITE_TEST_H_
|
||||
|
||||
#include "cocos2d.h"
|
||||
#include "../testBasic.h"
|
||||
|
@ -13,337 +13,337 @@ public:
|
|||
SpriteTestDemo(void);
|
||||
~SpriteTestDemo(void);
|
||||
|
||||
virtual std::string title();
|
||||
virtual std::string subtitle();
|
||||
virtual void onEnter();
|
||||
|
||||
void restartCallback(NSObject* pSender);
|
||||
void nextCallback(NSObject* pSender);
|
||||
void backCallback(NSObject* pSender);
|
||||
virtual std::string title();
|
||||
virtual std::string subtitle();
|
||||
virtual void onEnter();
|
||||
|
||||
void restartCallback(NSObject* pSender);
|
||||
void nextCallback(NSObject* pSender);
|
||||
void backCallback(NSObject* pSender);
|
||||
};
|
||||
|
||||
class Sprite1 : public SpriteTestDemo
|
||||
{
|
||||
public:
|
||||
Sprite1();
|
||||
virtual std::string title();
|
||||
|
||||
void addNewSpriteWithCoords(CGPoint p);
|
||||
void ccTouchesEnded(NSSet* touches, UIEvent* event);
|
||||
Sprite1();
|
||||
virtual std::string title();
|
||||
|
||||
void addNewSpriteWithCoords(CGPoint p);
|
||||
void ccTouchesEnded(NSSet* touches, UIEvent* event);
|
||||
};
|
||||
|
||||
class SpriteSheet1: public SpriteTestDemo
|
||||
{
|
||||
public:
|
||||
SpriteSheet1();
|
||||
void addNewSpriteWithCoords(CGPoint p);
|
||||
virtual void ccTouchesEnded(NSSet* touches, UIEvent* event);
|
||||
virtual std::string title();
|
||||
SpriteSheet1();
|
||||
void addNewSpriteWithCoords(CGPoint p);
|
||||
virtual void ccTouchesEnded(NSSet* touches, UIEvent* event);
|
||||
virtual std::string title();
|
||||
};
|
||||
|
||||
class SpriteColorOpacity : public SpriteTestDemo
|
||||
{
|
||||
public:
|
||||
SpriteColorOpacity();
|
||||
void removeAndAddSprite(ccTime dt);
|
||||
virtual std::string title();
|
||||
SpriteColorOpacity();
|
||||
void removeAndAddSprite(ccTime dt);
|
||||
virtual std::string title();
|
||||
};
|
||||
|
||||
class SpriteSheetColorOpacity : public SpriteTestDemo
|
||||
{
|
||||
public:
|
||||
SpriteSheetColorOpacity();
|
||||
void removeAndAddSprite(ccTime dt);
|
||||
virtual std::string title();
|
||||
SpriteSheetColorOpacity();
|
||||
void removeAndAddSprite(ccTime dt);
|
||||
virtual std::string title();
|
||||
};
|
||||
|
||||
class SpriteZOrder : public SpriteTestDemo
|
||||
{
|
||||
int m_dir;
|
||||
public:
|
||||
SpriteZOrder();
|
||||
void reorderSprite(ccTime dt);
|
||||
virtual std::string title();
|
||||
SpriteZOrder();
|
||||
void reorderSprite(ccTime dt);
|
||||
virtual std::string title();
|
||||
};
|
||||
|
||||
class SpriteSheetZOrder: public SpriteTestDemo
|
||||
{
|
||||
int m_dir;
|
||||
public:
|
||||
SpriteSheetZOrder();
|
||||
void reorderSprite(ccTime dt);
|
||||
virtual std::string title();
|
||||
SpriteSheetZOrder();
|
||||
void reorderSprite(ccTime dt);
|
||||
virtual std::string title();
|
||||
};
|
||||
|
||||
class SpriteSheetReorder : public SpriteTestDemo
|
||||
{
|
||||
public:
|
||||
SpriteSheetReorder();
|
||||
virtual std::string title();
|
||||
std::string subtitle();
|
||||
SpriteSheetReorder();
|
||||
virtual std::string title();
|
||||
std::string subtitle();
|
||||
};
|
||||
|
||||
class SpriteSheetReorderIssue744: public SpriteTestDemo
|
||||
{
|
||||
public:
|
||||
SpriteSheetReorderIssue744();
|
||||
virtual std::string title();
|
||||
std::string subtitle();
|
||||
SpriteSheetReorderIssue744();
|
||||
virtual std::string title();
|
||||
std::string subtitle();
|
||||
};
|
||||
|
||||
class SpriteZVertex: public SpriteTestDemo
|
||||
{
|
||||
int m_dir;
|
||||
int m_dir;
|
||||
float m_time;
|
||||
public:
|
||||
virtual void onEnter();
|
||||
virtual void onExit();
|
||||
SpriteZVertex();
|
||||
virtual std::string title();
|
||||
virtual void onEnter();
|
||||
virtual void onExit();
|
||||
SpriteZVertex();
|
||||
virtual std::string title();
|
||||
};
|
||||
|
||||
class SpriteSheetZVertex: public SpriteTestDemo
|
||||
{
|
||||
int m_dir;
|
||||
int m_dir;
|
||||
float m_time;
|
||||
public:
|
||||
virtual void onEnter();
|
||||
virtual void onExit();
|
||||
SpriteSheetZVertex();
|
||||
virtual std::string title();
|
||||
virtual void onEnter();
|
||||
virtual void onExit();
|
||||
SpriteSheetZVertex();
|
||||
virtual std::string title();
|
||||
};
|
||||
|
||||
class SpriteAnchorPoint : public SpriteTestDemo
|
||||
{
|
||||
public:
|
||||
SpriteAnchorPoint();
|
||||
virtual std::string title();
|
||||
SpriteAnchorPoint();
|
||||
virtual std::string title();
|
||||
};
|
||||
|
||||
class SpriteSheetAnchorPoint : public SpriteTestDemo
|
||||
{
|
||||
public:
|
||||
SpriteSheetAnchorPoint();
|
||||
virtual std::string title();
|
||||
SpriteSheetAnchorPoint();
|
||||
virtual std::string title();
|
||||
};
|
||||
|
||||
class Sprite6 : public SpriteTestDemo
|
||||
{
|
||||
public:
|
||||
Sprite6();
|
||||
virtual std::string title();
|
||||
Sprite6();
|
||||
virtual std::string title();
|
||||
};
|
||||
|
||||
class SpriteFlip : public SpriteTestDemo
|
||||
{
|
||||
public:
|
||||
SpriteFlip();
|
||||
void flipSprites(ccTime dt);
|
||||
virtual std::string title();
|
||||
SpriteFlip();
|
||||
void flipSprites(ccTime dt);
|
||||
virtual std::string title();
|
||||
};
|
||||
|
||||
class SpriteSheetFlip : public SpriteTestDemo
|
||||
{
|
||||
public:
|
||||
SpriteSheetFlip();
|
||||
void flipSprites(ccTime dt);
|
||||
virtual std::string title();
|
||||
SpriteSheetFlip();
|
||||
void flipSprites(ccTime dt);
|
||||
virtual std::string title();
|
||||
};
|
||||
|
||||
class SpriteAliased : public SpriteTestDemo
|
||||
{
|
||||
public:
|
||||
SpriteAliased();
|
||||
virtual void onEnter();
|
||||
virtual void onExit();
|
||||
virtual std::string title();
|
||||
SpriteAliased();
|
||||
virtual void onEnter();
|
||||
virtual void onExit();
|
||||
virtual std::string title();
|
||||
};
|
||||
|
||||
class SpriteSheetAliased : public SpriteTestDemo
|
||||
{
|
||||
public:
|
||||
SpriteSheetAliased();
|
||||
virtual void onEnter();
|
||||
virtual void onExit();
|
||||
virtual std::string title();
|
||||
SpriteSheetAliased();
|
||||
virtual void onEnter();
|
||||
virtual void onExit();
|
||||
virtual std::string title();
|
||||
};
|
||||
|
||||
class SpriteNewTexture : public SpriteTestDemo
|
||||
{
|
||||
BOOL m_usingTexture1;
|
||||
CCTexture2D* m_texture1;
|
||||
bool m_usingTexture1;
|
||||
CCTexture2D* m_texture1;
|
||||
CCTexture2D* m_texture2;
|
||||
|
||||
public:
|
||||
SpriteNewTexture();
|
||||
virtual ~SpriteNewTexture();
|
||||
void addNewSprite();
|
||||
void ccTouchesEnded(NSSet* touches, UIEvent* event);
|
||||
virtual std::string title();
|
||||
SpriteNewTexture();
|
||||
virtual ~SpriteNewTexture();
|
||||
void addNewSprite();
|
||||
void ccTouchesEnded(NSSet* touches, UIEvent* event);
|
||||
virtual std::string title();
|
||||
};
|
||||
|
||||
class SpriteSheetNewTexture : public SpriteTestDemo
|
||||
{
|
||||
CCTexture2D* m_texture1;
|
||||
CCTexture2D* m_texture1;
|
||||
CCTexture2D* m_texture2;
|
||||
|
||||
public:
|
||||
SpriteSheetNewTexture();
|
||||
virtual ~SpriteSheetNewTexture();
|
||||
void addNewSprite();
|
||||
void ccTouchesEnded(NSSet* touches, UIEvent* event);
|
||||
virtual std::string title();
|
||||
SpriteSheetNewTexture();
|
||||
virtual ~SpriteSheetNewTexture();
|
||||
void addNewSprite();
|
||||
void ccTouchesEnded(NSSet* touches, UIEvent* event);
|
||||
virtual std::string title();
|
||||
};
|
||||
|
||||
class SpriteFrameTest: public SpriteTestDemo
|
||||
{
|
||||
public:
|
||||
SpriteFrameTest();
|
||||
~SpriteFrameTest();
|
||||
virtual void onExit();
|
||||
virtual std::string title();
|
||||
virtual std::string subtitle();
|
||||
|
||||
void startIn05Secs(ccTime dt);
|
||||
void flipSprites(ccTime dt);
|
||||
private:
|
||||
SpriteFrameTest();
|
||||
~SpriteFrameTest();
|
||||
virtual void onExit();
|
||||
virtual std::string title();
|
||||
virtual std::string subtitle();
|
||||
|
||||
void startIn05Secs(ccTime dt);
|
||||
void flipSprites(ccTime dt);
|
||||
private:
|
||||
CCSprite *m_pSprite1;
|
||||
CCSprite *m_pSprite2;
|
||||
int m_nCounter;
|
||||
int m_nCounter;
|
||||
};
|
||||
|
||||
class SpriteOffsetAnchorRotation: public SpriteTestDemo
|
||||
{
|
||||
public:
|
||||
SpriteOffsetAnchorRotation();
|
||||
virtual void onExit();
|
||||
virtual std::string title();
|
||||
SpriteOffsetAnchorRotation();
|
||||
virtual void onExit();
|
||||
virtual std::string title();
|
||||
};
|
||||
|
||||
class SpriteSheetOffsetAnchorRotation: public SpriteTestDemo
|
||||
{
|
||||
public:
|
||||
SpriteSheetOffsetAnchorRotation();
|
||||
virtual void onExit();
|
||||
virtual std::string title();
|
||||
SpriteSheetOffsetAnchorRotation();
|
||||
virtual void onExit();
|
||||
virtual std::string title();
|
||||
};
|
||||
|
||||
class SpriteOffsetAnchorScale: public SpriteTestDemo
|
||||
{
|
||||
public:
|
||||
SpriteOffsetAnchorScale();
|
||||
virtual void onExit();
|
||||
virtual std::string title();
|
||||
SpriteOffsetAnchorScale();
|
||||
virtual void onExit();
|
||||
virtual std::string title();
|
||||
};
|
||||
|
||||
class SpriteSheetOffsetAnchorScale: public SpriteTestDemo
|
||||
{
|
||||
public:
|
||||
SpriteSheetOffsetAnchorScale();
|
||||
virtual void onExit();
|
||||
virtual std::string title();
|
||||
SpriteSheetOffsetAnchorScale();
|
||||
virtual void onExit();
|
||||
virtual std::string title();
|
||||
};
|
||||
|
||||
class SpriteAnimationSplit : public SpriteTestDemo
|
||||
{
|
||||
public:
|
||||
SpriteAnimationSplit();
|
||||
virtual void onExit();
|
||||
virtual std::string title();
|
||||
SpriteAnimationSplit();
|
||||
virtual void onExit();
|
||||
virtual std::string title();
|
||||
};
|
||||
|
||||
class SpriteHybrid: public SpriteTestDemo
|
||||
{
|
||||
BOOL m_usingSpriteSheet;
|
||||
bool m_usingSpriteSheet;
|
||||
public:
|
||||
SpriteHybrid();
|
||||
void reparentSprite(ccTime dt);
|
||||
virtual std::string title();
|
||||
virtual void onExit();
|
||||
SpriteHybrid();
|
||||
void reparentSprite(ccTime dt);
|
||||
virtual std::string title();
|
||||
virtual void onExit();
|
||||
};
|
||||
|
||||
class SpriteSheetChildren: public SpriteTestDemo
|
||||
{
|
||||
public:
|
||||
SpriteSheetChildren();
|
||||
virtual void onExit();
|
||||
virtual std::string title();
|
||||
SpriteSheetChildren();
|
||||
virtual void onExit();
|
||||
virtual std::string title();
|
||||
};
|
||||
|
||||
class SpriteSheetChildren2: public SpriteTestDemo
|
||||
{
|
||||
public:
|
||||
SpriteSheetChildren2();
|
||||
virtual void onExit();
|
||||
virtual std::string title();
|
||||
SpriteSheetChildren2();
|
||||
virtual void onExit();
|
||||
virtual std::string title();
|
||||
};
|
||||
|
||||
class SpriteSheetChildrenZ : public SpriteTestDemo
|
||||
{
|
||||
public:
|
||||
SpriteSheetChildrenZ();
|
||||
virtual void onExit();
|
||||
virtual std::string title();
|
||||
SpriteSheetChildrenZ();
|
||||
virtual void onExit();
|
||||
virtual std::string title();
|
||||
};
|
||||
|
||||
class SpriteChildrenVisibility: public SpriteTestDemo
|
||||
{
|
||||
public:
|
||||
SpriteChildrenVisibility();
|
||||
virtual void onExit();
|
||||
virtual std::string title();
|
||||
SpriteChildrenVisibility();
|
||||
virtual void onExit();
|
||||
virtual std::string title();
|
||||
};
|
||||
|
||||
class SpriteChildrenAnchorPoint: public SpriteTestDemo
|
||||
{
|
||||
public:
|
||||
SpriteChildrenAnchorPoint();
|
||||
virtual void onExit();
|
||||
virtual std::string title();
|
||||
SpriteChildrenAnchorPoint();
|
||||
virtual void onExit();
|
||||
virtual std::string title();
|
||||
};
|
||||
|
||||
class SpriteSheetChildrenAnchorPoint: public SpriteTestDemo
|
||||
{
|
||||
public:
|
||||
SpriteSheetChildrenAnchorPoint();
|
||||
virtual void onExit();
|
||||
virtual std::string title();
|
||||
SpriteSheetChildrenAnchorPoint();
|
||||
virtual void onExit();
|
||||
virtual std::string title();
|
||||
};
|
||||
|
||||
class SpriteSheetChildrenScale: public SpriteTestDemo
|
||||
{
|
||||
public:
|
||||
SpriteSheetChildrenScale();
|
||||
virtual std::string title();
|
||||
SpriteSheetChildrenScale();
|
||||
virtual std::string title();
|
||||
};
|
||||
|
||||
class SpriteChildrenChildren: public SpriteTestDemo
|
||||
{
|
||||
public:
|
||||
SpriteChildrenChildren();
|
||||
virtual std::string title();
|
||||
SpriteChildrenChildren();
|
||||
virtual std::string title();
|
||||
};
|
||||
|
||||
|
||||
class SpriteSheetChildrenChildren: public SpriteTestDemo
|
||||
{
|
||||
public:
|
||||
SpriteSheetChildrenChildren();
|
||||
virtual std::string title();
|
||||
SpriteSheetChildrenChildren();
|
||||
virtual std::string title();
|
||||
};
|
||||
|
||||
class SpriteNilTexture: public SpriteTestDemo
|
||||
{
|
||||
public:
|
||||
SpriteNilTexture();
|
||||
virtual std::string title();
|
||||
std::string subtitle();
|
||||
};
|
||||
|
||||
class SpriteTestScene : public TestScene
|
||||
{
|
||||
public:
|
||||
virtual void runThisTest();
|
||||
};
|
||||
|
||||
#endif
|
||||
SpriteNilTexture();
|
||||
virtual std::string title();
|
||||
std::string subtitle();
|
||||
};
|
||||
|
||||
class SpriteTestScene : public TestScene
|
||||
{
|
||||
public:
|
||||
virtual void runThisTest();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,13 +1,13 @@
|
|||
#include "Paddle.h"
|
||||
|
||||
Paddle::Paddle(void)
|
||||
{
|
||||
}
|
||||
|
||||
Paddle::~Paddle(void)
|
||||
{
|
||||
}
|
||||
|
||||
#include "Paddle.h"
|
||||
|
||||
Paddle::Paddle(void)
|
||||
{
|
||||
}
|
||||
|
||||
Paddle::~Paddle(void)
|
||||
{
|
||||
}
|
||||
|
||||
CGRect Paddle::rect()
|
||||
{
|
||||
CGSize s = getTexture()->getContentSize();
|
||||
|
@ -25,12 +25,12 @@ Paddle* Paddle::paddleWithTexture(CCTexture2D* aTexture)
|
|||
|
||||
bool Paddle::initWithTexture(CCTexture2D* aTexture)
|
||||
{
|
||||
if( CCSprite::initWithTexture(aTexture) )
|
||||
{
|
||||
m_state = kPaddleStateUngrabbed;
|
||||
}
|
||||
if( CCSprite::initWithTexture(aTexture) )
|
||||
{
|
||||
m_state = kPaddleStateUngrabbed;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
void Paddle::onEnter()
|
||||
|
|
|
@ -51,9 +51,9 @@ static TestScene* CreateTestScene(int nIdx)
|
|||
pScene = new TileMapTestScene(); break;
|
||||
case TEST_INTERVAL:
|
||||
pScene = new IntervalTestScene(); break;
|
||||
case TEST_CHIPMUNK:
|
||||
CCDirector::sharedDirector()->setDeviceOrientation(CCDeviceOrientationPortrait);
|
||||
pScene = new ChipmunkTestScene(); break;
|
||||
// case TEST_CHIPMUNK:
|
||||
// CCDirector::sharedDirector()->setDeviceOrientation(CCDeviceOrientationPortrait);
|
||||
// pScene = new ChipmunkTestScene(); break;
|
||||
case TEST_ATLAS:
|
||||
pScene = new AtlasTestScene(); break;
|
||||
case TEST_SPRITE:
|
||||
|
@ -96,7 +96,7 @@ TestController::TestController()
|
|||
// add menu items for tests
|
||||
for (int i = 0; i < ITEM_EVERYPAGE; ++i)
|
||||
{
|
||||
CCLabel* label = CCLabel::labelWithString("For Test", "Arial", 32);
|
||||
CCLabel* label = CCLabel::labelWithString("For Test", "Arial", 24);
|
||||
CCMenuItemLabel* pMenuItem = CCMenuItemLabel::itemWithLabel(label, this, menu_selector(TestController::menuCallback));
|
||||
pMenu->addChild(pMenuItem, i + 2);
|
||||
pMenuItem->setPosition( CGPointMake( s.width / 2, (s.height - (i + 1) * LINE_SPACE) ));
|
||||
|
|
|
@ -10,23 +10,23 @@ static const char s_pPathR1[] = "Images/r1.png";
|
|||
static const char s_pPathR2[] = "Images/r2.png";
|
||||
static const char s_pPathF1[] = "Images/f1.png";
|
||||
static const char s_pPathF2[] = "Images/f2.png";
|
||||
static const char s_pPathBlock[] = "Images/blocks.png";
|
||||
static const char s_back[] = "Images/background.png";
|
||||
static const char s_pPathBlock[] = "Images/blocks.png";
|
||||
static const char s_back[] = "Images/background.png";
|
||||
static const char s_back1[] = "Images/background1.png";
|
||||
static const char s_back2[] = "Images/background2.png";
|
||||
static const char s_back2[] = "Images/background2.png";
|
||||
static const char s_back3[] = "Images/background3.png";
|
||||
static const char s_stars1[] = "Images/stars.png";
|
||||
static const char s_stars2[] = "Images/stars2.png";
|
||||
static const char s_fire[] = "Images/fire.png";
|
||||
static const char s_snow[] = "Images/snow.png";
|
||||
static const char s_streak[] = "Images/streak.png";
|
||||
static const char s_PlayNormal[] = "Images/btn-play-normal.png";
|
||||
static const char s_PlaySelect[] = "Images/btn-play-selected.png";
|
||||
static const char s_AboutNormal[] = "Images/btn-about-normal.png";
|
||||
static const char s_AboutSelect[] = "Images/btn-about-selected.png";
|
||||
static const char s_HighNormal[] = "Images/btn-highscores-normal.png";
|
||||
static const char s_HighSelect[] = "Images/btn-highscores-selected.png";
|
||||
static const char s_Ball[] = "Images/ball.png";
|
||||
static const char s_fire[] = "Images/fire.png";
|
||||
static const char s_snow[] = "Images/snow.png";
|
||||
static const char s_streak[] = "Images/streak.png";
|
||||
static const char s_PlayNormal[] = "Images/btn-play-normal.png";
|
||||
static const char s_PlaySelect[] = "Images/btn-play-selected.png";
|
||||
static const char s_AboutNormal[] = "Images/btn-about-normal.png";
|
||||
static const char s_AboutSelect[] = "Images/btn-about-selected.png";
|
||||
static const char s_HighNormal[] = "Images/btn-highscores-normal.png";
|
||||
static const char s_HighSelect[] = "Images/btn-highscores-selected.png";
|
||||
static const char s_Ball[] = "Images/ball.png";
|
||||
static const char s_Paddle[] = "Images/paddle.png";
|
||||
static const char s_pPathClose[] = "Images/close.png";
|
||||
static const char s_MenuItem[] = "Images/menuitemsprite.png";
|
||||
|
@ -39,4 +39,5 @@ static const char s_AtlasTest[] = "Images/atlastest.png";
|
|||
static const char s_TilesPng[] = "TileMaps/tiles.png";
|
||||
static const char s_LevelMapTga[] = "TileMaps/levelmap.tga";
|
||||
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue