issue #21: change INT32 to int, change UINT to unsigned int

This commit is contained in:
Ming 2010-08-02 02:58:00 +00:00
parent 167122d2cf
commit a324e38cb2
36 changed files with 1114 additions and 1117 deletions

View File

@ -25,7 +25,6 @@ THE SOFTWARE.
#ifndef __CCCONFIGURATION_H__
#define __CCCONFIGURATION_H__
#include "platform/platform.h"
#include "cocoa/NSObject.h"
#include <GLES/gl.h>
#include <string>

View File

@ -50,8 +50,8 @@ CCDirector* CCDirector::getSharedDirector(void)
{
if (! pobSharedDirector)
{
//
// Default Director is TimerDirector
//
// Default Director is TimerDirector
//
//pobSharedDirector = new CCTimerDirector();
//pobSharedDirector->init();
@ -175,7 +175,7 @@ void CCDirector::mainLoop(void)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
/* to avoid flickr, nextScene MUST be here: after tick and before draw.
/* to avoid flickr, nextScene MUST be here: after tick and before draw.
XXX: Which bug is this one. It seems that it can't be reproduced with v0.9 */
if (m_pNextScene)
{
@ -325,22 +325,22 @@ void CCDirector::setDeviceOrientation(ccDeviceOrientation kDeviceOrientation)
m_eDeviceOrientation = kDeviceOrientation;
// how to implementation????
/*
switch( deviceOrientation_) {
case CCDeviceOrientationPortrait:
[[UIApplication sharedApplication] setStatusBarOrientation: UIInterfaceOrientationPortrait animated:NO];
break;
case CCDeviceOrientationPortraitUpsideDown:
[[UIApplication sharedApplication] setStatusBarOrientation: UIInterfaceOrientationPortrait animated:NO];
break;
case CCDeviceOrientationLandscapeLeft:
[[UIApplication sharedApplication] setStatusBarOrientation: UIInterfaceOrientationLandscapeRight animated:NO];
break;
case CCDeviceOrientationLandscapeRight:
[[UIApplication sharedApplication] setStatusBarOrientation: UIInterfaceOrientationLandscapeLeft animated:NO];
break;
default:
NSLog(@"Director: Unknown device orientation");
break;
switch( deviceOrientation_) {
case CCDeviceOrientationPortrait:
[[UIApplication sharedApplication] setStatusBarOrientation: UIInterfaceOrientationPortrait animated:NO];
break;
case CCDeviceOrientationPortraitUpsideDown:
[[UIApplication sharedApplication] setStatusBarOrientation: UIInterfaceOrientationPortrait animated:NO];
break;
case CCDeviceOrientationLandscapeLeft:
[[UIApplication sharedApplication] setStatusBarOrientation: UIInterfaceOrientationLandscapeRight animated:NO];
break;
case CCDeviceOrientationLandscapeRight:
[[UIApplication sharedApplication] setStatusBarOrientation: UIInterfaceOrientationLandscapeLeft animated:NO];
break;
default:
NSLog(@"Director: Unknown device orientation");
break;
}
*/
}
@ -371,25 +371,25 @@ void CCDirector::setProjection(ccDirectorProjection kProjection)
glLoadIdentity();
break;
case kCCDirectorProjection3D:
glViewport(0, 0, (GLsizei)size.width, (GLsizei)size.height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60, (GLfloat)size.width/size.height, 0.5f, 1500.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt( size.width/2, size.height/2, getZEye(),
size.width/2, size.height/2, 0,
0.0f, 1.0f, 0.0f);
break;
case kCCDirectorProjectionCustom:
// if custom, ignore it. The user is resposible for setting the correct projection
break;
default:
CCLOG("cocos2d: Director: unrecognized projecgtion");
case kCCDirectorProjection3D:
glViewport(0, 0, (GLsizei)size.width, (GLsizei)size.height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60, (GLfloat)size.width/size.height, 0.5f, 1500.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt( size.width/2, size.height/2, getZEye(),
size.width/2, size.height/2, 0,
0.0f, 1.0f, 0.0f);
break;
case kCCDirectorProjectionCustom:
// if custom, ignore it. The user is resposible for setting the correct projection
break;
default:
CCLOG("cocos2d: Director: unrecognized projecgtion");
break;
}
@ -454,9 +454,9 @@ void CCDirector::setDepthTest(bool bOn)
{
if (bOn)
{
glClearDepthf(1.0f);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glClearDepthf(1.0f);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
}
else
@ -627,28 +627,28 @@ void CCDirector::applyLandspace(void)
float w = s.width / 2;
float h = s.height / 2;
// XXX it's using hardcoded values.
// XXX it's using hardcoded values.
// What if the the screen size changes in the future?
switch (m_eDeviceOrientation)
{
case CCDeviceOrientationPortrait:
// nothing
break;
case CCDeviceOrientationPortraitUpsideDown:
// upside down
glTranslatef(w,h,0);
glRotatef(180,0,0,1);
glTranslatef(-w,-h,0);
break;
case CCDeviceOrientationLandscapeRight:
glTranslatef(w,h,0);
glRotatef(90,0,0,1);
glTranslatef(-h,-w,0);
break;
case CCDeviceOrientationLandscapeLeft:
glTranslatef(w,h,0);
glRotatef(-90,0,0,1);
glTranslatef(-h,-w,0);
case CCDeviceOrientationPortraitUpsideDown:
// upside down
glTranslatef(w,h,0);
glRotatef(180,0,0,1);
glTranslatef(-w,-h,0);
break;
case CCDeviceOrientationLandscapeRight:
glTranslatef(w,h,0);
glRotatef(90,0,0,1);
glTranslatef(-h,-w,0);
break;
case CCDeviceOrientationLandscapeLeft:
glTranslatef(w,h,0);
glRotatef(-90,0,0,1);
glTranslatef(-h,-w,0);
break;
}
}
@ -671,7 +671,7 @@ void CCDirector::replaceScene(CCScene *pScene)
{
assert(pScene != NULL);
UINT32 index = m_pobScenesStack->count();
unsigned int index = m_pobScenesStack->count();
m_bSendCleanupToScene = true;
m_pobScenesStack->replaceObjectAtIndex(index - 1, pScene);
@ -694,7 +694,7 @@ void CCDirector::popScene(void)
assert(m_pRunningScene != NULL);
m_pobScenesStack->removeLastObject();
UINT32 c = m_pobScenesStack->count();
unsigned int c = m_pobScenesStack->count();
if (c == 0)
{
@ -715,11 +715,11 @@ void CCDirector::end(void)
m_pRunningScene = NULL;
m_pNextScene = NULL;
// remove all objects, but don't release it.
// remove all objects, but don't release it.
// runWithScene might be executed after 'end'.
m_pobScenesStack->removeAllObjects();
// don't release the event handlers
// don't release the event handlers
// They are needed in case the director is run again
CCTouchDispatcher::getSharedDispatcher()->removeAllDelegates();
@ -757,7 +757,7 @@ void CCDirector::setNextScene(void)
{
m_pRunningScene->onExit();
// issue #709. the root node (scene) should receive the cleanup message too
// issue #709. the root node (scene) should receive the cleanup message too
// otherwise it might be leaked.
if (m_bSendCleanupToScene)
{
@ -829,7 +829,7 @@ void CCDirector::preMainLoop(void)
// todo: implement later
#if CC_DIRECTOR_FAST_FPS
// display the FPS using a LabelAtlas
// display the FPS using a LabelAtlas
// updates the FPS every frame
void CCDirector::showFPS(void)
{
@ -843,8 +843,8 @@ void CCDirector::showFPS(void)
m_fAccumDt = 0;
/*
NSString *str = [[NSString alloc] initWithFormat:@"%.1f", frameRate];
[FPSLabel setString:str];
NSString *str = [[NSString alloc] initWithFormat:@"%.1f", frameRate];
[FPSLabel setString:str];
[str release];
*/
}
@ -869,14 +869,14 @@ void CCDisplayLinkDirector::startAnimation(void)
m_bInvalid = false;
// approximate frame rate
// assumes device refreshes at 60 fps
//int frameInterval = (int) floor(animationInterval * 60.0f);
//CCLOG(@"cocos2d: Frame interval: %d", frameInterval);
//displayLink = [NSClassFromString(@"CADisplayLink") displayLinkWithTarget:self selector:@selector(preMainLoop:)];
//[displayLink setFrameInterval:frameInterval];
// approximate frame rate
// assumes device refreshes at 60 fps
//int frameInterval = (int) floor(animationInterval * 60.0f);
//CCLOG(@"cocos2d: Frame interval: %d", frameInterval);
//displayLink = [NSClassFromString(@"CADisplayLink") displayLinkWithTarget:self selector:@selector(preMainLoop:)];
//[displayLink setFrameInterval:frameInterval];
//[displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
}

View File

@ -1,30 +1,30 @@
/****************************************************************************
Copyright (c) 2010 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __CCDIRECTOR_H__
#define __CCDIRECTOR_H__
/****************************************************************************
Copyright (c) 2010 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __CCDIRECTOR_H__
#define __CCDIRECTOR_H__
#include "ccConfig.h"
#include "ccTypes.h"
#include "Cocos2dDefine.h"
@ -32,13 +32,12 @@ THE SOFTWARE.
#include "cocoa/CGGeometry.h"
#include "cocoa/NSMutableArray.h"
#include "cocoa/CGGeometry.h"
#include "CCXEGLView.h"
#include "CCXEGLView.h"
#include "platform/platform.h"
// OpenGL related
// #include "support/CCXEGLView.h"
#include "platform/platform.h"
/** @typedef tPixelFormat
Possible Pixel Formats for the CCXEGLView
*/
@ -296,8 +295,8 @@ public:
// bool attchInViewWithFrame(UIView *pView, CGRect frame);
// // set the view where opengl to draw in
// bool attachWindow(UIWindow *pVindow);
// // set the view where opengl to draw in
// bool attachWindow(UIWindow *pVindow);
// Landspace
@ -455,7 +454,7 @@ protected:
/* display FPS ? */
bool m_bDisplayFPS;
INT32 m_nFrames;
int m_nFrames;
ccTime m_fAccumDt;
ccTime m_fFrameRate;
#if CC_DIRECTOR_FAST_FPS
@ -503,34 +502,34 @@ protected:
#if CC_ENABLE_PROFILERS
ccTime m_fAccumDtForProfiler;
#endif
};
};
/** FastDirector is a Director that triggers the main loop as fast as possible.
*
* Features and Limitations:
* - Faster than "normal" director
* - Consumes more battery than the "normal" director
* - It has some issues while using UIKit objects
*/
/*
class CCFastDirector : public CCDirector
{
public:
static CCFastDirector* getSharedDirector(void);
protected:
virtual void preMainLoop(void);
private:
CCFastDirector(void) {}
protected:
bool isRunning;
NSAutoreleasePool *pAutoreleasePool;
};
*/
*/
/*
class CCFastDirector : public CCDirector
{
public:
static CCFastDirector* getSharedDirector(void);
protected:
virtual void preMainLoop(void);
private:
CCFastDirector(void) {}
protected:
bool isRunning;
NSAutoreleasePool *pAutoreleasePool;
};
*/
/** ThreadedFastDirector is a Director that triggers the main loop from a thread.
*
* Features and Limitations:
@ -539,23 +538,23 @@ protected:
* - It can be used with UIKit objects
*
* @since v0.8.2
*/
/*
class CCThreadedFastDirector : public CCDirector
{
public:
static CCThreadedFastDirector* getSharedDirector(void);
protected:
virtual void preMainLoop(void);
private:
CCThreadedFastDirector(void){}
protected:
bool isRunning;
};
*/
*/
/*
class CCThreadedFastDirector : public CCDirector
{
public:
static CCThreadedFastDirector* getSharedDirector(void);
protected:
virtual void preMainLoop(void);
private:
CCThreadedFastDirector(void){}
protected:
bool isRunning;
};
*/
/** DisplayLinkDirector is a Director that synchronizes timers with the refresh rate of the display.
*
* Features and Limitations:
@ -566,22 +565,22 @@ protected:
* It is the recommended Director if the SDK is 3.1 or newer
*
* @since v0.8.2
*/
class CCDisplayLinkDirector : public CCDirector
{
public:
CCDisplayLinkDirector(void) {}
//static CCDisplayLinkDirector* getSharedDirector(void);
virtual void preMainLoop(void);
virtual void setAnimationInterval(double dValue);
virtual void startAnimation(void);
virtual void stopAnimation();
protected:
bool m_bInvalid;
};
*/
class CCDisplayLinkDirector : public CCDirector
{
public:
CCDisplayLinkDirector(void) {}
//static CCDisplayLinkDirector* getSharedDirector(void);
virtual void preMainLoop(void);
virtual void setAnimationInterval(double dValue);
virtual void startAnimation(void);
virtual void stopAnimation();
protected:
bool m_bInvalid;
};
/** TimerDirector is a Director that calls the main loop from an NSTimer object
*
* Features and Limitations:
@ -590,22 +589,22 @@ protected:
* - The invertal update is customizable from 1 to 60
*
* It is the default Director.
*/
/*
class CCTimerDirector : public CCDirector
{
public:
static CCTimerDirector* getSharedDirector(void);
protected:
virtual void preMain(void);
private:
CCTimerDirector(void) {}
protected:
NSTimer *pAnimationTimer;
};
*/
#endif // __CCDIRECTOR_H__
*/
/*
class CCTimerDirector : public CCDirector
{
public:
static CCTimerDirector* getSharedDirector(void);
protected:
virtual void preMain(void);
private:
CCTimerDirector(void) {}
protected:
NSTimer *pAnimationTimer;
};
*/
#endif // __CCDIRECTOR_H__

View File

@ -41,7 +41,6 @@ THE SOFTWARE.
*/
#include "Cocoa/CGGeometry.h" // for CGPoint
#include "platform/platform.h"
/** draws a point given x and y coordinate */
void ccDrawPoint( CGPoint point );

View File

@ -31,35 +31,35 @@ THE SOFTWARE.
// data structures
// A list double-linked list used for "updates with priority"
typedef struct _listEntry
{
struct _listEntry *prev, *next;
SelectorProtocol *target; // not retained (retained by hashUpdateEntry)
INT32 priority;
bool paused;
// A list double-linked list used for "updates with priority"
typedef struct _listEntry
{
struct _listEntry *prev, *next;
SelectorProtocol *target; // not retained (retained by hashUpdateEntry)
int priority;
bool paused;
} tListEntry;
typedef struct _hashUpdateEntry
{
tListEntry **list; // Which list does it belong to ?
tListEntry *entry; // entry in the list
SelectorProtocol *target; // hash key (retained)
UT_hash_handle hh;
} tHashUpdateEntry;
// Hash Element used for "selectors with interval"
typedef struct _hashSelectorEntry
{
NSMutableArray<CCTimer*> *timers;
SelectorProtocol *target; // hash key (retained)
UINT32 timerIndex;
CCTimer *currentTimer;
bool currentTimerSalvaged;
bool paused;
UT_hash_handle hh;
} tHashSelectorEntry;
typedef struct _hashUpdateEntry
{
tListEntry **list; // Which list does it belong to ?
tListEntry *entry; // entry in the list
SelectorProtocol *target; // hash key (retained)
UT_hash_handle hh;
} tHashUpdateEntry;
// Hash Element used for "selectors with interval"
typedef struct _hashSelectorEntry
{
NSMutableArray<CCTimer*> *timers;
SelectorProtocol *target; // hash key (retained)
unsigned int timerIndex;
CCTimer *currentTimer;
bool currentTimerSalvaged;
bool paused;
UT_hash_handle hh;
} tHashSelectorEntry;
// implementation CCTimer
@ -220,7 +220,7 @@ void CCScheduler::scheduleSelector(SEL_SCHEDULE pfnSelector, SelectorProtocol *p
}
// NSMutableArray will increase it's capacity automatically
//else if( element->timers->num == element->timers->max )
//else if( element->timers->num == element->timers->max )
//ccArrayDoubleCapacity(element->timers);
CCTimer *pTimer = new CCTimer();
@ -246,7 +246,7 @@ void CCScheduler::unscheduleSelector(SEL_SCHEDULE pfnSelector, SelectorProtocol
if (pElement)
{
NSMutableArray<CCTimer*>::NSMutableArrayIterator iter;
UINT32 i;
unsigned int i;
for (iter = pElement->timers->begin(), i = 0; iter != pElement->timers->end(); ++iter, ++i)
{
CCTimer *pTimer = *iter;
@ -285,7 +285,7 @@ void CCScheduler::unscheduleSelector(SEL_SCHEDULE pfnSelector, SelectorProtocol
}
}
void CCScheduler::priorityIn(tListEntry **ppList, SelectorProtocol *pTarget, Int32 nPriority, bool bPaused)
void CCScheduler::priorityIn(tListEntry **ppList, SelectorProtocol *pTarget, int nPriority, bool bPaused)
{
tListEntry *pListElement = (tListEntry *)malloc(sizeof(*pListElement));
@ -352,7 +352,7 @@ void CCScheduler::appendIn(_listEntry **ppList, SelectorProtocol *pTarget, bool
HASH_ADD_INT(m_pHashForUpdates, target, pHashElement);
}
void CCScheduler::scheduleUpdateForTarget(SelectorProtocol *pTarget, INT32 nPriority, bool bPaused)
void CCScheduler::scheduleUpdateForTarget(SelectorProtocol *pTarget, int nPriority, bool bPaused)
{
#if COCOS2D_DEBUG >= 1
tHashUpdateEntry *pHashElement = NULL;
@ -360,7 +360,7 @@ void CCScheduler::scheduleUpdateForTarget(SelectorProtocol *pTarget, INT32 nPrio
assert(pHashElement == NULL);
#endif
// most of the updates are going to be 0, that's way there
// most of the updates are going to be 0, that's way there
// is an special list for updates with priority 0
if (nPriority == 0)
{
@ -560,8 +560,8 @@ void CCScheduler::tick(ccTime dt)
if (elt->currentTimerSalvaged)
{
// The currentTimer told the remove itself. To prevent the timer from
// accidentally deallocating itself before finishing its step, we retained
// The currentTimer told the remove itself. To prevent the timer from
// accidentally deallocating itself before finishing its step, we retained
// it. Now that step is done, it's safe to release it.
elt->currentTimer->release();
}
@ -570,7 +570,7 @@ void CCScheduler::tick(ccTime dt)
}
}
// elt, at this moment, is still valid
// elt, at this moment, is still valid
// so it is safe to ask this here (issue #490)
elt = (tHashSelectorEntry *)elt->hh.next;

View File

@ -25,14 +25,13 @@ THE SOFTWARE.
#ifndef __CCSCHEDULER_H__
#define __CCSCHEDULER_H__
#include "platform/platform.h"
#include "cocoa/NSObject.h"
#include "cocoa/selector_protocol.h"
#include "support/data_support/uthash.h"
//
// CCTimer
//
//
// CCTimer
//
/** Light weight timer */
class CCTimer : public NSObject
{
@ -68,19 +67,19 @@ protected:
ccTime m_fElapsed;
};
//
// CCScheduler
//
/** Scheduler is responsible of triggering the scheduled callbacks.
You should not use NSTimer. Instead use this class.
There are 2 different types of callbacks (selectors):
- update selector: the 'update' selector will be called every frame. You can customize the priority.
- custom selector: A custom selector will be called every frame, or with a custom interval of time
The 'custom selectors' should be avoided when possible. It is faster, and consumes less memory to use the 'update selector'.
//
// CCScheduler
//
/** Scheduler is responsible of triggering the scheduled callbacks.
You should not use NSTimer. Instead use this class.
There are 2 different types of callbacks (selectors):
- update selector: the 'update' selector will be called every frame. You can customize the priority.
- custom selector: A custom selector will be called every frame, or with a custom interval of time
The 'custom selectors' should be avoided when possible. It is faster, and consumes less memory to use the 'update selector'.
*/
struct _listEntry;
@ -92,92 +91,92 @@ class CCScheduler : public NSObject
public:
~CCScheduler(void);
/** Modifies the time of all scheduled callbacks.
You can use this property to create a 'slow motion' or 'fast fordward' effect.
Default is 1.0. To create a 'slow motion' effect, use values below 1.0.
To create a 'fast fordward' effect, use values higher than 1.0.
@since v0.8
@warning It will affect EVERY scheduled selector / action.
/** Modifies the time of all scheduled callbacks.
You can use this property to create a 'slow motion' or 'fast fordward' effect.
Default is 1.0. To create a 'slow motion' effect, use values below 1.0.
To create a 'fast fordward' effect, use values higher than 1.0.
@since v0.8
@warning It will affect EVERY scheduled selector / action.
*/
ccTime getTimeScale(void);
void setTimeScale(ccTime fTimeScale);
/** 'tick' the scheduler.
You should NEVER call this method, unless you know what you are doing.
/** 'tick' the scheduler.
You should NEVER call this method, unless you know what you are doing.
*/
void tick(ccTime dt);
/** The scheduled method will be called every 'interval' seconds.
If paused is YES, then it won't be called until it is resumed.
If 'interval' is 0, it will be called every frame, but if so, it recommened to use 'scheduleUpdateForTarget:' instead.
@since v0.99.3
/** The scheduled method will be called every 'interval' seconds.
If paused is YES, then it won't be called until it is resumed.
If 'interval' is 0, it will be called every frame, but if so, it recommened to use 'scheduleUpdateForTarget:' instead.
@since v0.99.3
*/
void scheduleSelector(SEL_SCHEDULE pfnSelector, SelectorProtocol *pTarget, float fInterval, bool bPaused);
/** Schedules the 'update' selector for a given target with a given priority.
The 'update' selector will be called every frame.
The lower the priority, the earlier it is called.
@since v0.99.3
/** Schedules the 'update' selector for a given target with a given priority.
The 'update' selector will be called every frame.
The lower the priority, the earlier it is called.
@since v0.99.3
*/
void scheduleUpdateForTarget(SelectorProtocol *pTarget, INT32 nPriority, bool bPaused);
void scheduleUpdateForTarget(SelectorProtocol *pTarget, int nPriority, bool bPaused);
/** Unshedules a selector for a given target.
If you want to unschedule the "update", use unscheudleUpdateForTarget.
@since v0.99.3
/** Unshedules a selector for a given target.
If you want to unschedule the "update", use unscheudleUpdateForTarget.
@since v0.99.3
*/
void unscheduleSelector(SEL_SCHEDULE pfnSelector, SelectorProtocol *pTarget);
/** Unschedules the update selector for a given target
@since v0.99.3
/** Unschedules the update selector for a given target
@since v0.99.3
*/
void unscheduleUpdateForTarget(SelectorProtocol *pTarget);
/** Unschedules all selectors for a given target.
This also includes the "update" selector.
@since v0.99.3
/** Unschedules all selectors for a given target.
This also includes the "update" selector.
@since v0.99.3
*/
void unscheduleAllSelectorsForTarget(SelectorProtocol *pTarget);
/** Unschedules all selectors from all targets.
You should NEVER call this method, unless you know what you are doing.
@since v0.99.3
/** Unschedules all selectors from all targets.
You should NEVER call this method, unless you know what you are doing.
@since v0.99.3
*/
void unscheduleAllSelectors(void);
/** Pauses the target.
All scheduled selectors/update for a given target won't be 'ticked' until the target is resumed.
If the target is not present, nothing happens.
@since v0.99.3
/** Pauses the target.
All scheduled selectors/update for a given target won't be 'ticked' until the target is resumed.
If the target is not present, nothing happens.
@since v0.99.3
*/
void pauseTarget(SelectorProtocol *pTarget);
/** Resumes the target.
The 'target' will be unpaused, so all schedule selectors/update will be 'ticked' again.
If the target is not present, nothing happens.
@since v0.99.3
/** Resumes the target.
The 'target' will be unpaused, so all schedule selectors/update will be 'ticked' again.
If the target is not present, nothing happens.
@since v0.99.3
*/
void resumeTarget(SelectorProtocol *pTarget);
/** schedules a Timer.
It will be fired in every frame.
@deprecated Use scheduleSelector:forTarget:interval:paused instead. Will be removed in 1.0
/** schedules a Timer.
It will be fired in every frame.
@deprecated Use scheduleSelector:forTarget:interval:paused instead. Will be removed in 1.0
*/
void scheduleTimer(CCTimer *pTimer);
/** unschedules an already scheduled Timer
@deprecated Use unscheduleSelector:forTarget. Will be removed in v1.0
/** unschedules an already scheduled Timer
@deprecated Use unscheduleSelector:forTarget. Will be removed in v1.0
*/
void unscheduleTimer(CCTimer *pTimer);
/** unschedule all timers.
You should NEVER call this method, unless you know what you are doing.
@deprecated Use scheduleAllSelectors instead. Will be removed in 1.0
@since v0.8
/** unschedule all timers.
You should NEVER call this method, unless you know what you are doing.
@deprecated Use scheduleAllSelectors instead. Will be removed in 1.0
@since v0.8
*/
void unscheduleAllTimers(void);
@ -185,8 +184,8 @@ public:
// returns a shared instance of the Scheduler
static CCScheduler* getSharedScheduler(void);
/** purges the shared scheduler. It releases the retained instance.
@since v0.99.0
/** purges the shared scheduler. It releases the retained instance.
@since v0.99.0
*/
static void purgeSharedScheduler(void);
@ -197,14 +196,14 @@ private:
// update specific
void priorityIn(struct _listEntry **ppList, SelectorProtocol *pTarget, INT32 nPriority, bool bPaused);
void priorityIn(struct _listEntry **ppList, SelectorProtocol *pTarget, int nPriority, bool bPaused);
void appendIn(struct _listEntry **ppList, SelectorProtocol *pTarget, bool bPaused);
protected:
ccTime m_fTimeScale;
//
// "updates with priority" stuff
//
// "updates with priority" stuff
//
struct _listEntry *m_pUpdatesNegList; // list of priority < 0
struct _listEntry *m_pUpdates0List; // list priority == 0

View File

@ -27,6 +27,7 @@ THE SOFTWARE.
#include "NSObject.h"
#include <string>
#include "platform/platform.h"
class NSData : public NSObject
{

View File

@ -26,7 +26,6 @@ THE SOFTWARE.
#define __COCOA_NS_MUTATLE_ARRAY_H__
#include "cocoa/NSObject.h"
#include "platform/platform.h"
#include <vector>
#include <assert.h>
@ -40,7 +39,7 @@ public:
typedef typename NSObjectArray::reverse_iterator NSMutableArrayRevIterator;
public:
NSMutableArray(UINT uSize = 0)
NSMutableArray(unsigned int uSize = 0)
{
m_array.resize(uSize);
}
@ -50,12 +49,12 @@ public:
removeAllObjects();
}
UINT32 count(void)
unsigned int count(void)
{
return m_array.size();
}
UINT32 getIndexOfObject(T pObject)
unsigned int getIndexOfObject(T pObject)
{
if (m_array.empty() || (pObject == NULL))
{
@ -63,8 +62,8 @@ public:
}
NSMutableArray<T>::NSMutableArrayIterator iter;
UINT32 uRet = 0;
INT32 i;
unsigned int uRet = 0;
int i;
for (iter = m_array.begin(), i = 0; iter != m_array.end(); ++iter, ++i)
{
if (*iter == pObject)
@ -101,7 +100,7 @@ public:
T getLastObject(void)
{
T pObject = NULL;
INT32 count = this->count();
int count = this->count();
if (count > 0)
{
@ -111,7 +110,7 @@ public:
return pObject;
}
T getObjectAtIndex(UINT32 uIndex)
T getObjectAtIndex(unsigned int uIndex)
{
assert(uIndex < count());
@ -154,7 +153,7 @@ public:
}
}
void insertObjectAtIndex(T pObject, UINT32 uIndex)
void insertObjectAtIndex(T pObject, unsigned int uIndex)
{
// make sure the object is not null
if (pObject == NULL)
@ -172,7 +171,7 @@ public:
// Removing objects
void removeLastObject(void)
{
INT32 count = this->count();
int count = this->count();
if (count > 0)
{
@ -202,7 +201,7 @@ public:
}
}
void removeObjectAtIndex(UINT32 uIndex)
void removeObjectAtIndex(unsigned int uIndex)
{
if (m_array.empty() || uIndex == 0)
{
@ -232,7 +231,7 @@ public:
m_array.clear();
}
void replaceObjectAtIndex(UINT32 uIndex, T pObject)
void replaceObjectAtIndex(unsigned int uIndex, T pObject)
{
if (uIndex >= count())
{

View File

@ -1,15 +1,15 @@
/* cocos2d for windows
*
* http://cocos2d-win.blogspot.com
*
* Copyright (C) 2010 KOO C.H
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the 'cocos2d for windows' license.
*
* You will find a copy of this license within the cocos2d for windows
* distribution inside the "LICENSE" file.
*
/* cocos2d for windows
*
* http://cocos2d-win.blogspot.com
*
* Copyright (C) 2010 KOO C.H
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the 'cocos2d for windows' license.
*
* You will find a copy of this license within the cocos2d for windows
* distribution inside the "LICENSE" file.
*
*/
#ifndef __CCMUTABLE_DICTIONARY_H__
#define __CCMUTABLE_DICTIONARY_H__
@ -46,7 +46,7 @@ public:
}
/// return the number of items
UINT32 count()
unsigned int count()
{
return m_Map.size();
}
@ -70,8 +70,8 @@ public:
NSObjectMapIter it;
for( it= m_Map.begin(); it != m_Map.end(); ++it)
{
if (it->second == object)
{
if (it->second == object)
{
tRet.push_back(it->first);
}
}

View File

@ -36,7 +36,7 @@ NSObject* CCCopying::copyWithZone(NSZone *pZone)
NSObject::NSObject(void)
{
static UINT uObjectCount = 0;
static unsigned int uObjectCount = 0;
m_uID = ++uObjectCount;
@ -91,7 +91,7 @@ bool NSObject::isSingleRefrence(void)
return m_uRefrence == 1;
}
UINT32 NSObject::retainCount(void)
unsigned int NSObject::retainCount(void)
{
return m_uRefrence;
}

View File

@ -25,7 +25,6 @@ THE SOFTWARE.
#ifndef __COCOA_NSOBJECT_H__
#define __COCOA_NSOBJECT_H__
#include "platform/platform.h"
class NSZone;
class NSObject;
class NSString;
@ -40,9 +39,9 @@ class NSObject : public CCCopying
{
protected:
// object id
UINT32 m_uID;
unsigned int m_uID;
// count of refrence
UINT32 m_uRefrence;
unsigned int m_uRefrence;
// is the object autoreleased
bool m_bManaged;
public:
@ -54,7 +53,7 @@ public:
NSObject* autorelease(void);
NSObject* copy(void);
bool isSingleRefrence(void);
UINT32 retainCount(void);
unsigned int retainCount(void);
bool isEqual(const NSObject* pObject);
friend class NSAutoreleasePool;

View File

@ -24,7 +24,6 @@ THE SOFTWARE.
#ifndef __NS_ZONE_H__
#define __NS_ZONE_H__
#include "platform/platform.h"
class NSObject;

View File

@ -52,7 +52,7 @@ public:
protected:
bool m_bActive;
INT32 m_nReuseGrid;
int m_nReuseGrid;
ccGridSize m_obGridSize;
CCTexture2D *m_pobTexture;
CGPoint m_obStep;

View File

@ -28,7 +28,6 @@ THE SOFTWARE.
#include "ccTypes.h"
#include "cocoa/NSObject.h"
#include "cocoa/NSZone.h"
#include "platform/platform.h"
enum {
//! Default tag
@ -82,8 +81,8 @@ public:
NSObject* getOriginalTarget(void);
// The action tag. An identifier of the action
INT32 getTag(void);
void setTag(INT32 nTag);
int getTag(void);
void setTag(int nTag);
public:
// Allocates and initializes the action
@ -92,7 +91,7 @@ public:
protected:
NSObject *m_pOriginalTarget;
NSObject *m_pTarget;
INT32 m_nTag;
int m_nTag;
};
/** Base class actions that do have a finite time duration.

View File

@ -42,50 +42,50 @@ class CGSize;
class CCTexture2D;
struct transformValues_;
enum {
/// CCSprite invalid index on the CCSpriteSheet
CCSpriteIndexNotInitialized = 0xffffffff,
enum {
/// CCSprite invalid index on the CCSpriteSheet
CCSpriteIndexNotInitialized = 0xffffffff,
};
/**
Whether or not an CCSprite will rotate, scale or translate with it's parent.
Useful in health bars, when you want that the health bar translates with it's parent but you don't
want it to rotate with its parent.
@since v0.99.0
*/
typedef enum {
//! Translate with it's parent
CC_HONOR_PARENT_TRANSFORM_TRANSLATE = 1 << 0,
//! Rotate with it's parent
CC_HONOR_PARENT_TRANSFORM_ROTATE = 1 << 1,
//! Scale with it's parent
CC_HONOR_PARENT_TRANSFORM_SCALE = 1 << 2,
//! All possible transformation enabled. Default value.
CC_HONOR_PARENT_TRANSFORM_ALL = CC_HONOR_PARENT_TRANSFORM_TRANSLATE | CC_HONOR_PARENT_TRANSFORM_ROTATE | CC_HONOR_PARENT_TRANSFORM_SCALE,
/**
Whether or not an CCSprite will rotate, scale or translate with it's parent.
Useful in health bars, when you want that the health bar translates with it's parent but you don't
want it to rotate with its parent.
@since v0.99.0
*/
typedef enum {
//! Translate with it's parent
CC_HONOR_PARENT_TRANSFORM_TRANSLATE = 1 << 0,
//! Rotate with it's parent
CC_HONOR_PARENT_TRANSFORM_ROTATE = 1 << 1,
//! Scale with it's parent
CC_HONOR_PARENT_TRANSFORM_SCALE = 1 << 2,
//! All possible transformation enabled. Default value.
CC_HONOR_PARENT_TRANSFORM_ALL = CC_HONOR_PARENT_TRANSFORM_TRANSLATE | CC_HONOR_PARENT_TRANSFORM_ROTATE | CC_HONOR_PARENT_TRANSFORM_SCALE,
} ccHonorParentTransform;
/** CCSprite is a 2d image ( http://en.wikipedia.org/wiki/Sprite_(computer_graphics) )
*
* CCSprite can be created with an image, or with a sub-rectangle of an image.
*
* If the parent or any of its ancestors is a CCSpriteSheet then the following features/limitations are valid
* - Features when the parent is a CCSpriteSheet:
* - MUCH faster rendering, specially if the CCSpriteSheet has many children. All the children will be drawn in a single batch.
*
* - Limitations
* - Camera is not supported yet (eg: CCOrbitCamera action doesn't work)
* - GridBase actions are not supported (eg: CCLens, CCRipple, CCTwirl)
* - The Alias/Antialias property belongs to CCSpriteSheet, so you can't individually set the aliased property.
* - The Blending function property belongs to CCSpriteSheet, so you can't individually set the blending function property.
* - Parallax scroller is not supported, but can be simulated with a "proxy" sprite.
*
* If the parent is an standard CCNode, then CCSprite behaves like any other CCNode:
* - It supports blending functions
* - It supports aliasing / antialiasing
* - But the rendering will be slower: 1 draw per children.
*
/** CCSprite is a 2d image ( http://en.wikipedia.org/wiki/Sprite_(computer_graphics) )
*
* CCSprite can be created with an image, or with a sub-rectangle of an image.
*
* If the parent or any of its ancestors is a CCSpriteSheet then the following features/limitations are valid
* - Features when the parent is a CCSpriteSheet:
* - MUCH faster rendering, specially if the CCSpriteSheet has many children. All the children will be drawn in a single batch.
*
* - Limitations
* - Camera is not supported yet (eg: CCOrbitCamera action doesn't work)
* - GridBase actions are not supported (eg: CCLens, CCRipple, CCTwirl)
* - The Alias/Antialias property belongs to CCSpriteSheet, so you can't individually set the aliased property.
* - The Blending function property belongs to CCSpriteSheet, so you can't individually set the blending function property.
* - Parallax scroller is not supported, but can be simulated with a "proxy" sprite.
*
* If the parent is an standard CCNode, then CCSprite behaves like any other CCNode:
* - It supports blending functions
* - It supports aliasing / antialiasing
* - But the rendering will be slower: 1 draw per children.
*
*/
class CCSprite : public CCNode, public CCRGBAProtocol, public CCTextureProtocol
{
@ -103,8 +103,8 @@ public:
inline ccV3F_C4B_T2F_Quad getQuad(void) { return m_sQuad; }
// The index used on the TextureATlas. Don't modify this value unless you know what you are doing
inline UINT32 getAtlasIndex(void) { return m_uAtlasIndex; }
inline void setAtlasIndex(UINT32 uAtlasIndex) { m_uAtlasIndex = uAtlasIndex; }
inline unsigned int getAtlasIndex(void) { return m_uAtlasIndex; }
inline void setAtlasIndex(unsigned int uAtlasIndex) { m_uAtlasIndex = uAtlasIndex; }
// returns the rect of the CCSprite
inline CGRect getTextureRect(void) { return m_obRect; }
@ -121,16 +121,16 @@ public:
inline CCSpriteSheet* getSpriteSheet(void) { return m_pobSpriteSheet; }
inline void setSpriteSheet(CCSpriteSheet *pobSpriteSheet) { m_pobSpriteSheet = pobSpriteSheet; }
/** whether or not to transform according to its parent transfomrations.
Useful for health bars. eg: Don't rotate the health bar, even if the parent rotates.
IMPORTANT: Only valid if it is rendered using an CCSpriteSheet.
@since v0.99.0
/** whether or not to transform according to its parent transfomrations.
Useful for health bars. eg: Don't rotate the health bar, even if the parent rotates.
IMPORTANT: Only valid if it is rendered using an CCSpriteSheet.
@since v0.99.0
*/
inline ccHonorParentTransform getHornorParentTransform(void) { return m_eHonorParentTransform; }
inline void setHornorParentTransform(ccHonorParentTransform eHonorParentTransform) { m_eHonorParentTransform = eHonorParentTransform; }
/** offset position of the sprite. Calculated automatically by editors like Zwoptex.
@since v0.99.0
/** offset position of the sprite. Calculated automatically by editors like Zwoptex.
@since v0.99.0
*/
inline CGPoint getOffsetPosition(void) { return m_obOffsetPosition; }
inline void setSffsetPosition(CGPoint obOffsetPosition) { m_obOffsetPosition = obOffsetPosition; }
@ -140,14 +140,14 @@ public:
inline void setBlendFunc(ccBlendFunc blendFunc) { m_sBlendFunc = blendFunc; }
public:
/** Creates an sprite with a texture.
The rect used will be the size of the texture.
The offset will be (0,0).
/** Creates an sprite with a texture.
The rect used will be the size of the texture.
The offset will be (0,0).
*/
static CCSprite* spriteWithTexture(CCTexture2D *pTexture);
/** Creates an sprite with a texture and a rect.
The offset will be (0,0).
/** Creates an sprite with a texture and a rect.
The offset will be (0,0).
*/
static CCSprite* spriteWithTexture(CCTexture2D *pTexture, CGRect rect);
@ -157,34 +157,34 @@ public:
// Creates an sprite with an sprite frame.
static CCSprite* spriteWithSpriteFrame(CCSpriteFrame *pSpriteFrame);
/** Creates an sprite with an sprite frame name.
An CCSpriteFrame will be fetched from the CCSpriteFrameCache by name.
If the CCSpriteFrame doesn't exist it will raise an exception.
@since v0.9
/** Creates an sprite with an sprite frame name.
An CCSpriteFrame will be fetched from the CCSpriteFrameCache by name.
If the CCSpriteFrame doesn't exist it will raise an exception.
@since v0.9
*/
static CCSprite* spriteWithSpriteFrameName(const char *pszSpriteFrameName);
/** Creates an sprite with an image filename.
The rect used will be the size of the image.
The offset will be (0,0).
/** Creates an sprite with an image filename.
The rect used will be the size of the image.
The offset will be (0,0).
*/
static CCSprite* spriteWithFile(const char *pszFileName);
/** Creates an sprite with an image filename and a rect.
The offset will be (0,0).
/** Creates an sprite with an image filename and a rect.
The offset will be (0,0).
*/
static CCSprite* spriteWithFile(const char *pszFileName, CGRect rect);
/** Creates an sprite with a CGImageRef.
@deprecated Use spriteWithCGImage:key: instead. Will be removed in v1.0 final
/** Creates an sprite with a CGImageRef.
@deprecated Use spriteWithCGImage:key: instead. Will be removed in v1.0 final
*/
// static CCSprite* spriteWithCGImage(CGImageRef pImage);
/** Creates an sprite with a CGImageRef and a key.
The key is used by the CCTextureCache to know if a texture was already created with this CGImage.
For example, a valid key is: @"sprite_frame_01".
If key is nil, then a new texture will be created each time by the CCTextureCache.
@since v0.99.0
/** Creates an sprite with a CGImageRef and a key.
The key is used by the CCTextureCache to know if a texture was already created with this CGImage.
For example, a valid key is: @"sprite_frame_01".
If key is nil, then a new texture will be created each time by the CCTextureCache.
@since v0.99.0
*/
// static CCSprite* spriteWithCGImage(CGImageRef pImage, const char *pszKey);
@ -201,10 +201,10 @@ public:
virtual void removeChild(CCNode* pChild, bool bCleanup);
virtual void removeAllChildrenWithCleanup(bool bCleanup);
virtual void reorderChild(CCNode *pChild, INT32 zOrder);
virtual void reorderChild(CCNode *pChild, int zOrder);
virtual CCNode* addChild(CCNode *pChild);
virtual CCNode* addChild(CCNode *pChild, INT32 zOrder);
virtual CCNode* addChild(CCNode *pChild, INT32 zOrder, INT32 tag);
virtual CCNode* addChild(CCNode *pChild, int zOrder);
virtual CCNode* addChild(CCNode *pChild, int zOrder, int tag);
virtual void setDirtyRecursively(bool bValue);
virtual void setPosition(CGPoint pos);
@ -234,48 +234,48 @@ public:
virtual void setTexture(CCTexture2D *texture);
virtual CCTexture2D* getTexture(void);
/** Initializes an sprite with a texture.
The rect used will be the size of the texture.
The offset will be (0,0).
/** Initializes an sprite with a texture.
The rect used will be the size of the texture.
The offset will be (0,0).
*/
CCSprite* initWithTexture(CCTexture2D *pTexture);
/** Initializes an sprite with a texture and a rect.
The offset will be (0,0).
/** Initializes an sprite with a texture and a rect.
The offset will be (0,0).
*/
CCSprite* initWithTexture(CCTexture2D *pTexture, CGRect rect);
// Initializes an sprite with an sprite frame.
// Initializes an sprite with an sprite frame.
CCSprite* initWithSpriteFrame(CCSpriteFrame *pSpriteFrame);
/** Initializes an sprite with an sprite frame name.
An CCSpriteFrame will be fetched from the CCSpriteFrameCache by name.
If the CCSpriteFrame doesn't exist it will raise an exception.
@since v0.9
/** Initializes an sprite with an sprite frame name.
An CCSpriteFrame will be fetched from the CCSpriteFrameCache by name.
If the CCSpriteFrame doesn't exist it will raise an exception.
@since v0.9
*/
CCSprite* initWithSpriteFrameName(const char *pszSpriteFrameName);
/** Initializes an sprite with an image filename.
The rect used will be the size of the image.
The offset will be (0,0).
/** Initializes an sprite with an image filename.
The rect used will be the size of the image.
The offset will be (0,0).
*/
CCSprite* initWithFile(const char *pszFilename);
/** Initializes an sprite with an image filename, and a rect.
The offset will be (0,0).
/** Initializes an sprite with an image filename, and a rect.
The offset will be (0,0).
*/
CCSprite* initWithFile(const char *pszFilename, CGRect rect);
/** Initializes an sprite with a CGImageRef
@deprecated Use spriteWithCGImage:key: instead. Will be removed in v1.0 final
/** Initializes an sprite with a CGImageRef
@deprecated Use spriteWithCGImage:key: instead. Will be removed in v1.0 final
*/
// CCSprite* initWithCGImage(CGImageRef pImage);
/** Initializes an sprite with a CGImageRef and a key
The key is used by the CCTextureCache to know if a texture was already created with this CGImage.
For example, a valid key is: @"sprite_frame_01".
If key is nil, then a new texture will be created each time by the CCTextureCache.
@since v0.99.0
/** Initializes an sprite with a CGImageRef and a key
The key is used by the CCTextureCache to know if a texture was already created with this CGImage.
For example, a valid key is: @"sprite_frame_01".
If key is nil, then a new texture will be created each time by the CCTextureCache.
@since v0.99.0
*/
// CCSprite* initWithCGImage(CGImageRef pImage, const char *pszKey);
@ -287,16 +287,16 @@ public:
// updates the quad according the the rotation, position, scale values.
void updateTransform(void);
/** tell the sprite to use self-render.
@since v0.99.0
/** tell the sprite to use self-render.
@since v0.99.0
*/
void useSelfRender(void);
// updates the texture rect of the CCSprite.
// updates the texture rect of the CCSprite.
void setTextureRect(CGRect rect);
/** tell the sprite to use sprite sheet render.
@since v0.99.0
/** tell the sprite to use sprite sheet render.
@since v0.99.0
*/
void useSpriteSheetRender(CCSpriteSheet *pSpriteSheet);
@ -320,16 +320,16 @@ public:
// Animation
// changes the display frame based on an animation and an index.
void setDisplayFrame(const char *pszAnimationName, INT32 nFrameIndex);
void setDisplayFrame(const char *pszAnimationName, int nFrameIndex);
protected:
/*
@interface CCSprite (Private)
-(void)updateTextureCoords:(CGRect)rect;
-(void)updateBlendFunc;
-(void) initAnimationDictionary;
-(void) setTextureRect:(CGRect)rect untrimmedSize:(CGSize)size;
-(struct transformValues_) getTransformValues; // optimization
@interface CCSprite (Private)
-(void)updateTextureCoords:(CGRect)rect;
-(void)updateBlendFunc;
-(void) initAnimationDictionary;
-(void) setTextureRect:(CGRect)rect untrimmedSize:(CGSize)size;
-(struct transformValues_) getTransformValues; // optimization
@end
*/
void updateTextureCoords(CGRect rect);
@ -339,25 +339,25 @@ protected:
struct transformValues_ getTransformValues(void);
protected:
//
// Data used when the sprite is rendered using a CCSpriteSheet
//
// Data used when the sprite is rendered using a CCSpriteSheet
//
CCTextureAtlas *m_pobTextureAtlas; // Sprite Sheet texture atlas (weak reference)
UINT32 m_uAtlasIndex; // Absolute (real) Index on the SpriteSheet
unsigned int m_uAtlasIndex; // Absolute (real) Index on the SpriteSheet
CCSpriteSheet *m_pobSpriteSheet; // Used spritesheet (weak reference)
ccHonorParentTransform m_eHonorParentTransform;// whether or not to transform according to its parent transformations
bool m_bDirty; // Sprite needs to be updated
bool m_bRecursiveDirty; // Subchildren needs to be updated
bool m_bHasChildren; // optimization to check if it contain children
//
// Data used when the sprite is self-rendered
//
// Data used when the sprite is self-rendered
//
ccBlendFunc m_sBlendFunc; // Needed for the texture protocol
CCTexture2D *m_pobTexture;// Texture used to render the sprite
//
// Shared data
//
// Shared data
//
// whether or not it's parent is a CCSpriteSheet

View File

@ -35,73 +35,73 @@ THE SOFTWARE.
class CCSprite;
class CGRect;
/** CCSpriteSheet is like a batch node: if it contains children, it will draw them in 1 single OpenGL call
* (often known as "batch draw").
*
* A CCSpriteSheet can reference one and only one texture (one image file, one texture atlas).
* Only the CCSprites that are contained in that texture can be added to the CCSpriteSheet.
* All CCSprites added to a CCSpriteSheet are drawn in one OpenGL ES draw call.
* If the CCSprites are not added to a CCSpriteSheet then an OpenGL ES draw call will be needed for each one, which is less efficient.
*
*
* Limitations:
* - The only object that is accepted as child (or grandchild) is CCSprite or any subclass of CCSprite. eg: particles, labels and layer can't be added to a CCSpriteSheet.
* - Either all its children are Aliased or Antialiased. It can't be a mix. This is because "alias" is a property of the texture, and all the sprites share the same texture.
*
* @since v0.7.1
/** CCSpriteSheet is like a batch node: if it contains children, it will draw them in 1 single OpenGL call
* (often known as "batch draw").
*
* A CCSpriteSheet can reference one and only one texture (one image file, one texture atlas).
* Only the CCSprites that are contained in that texture can be added to the CCSpriteSheet.
* All CCSprites added to a CCSpriteSheet are drawn in one OpenGL ES draw call.
* If the CCSprites are not added to a CCSpriteSheet then an OpenGL ES draw call will be needed for each one, which is less efficient.
*
*
* Limitations:
* - The only object that is accepted as child (or grandchild) is CCSprite or any subclass of CCSprite. eg: particles, labels and layer can't be added to a CCSpriteSheet.
* - Either all its children are Aliased or Antialiased. It can't be a mix. This is because "alias" is a property of the texture, and all the sprites share the same texture.
*
* @since v0.7.1
*/
class CCSpriteSheet : public CCNode, public CCTextureProtocol
{
public:
~CCSpriteSheet(void);
/** initializes a CCSpriteSheet with a texture2d and capacity of children.
The capacity will be increased in 33% in runtime if it run out of space.
/** initializes a CCSpriteSheet with a texture2d and capacity of children.
The capacity will be increased in 33% in runtime if it run out of space.
*/
CCSpriteSheet* initWithTexture(CCTexture2D *pobTexture, UINT32 uCapacity);
CCSpriteSheet* initWithTexture(CCTexture2D *pobTexture, unsigned int uCapacity);
/** initializes a CCSpriteSheet with a file image (.png, .jpeg, .pvr, etc) and a capacity of children.
The capacity will be increased in 33% in runtime if it run out of space.
The file will be loaded using the TextureMgr.
/** initializes a CCSpriteSheet with a file image (.png, .jpeg, .pvr, etc) and a capacity of children.
The capacity will be increased in 33% in runtime if it run out of space.
The file will be loaded using the TextureMgr.
*/
CCSpriteSheet* initWithFile(const char *pszFileImage, UINT32 uCapacity);
CCSpriteSheet* initWithFile(const char *pszFileImage, unsigned int uCapacity);
void increaseAtlasCapacity(void);
/** creates an sprite with a rect in the CCSpriteSheet.
It's the same as:
- create an standard CCSsprite
- set the usingSpriteSheet = YES
- set the textureAtlas to the same texture Atlas as the CCSpriteSheet
@deprecated Use [CCSprite spriteWithSpriteSheet:rect] instead;
/** creates an sprite with a rect in the CCSpriteSheet.
It's the same as:
- create an standard CCSsprite
- set the usingSpriteSheet = YES
- set the textureAtlas to the same texture Atlas as the CCSpriteSheet
@deprecated Use [CCSprite spriteWithSpriteSheet:rect] instead;
*/
CCSprite* createSpriteWithRect(CGRect rect);
/** initializes a previously created sprite with a rect. This sprite will have the same texture as the CCSpriteSheet.
It's the same as:
- initialize an standard CCSsprite
- set the usingSpriteSheet = YES
- set the textureAtlas to the same texture Atlas as the CCSpriteSheet
@since v0.99.0
@deprecated Use [CCSprite initWithSpriteSheet:rect] instead;
/** initializes a previously created sprite with a rect. This sprite will have the same texture as the CCSpriteSheet.
It's the same as:
- initialize an standard CCSsprite
- set the usingSpriteSheet = YES
- set the textureAtlas to the same texture Atlas as the CCSpriteSheet
@since v0.99.0
@deprecated Use [CCSprite initWithSpriteSheet:rect] instead;
*/
void initSprite(CCSprite* pobSprite, CGRect rect);
/** removes a child given a certain index. It will also cleanup the running actions depending on the cleanup parameter.
@warning Removing a child from a CCSpriteSheet is very slow
/** removes a child given a certain index. It will also cleanup the running actions depending on the cleanup parameter.
@warning Removing a child from a CCSpriteSheet is very slow
*/
void removeChildAtIndex(UINT32 uIndex, bool bDoCleanup);
void removeChildAtIndex(unsigned int uIndex, bool bDoCleanup);
/** removes a child given a reference. It will also cleanup the running actions depending on the cleanup parameter.
@warning Removing a child from a CCSpriteSheet is very slow
/** removes a child given a reference. It will also cleanup the running actions depending on the cleanup parameter.
@warning Removing a child from a CCSpriteSheet is very slow
*/
// void removeChild(CCSprite *pobSprite, bool bDoCleanup);
void insertChild(CCSprite *pobSprite, UINT32 uIndex);
void insertChild(CCSprite *pobSprite, unsigned int uIndex);
void removeSpriteFromAtlas(CCSprite *pobSprite);
UINT32 rebuildIndexInOrder(CCSprite *pobParent, UINT32 uIndex);
UINT32 atlasIndexForChild(CCSprite *pobSprite, INT32 nZ);
unsigned int rebuildIndexInOrder(CCSprite *pobParent, unsigned int uIndex);
unsigned int atlasIndexForChild(CCSprite *pobSprite, int nZ);
unsigned int highestAtlasIndexInChild(CCSprite *pSprite);
unsigned int lowestAtlasIndexInChild(CCSprite *pSprite);
@ -120,27 +120,27 @@ public:
virtual void removeAllChildrenWithCleanup(bool cleanup);
virtual void draw(void);
public:
/** creates a CCSpriteSheet with a texture2d and a default capacity of 29 children.
The capacity will be increased in 33% in runtime if it run out of space.
/** creates a CCSpriteSheet with a texture2d and a default capacity of 29 children.
The capacity will be increased in 33% in runtime if it run out of space.
*/
static CCSpriteSheet* spriteSheetWithTexture(CCTexture2D *pobTexture);
/** creates a CCSpriteSheet with a texture2d and capacity of children.
The capacity will be increased in 33% in runtime if it run out of space.
/** creates a CCSpriteSheet with a texture2d and capacity of children.
The capacity will be increased in 33% in runtime if it run out of space.
*/
static CCSpriteSheet* spriteSheetWithTexture(CCTexture2D *pobTexture, UINT32 uCapacity);
static CCSpriteSheet* spriteSheetWithTexture(CCTexture2D *pobTexture, unsigned int uCapacity);
/** creates a CCSpriteSheet with a file image (.png, .jpeg, .pvr, etc) with a default capacity of 29 children.
The capacity will be increased in 33% in runtime if it run out of space.
The file will be loaded using the TextureMgr.
/** creates a CCSpriteSheet with a file image (.png, .jpeg, .pvr, etc) with a default capacity of 29 children.
The capacity will be increased in 33% in runtime if it run out of space.
The file will be loaded using the TextureMgr.
*/
static CCSpriteSheet* spriteSheetWithFile(const char *pszFileImage);
/** creates a CCSpriteSheet with a file image (.png, .jpeg, .pvr, etc) and capacity of children.
The capacity will be increased in 33% in runtime if it run out of space.
The file will be loaded using the TextureMgr.
/** creates a CCSpriteSheet with a file image (.png, .jpeg, .pvr, etc) and capacity of children.
The capacity will be increased in 33% in runtime if it run out of space.
The file will be loaded using the TextureMgr.
*/
static CCSpriteSheet* spriteSheetWithFile(const char *pszFileImage, UINT32 uCapacity);
static CCSpriteSheet* spriteSheetWithFile(const char *pszFileImage, unsigned int uCapacity);
private:
void updateBlendFunc(void);

View File

@ -1,33 +1,33 @@
/****************************************************************************
Copyright (c) 2010 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __CCTEXTURE2D_H__
#define __CCTEXTURE2D_H__
#include <string>
#include <GLES/gl.h>
/****************************************************************************
Copyright (c) 2010 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __CCTEXTURE2D_H__
#define __CCTEXTURE2D_H__
#include <string>
#include <GLES/gl.h>
#include "Cocos2dDefine.h"
#include "cocoa/NSObject.h"
#include "cocoa/CGGeometry.h"
@ -89,9 +89,9 @@ class CCTexture2D : public NSObject
/** pixel format of the texture */
CCX_PROPERTY_READONLY(CCTexture2DPixelFormat, m_ePixelFormat, PixelFormat)
/** width in pixels */
CCX_PROPERTY_READONLY(UINT32, m_uPixelsWide, PixelsWide)
CCX_PROPERTY_READONLY(unsigned int, m_uPixelsWide, PixelsWide)
/** hight in pixels */
CCX_PROPERTY_READONLY(UINT32, m_uPixelsHigh, PixelsHigh)
CCX_PROPERTY_READONLY(unsigned int, m_uPixelsHigh, PixelsHigh)
/** texture name */
CCX_PROPERTY_READONLY(GLuint, m_uName, Name)
@ -112,7 +112,7 @@ public:
std::string description(void);
/** Intializes with a texture2d with data */
CCTexture2D * initWithData(const void* data, CCTexture2DPixelFormat pixelFormat, UINT32 pixelsWide, UINT32 pixelsHigh, CGSize contentSize);
CCTexture2D * initWithData(const void* data, CCTexture2DPixelFormat pixelFormat, unsigned int pixelsWide, unsigned int pixelsHigh, CGSize contentSize);
/**
Drawing extensions to make it easy to draw basic quads using a CCTexture2D object.
@ -200,9 +200,9 @@ public:
static CCTexture2DPixelFormat defaultAlphaPixelFormat();
private:
CCTexture2D * initPremultipliedATextureWithImage(UIImage * image, UINT32 pixelsWide, UINT32 pixelsHigh);
CCTexture2D * initPremultipliedATextureWithImage(UIImage * image, unsigned int pixelsWide, unsigned int pixelsHigh);
};
#endif //__CCTEXTURE2D_H__
#endif //__CCTEXTURE2D_H__

View File

@ -1,30 +1,30 @@
/****************************************************************************
Copyright (c) 2010 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __CCTEXTURE_ATLAS_H__
#define __CCTEXTURE_ATLAS_H__
/****************************************************************************
Copyright (c) 2010 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __CCTEXTURE_ATLAS_H__
#define __CCTEXTURE_ATLAS_H__
#include <string>
#include "ccTypes.h"
#include "cocoa/NSObject.h"
@ -53,9 +53,9 @@ protected:
#endif // CC_TEXTURE_ATLAS_USES_VBO
/** quantity of quads that are going to be drawn */
CCX_PROPERTY_READONLY(UINT32, m_uTotalQuads, TotalQuads)
CCX_PROPERTY_READONLY(unsigned int, m_uTotalQuads, TotalQuads)
/** quantity of quads that can be stored with the current texture atlas size */
CCX_PROPERTY_READONLY(UINT32, m_uCapacity, Capacity)
CCX_PROPERTY_READONLY(unsigned int, m_uCapacity, Capacity)
/** Texture of the texture atlas */
CCX_PROPERTY(CCTexture2D *, m_pTexture, Texture)
/** Quads that are going to be rendered */
@ -71,20 +71,20 @@ public:
/** creates a TextureAtlas with an filename and with an initial capacity for Quads.
* The TextureAtlas capacity can be increased in runtime.
*/
static CCTextureAtlas * textureAtlasWithFile(const char* file , UINT32 capacity);
static CCTextureAtlas * textureAtlasWithFile(const char* file , unsigned int capacity);
/** initializes a TextureAtlas with a filename and with a certain capacity for Quads.
* The TextureAtlas capacity can be increased in runtime.
*
* WARNING: Do not reinitialize the TextureAtlas because it will leak memory (issue #706)
*/
CCTextureAtlas * initWithFile(const char* file, UINT32 capacity);
CCTextureAtlas * initWithFile(const char* file, unsigned int capacity);
/** creates a TextureAtlas with a previously initialized Texture2D object, and
* with an initial capacity for n Quads.
* The TextureAtlas capacity can be increased in runtime.
*/
static CCTextureAtlas * textureAtlasWithTexture(CCTexture2D *tex, UINT32 capacity);
static CCTextureAtlas * textureAtlasWithTexture(CCTexture2D *tex, unsigned int capacity);
/** initializes a TextureAtlas with a previously initialized Texture2D object, and
* with an initial capacity for Quads.
@ -92,31 +92,31 @@ public:
*
* WARNING: Do not reinitialize the TextureAtlas because it will leak memory (issue #706)
*/
CCTextureAtlas * initWithTexture(CCTexture2D *tex, UINT32 capacity);
CCTextureAtlas * initWithTexture(CCTexture2D *tex, unsigned int capacity);
/** updates a Quad (texture, vertex and color) at a certain index
* index must be between 0 and the atlas capacity - 1
@since v0.8
*/
void updateQuad(ccV3F_C4B_T2F_Quad* quad, UINT32 index);
void updateQuad(ccV3F_C4B_T2F_Quad* quad, unsigned int index);
/** Inserts a Quad (texture, vertex and color) at a certain index
index must be between 0 and the atlas capacity - 1
@since v0.8
*/
void insertQuad(ccV3F_C4B_T2F_Quad* quad, UINT32 index);
void insertQuad(ccV3F_C4B_T2F_Quad* quad, unsigned int index);
/** Removes the quad that is located at a certain index and inserts it at a new index
This operation is faster than removing and inserting in a quad in 2 different steps
@since v0.7.2
*/
void insertQuadFromIndex(UINT32 fromIndex, UINT32 newIndex);
void insertQuadFromIndex(unsigned int fromIndex, unsigned int newIndex);
/** removes a quad at a given index number.
The capacity remains the same, but the total number of quads to be drawn is reduced in 1
@since v0.7.2
*/
void removeQuadAtIndex(UINT32 index);
void removeQuadAtIndex(unsigned int index);
/** removes all Quads.
The TextureAtlas capacity remains untouched. No memory is freed.
@ -131,21 +131,21 @@ public:
* It returns YES if the resize was successful.
* If it fails to resize the capacity it will return NO with a new capacity of 0.
*/
bool resizeCapacity(UINT32 n);
bool resizeCapacity(unsigned int n);
/** draws n quads
* n can't be greater than the capacity of the Atlas
*/
void drawNumberOfQuads(UINT32 n);
void drawNumberOfQuads(unsigned int n);
/** draws all the Atlas's Quads
*/
void drawQuads();
private:
void initIndices();
};
#endif //__CCTEXTURE_ATLAS_H__
};
#endif //__CCTEXTURE_ATLAS_H__

View File

@ -26,7 +26,6 @@ THE SOFTWARE.
#define __CCTYPES_H__
#include "cocoa/CGGeometry.h"
#include "platform/platform.h"
#include <GLES/gl.h>
/** RGB color composed of bytes 3 bytes

View File

@ -26,7 +26,7 @@ THE SOFTWARE.
#ifndef __COCOS2D_H__
#define __COCOS2D_H__
#include "platform/platform.h"
//#include "platform/platform.h"
/*
//

View File

@ -1,43 +1,43 @@
/****************************************************************************
Copyright (c) 2010 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include <stdarg.h>
#include "CCLayer.h"
#include "touch_dispatcher/CCTouchDispatcher.h"
#include "CCDirector.h"
#include "support/CGPointExtension.h"
/****************************************************************************
Copyright (c) 2010 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include <stdarg.h>
#include "CCLayer.h"
#include "touch_dispatcher/CCTouchDispatcher.h"
#include "CCDirector.h"
#include "support/CGPointExtension.h"
// CCLayer
CCLayer::CCLayer()
{
CGSize s = CCDirector::getSharedDirector()->getWinSize();
m_tAnchorPoint = ccp(0.5f, 0.5f);
this->setContentSize(s);
m_bIsRelativeAnchorPoint = false;
m_bIsTouchEnabled = false;
m_bIsAccelerometerEnabled = false;
}
m_tAnchorPoint = ccp(0.5f, 0.5f);
this->setContentSize(s);
m_bIsRelativeAnchorPoint = false;
m_bIsTouchEnabled = false;
m_bIsAccelerometerEnabled = false;
}
CCLayer::~CCLayer()
{
@ -60,23 +60,23 @@ bool CCLayer::getIsTouchEnabled()
/// isTouchEnabled setter
void CCLayer::setIsTouchEnabled(bool enabled)
{
if (m_bIsTouchEnabled != enabled)
{
m_bIsTouchEnabled = enabled;
if (m_bIsRunning)
{
if (enabled)
{
this->registerWithTouchDispatcher();
}
else
{
// have problems?
CCTouchDispatcher::getSharedDispatcher()->removeDelegate(static_cast<CCTargetedTouchDelegate*>(this));
CCTouchDispatcher::getSharedDispatcher()->removeDelegate(static_cast<CCStandardTouchDelegate*>(this));
}
}
}
if (m_bIsTouchEnabled != enabled)
{
m_bIsTouchEnabled = enabled;
if (m_bIsRunning)
{
if (enabled)
{
this->registerWithTouchDispatcher();
}
else
{
// have problems?
CCTouchDispatcher::getSharedDispatcher()->removeDelegate(static_cast<CCTargetedTouchDelegate*>(this));
CCTouchDispatcher::getSharedDispatcher()->removeDelegate(static_cast<CCStandardTouchDelegate*>(this));
}
}
}
}
/// isAccelerometerEnabled getter
@ -209,7 +209,7 @@ CCColorLayer* CCColorLayer::initWithColorWidthHeight(ccColor4B color, GLfloat wi
m_tColor.b = color.b;
m_cOpacity = color.a;
for (UINT32 i=0; i<sizeof(m_pSquareVertices) / sizeof(m_pSquareVertices[0]); i++ )
for (unsigned int i=0; i<sizeof(m_pSquareVertices) / sizeof(m_pSquareVertices[0]); i++ )
m_pSquareVertices[i] = 0.0f;
this->updateColor();
@ -251,7 +251,7 @@ void CCColorLayer::changeHeight(GLfloat h)
void CCColorLayer::updateColor()
{
for( UINT32 i=0; i < sizeof(m_pSquareColors) / sizeof(m_pSquareColors[0]); i++ )
for( unsigned int i=0; i < sizeof(m_pSquareColors) / sizeof(m_pSquareColors[0]); i++ )
{
if( i % 4 == 0 )
m_pSquareColors[i] = m_tColor.r;
@ -303,7 +303,7 @@ CCMultiplexLayer::CCMultiplexLayer()
}
CCMultiplexLayer::~CCMultiplexLayer()
{
m_pLayers->release();
m_pLayers->release();
}
CCMultiplexLayer * CCMultiplexLayer::layerWithLayers(CCLayer * layer, ...)

View File

@ -185,7 +185,7 @@ char* CCFileUtils::fullPathFromRelativePath(const char *pszRelativePath)
TUString::StrUnicodeToStrUtf8((Char*)pszUserPath, pszTmp);
char *pszRet;
INT32 nLen = strlen(pszRelativePath) + strlen(pszUserPath) + 1;
int nLen = strlen(pszRelativePath) + strlen(pszUserPath) + 1;
pszRet = new char[nLen];
memset(pszRet, 0, nLen);
strncat(pszRet, pszUserPath, strlen(pszUserPath));

View File

@ -27,9 +27,9 @@ THE SOFTWARE.
// although it is not the same as gettimeofday as unix
// but we only use the diffrences of tow values
INT32 CCTime::gettimeofday(struct cc_timeval *tp, void *tzp)
int CCTime::gettimeofday(struct cc_timeval *tp, void *tzp)
{
UINT32 uSeconds = GetSysSecond();
unsigned int uSeconds = GetSysSecond();
tp->tv_sec = uSeconds;
tp->tv_usec = 0;

View File

@ -43,8 +43,8 @@ public:
bool save(const std::string &strFileName, int nFormat);
UINT32 width(void);
UINT32 height(void);
unsigned int width(void);
unsigned int height(void);
bool isAlphaPixelFormat(void);

View File

@ -1,43 +1,43 @@
/****************************************************************************
Copyright (c) 2010 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "CCSpriteSheet.h"
#include "ccConfig.h"
#include "CCSprite.h"
#include "CCSpriteFrame.h"
#include "CCSpriteFrameCache.h"
#include "CCTextureCache.h"
#include "support/CGPointExtension.h"
#include "CCDrawingPrimitives.h"
#include "cocoa/CGGeometry.h"
#include "CCTexture2D.h"
#include "cocoa/CGAffineTransform.h"
#include "sstsd.h"
#include <string.h>
using namespace std;
/****************************************************************************
Copyright (c) 2010 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "CCSpriteSheet.h"
#include "ccConfig.h"
#include "CCSprite.h"
#include "CCSpriteFrame.h"
#include "CCSpriteFrameCache.h"
#include "CCTextureCache.h"
#include "support/CGPointExtension.h"
#include "CCDrawingPrimitives.h"
#include "cocoa/CGGeometry.h"
#include "CCTexture2D.h"
#include "cocoa/CGAffineTransform.h"
#include "sstsd.h"
#include <string.h>
using namespace std;
#if CC_SPRITESHEET_RENDER_SUBPIXEL
#define RENDER_IN_SUBPIXEL
#else
@ -553,10 +553,10 @@ void CCSprite::draw(void)
#define kQuadSize sizeof(m_sQuad.bl)
glBindTexture(GL_TEXTURE_2D, m_pobTexture->getName());
INT32 offset = (INT32)&m_sQuad;
int offset = (int)&m_sQuad;
// vertex
INT32 diff = offsetof(ccV3F_C4B_T2F, vertices);
int diff = offsetof(ccV3F_C4B_T2F, vertices);
glVertexPointer(3, GL_FLOAT, kQuadSize, (void*)(offset + diff));
// color
@ -592,12 +592,12 @@ CCNode* CCSprite::addChild(CCNode* pChild)
return __super::addChild(pChild);
}
CCNode* CCSprite::addChild(CCNode *pChild, INT32 zOrder)
CCNode* CCSprite::addChild(CCNode *pChild, int zOrder)
{
return __super::addChild(pChild, zOrder);
}
CCNode* CCSprite::addChild(CCNode *pChild, INT32 zOrder, INT32 tag)
CCNode* CCSprite::addChild(CCNode *pChild, int zOrder, int tag)
{
assert(pChild != NULL);
CCNode* pRet = __super::addChild(pChild, zOrder, tag);
@ -606,7 +606,7 @@ CCNode* CCSprite::addChild(CCNode *pChild, INT32 zOrder, INT32 tag)
{
/*
///@todo implement after SpriteSheet is implemented
UINT32 index = m_pobSpriteSheet->atlasIndexForChild(static_cast<CCSprite*>(pChild), zOrder);
unsigned int index = m_pobSpriteSheet->atlasIndexForChild(static_cast<CCSprite*>(pChild), zOrder);
m_pobSpriteSheet->insertChild(static_cast<CCSprite*>(pChild), index);
*/
}
@ -616,7 +616,7 @@ CCNode* CCSprite::addChild(CCNode *pChild, INT32 zOrder, INT32 tag)
return pRet;
}
void CCSprite::reorderChild(CCNode *pChild, INT32 zOrder)
void CCSprite::reorderChild(CCNode *pChild, int zOrder)
{
assert(pChild != NULL);
assert(m_pChildren->containsObject(pChild));

View File

@ -42,7 +42,7 @@ CCSpriteSheet* CCSpriteSheet::spriteSheetWithTexture(CCTexture2D *pobTexture)
return pSpriteSheet;
}
CCSpriteSheet* CCSpriteSheet::spriteSheetWithTexture(CCTexture2D *pobTexture, UINT32 uCapacity)
CCSpriteSheet* CCSpriteSheet::spriteSheetWithTexture(CCTexture2D *pobTexture, unsigned int uCapacity)
{
CCSpriteSheet *pSpriteSheet = new CCSpriteSheet();
pSpriteSheet->initWithTexture(pobTexture, uCapacity);
@ -52,7 +52,7 @@ CCSpriteSheet* CCSpriteSheet::spriteSheetWithTexture(CCTexture2D *pobTexture, UI
}
// creation with file image
CCSpriteSheet* CCSpriteSheet::spriteSheetWithFile(const char *pszFileImage, UINT32 uCapacity)
CCSpriteSheet* CCSpriteSheet::spriteSheetWithFile(const char *pszFileImage, unsigned int uCapacity)
{
CCSpriteSheet *pSpriteSheet = new CCSpriteSheet();
pSpriteSheet->initWithFile(pszFileImage, uCapacity);
@ -71,7 +71,7 @@ CCSpriteSheet* CCSpriteSheet::spriteSheetWithFile(const char *pszFileImage)
}
// init with CCTexture2D
CCSpriteSheet* CCSpriteSheet::initWithTexture(CCTexture2D *pobTexture, UINT32 uCapacity)
CCSpriteSheet* CCSpriteSheet::initWithTexture(CCTexture2D *pobTexture, unsigned int uCapacity)
{
m_blendFunc.src = CC_BLEND_SRC;
m_blendFunc.dst = CC_BLEND_DST;
@ -89,7 +89,7 @@ CCSpriteSheet* CCSpriteSheet::initWithTexture(CCTexture2D *pobTexture, UINT32 uC
}
// init with FileImage
CCSpriteSheet* CCSpriteSheet::initWithFile(const char *pszFileImage, UINT32 uCapacity)
CCSpriteSheet* CCSpriteSheet::initWithFile(const char *pszFileImage, unsigned int uCapacity)
{
CCTexture2D *pTexture2D = CCTextureCache::sharedTextureCache()->addImage(pszFileImage);
return initWithTexture(pTexture2D, uCapacity);
@ -107,12 +107,12 @@ CCSpriteSheet::~CCSpriteSheet(void)
// don't call visit on it's children
void CCSpriteSheet::visit(void)
{
// CAREFUL:
// This visit is almost identical to CocosNode#visit
// with the exception that it doesn't call visit on it's children
//
// The alternative is to have a void CCSprite#visit, but
// although this is less mantainable, is faster
// CAREFUL:
// This visit is almost identical to CocosNode#visit
// with the exception that it doesn't call visit on it's children
//
// The alternative is to have a void CCSprite#visit, but
// although this is less mantainable, is faster
//
if (! m_bIsVisible)
{
@ -123,9 +123,9 @@ void CCSpriteSheet::visit(void)
///@todo implement later
/*
if ( grid_ && grid_.active) {
[grid_ beforeDraw];
[self transformAncestors];
if ( grid_ && grid_.active) {
[grid_ beforeDraw];
[self transformAncestors];
}
*/
@ -135,7 +135,7 @@ void CCSpriteSheet::visit(void)
///@todo: implement later
/*
if ( grid_ && grid_.active)
if ( grid_ && grid_.active)
[grid_ afterDraw:self];
*/
@ -216,7 +216,7 @@ void CCSpriteSheet::removeChild(CCNode *child, bool cleanup)
__super::removeChild(pSprite, cleanup);
}
void CCSpriteSheet::removeChildAtIndex(UINT32 uIndex, bool bDoCleanup)
void CCSpriteSheet::removeChildAtIndex(unsigned int uIndex, bool bDoCleanup)
{
removeChild(static_cast<CCSprite*>(m_pChildren->getObjectAtIndex(uIndex)), bDoCleanup);
}
@ -261,20 +261,20 @@ void CCSpriteSheet::draw(void)
}
#if CC_SPRITESHEET_DEBUG_DRAW
CGRect rect = [child boundingBox]; //Issue #528
CGPoint vertices[4]={
ccp(rect.origin.x,rect.origin.y),
ccp(rect.origin.x+rect.size.width,rect.origin.y),
ccp(rect.origin.x+rect.size.width,rect.origin.y+rect.size.height),
ccp(rect.origin.x,rect.origin.y+rect.size.height),
};
CGRect rect = [child boundingBox]; //Issue #528
CGPoint vertices[4]={
ccp(rect.origin.x,rect.origin.y),
ccp(rect.origin.x+rect.size.width,rect.origin.y),
ccp(rect.origin.x+rect.size.width,rect.origin.y+rect.size.height),
ccp(rect.origin.x,rect.origin.y+rect.size.height),
};
ccDrawPoly(vertices, 4, YES);
#endif // CC_SPRITESHEET_DEBUG_DRAW
}
}
// Default GL states: GL_TEXTURE_2D, GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY
// Needed states: GL_TEXTURE_2D, GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY
// Default GL states: GL_TEXTURE_2D, GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY
// Needed states: GL_TEXTURE_2D, GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY
// Unneeded states: -
bool newBlend = false;
if (m_blendFunc.src != CC_BLEND_SRC || m_blendFunc.dst != CC_BLEND_DST)
@ -292,8 +292,8 @@ void CCSpriteSheet::draw(void)
void CCSpriteSheet::increaseAtlasCapacity(void)
{
// if we're going beyond the current TextureAtlas's capacity,
// all the previously initialized sprites will need to redo their texture coords
// if we're going beyond the current TextureAtlas's capacity,
// all the previously initialized sprites will need to redo their texture coords
// this is likely computationally expensive
unsigned int quantity = (m_pobTextureAtlas->getCapacity() + 1) * 4 / 3;
@ -369,7 +369,7 @@ unsigned int CCSpriteSheet::lowestAtlasIndexInChild(CCSprite *pSprite)
}
}
unsigned int CCSpriteSheet::atlasIndexForChild(CCSprite *pobSprite, INT32 nZ)
unsigned int CCSpriteSheet::atlasIndexForChild(CCSprite *pobSprite, int nZ)
{
NSMutableArray<CCNode*> *pBrothers = pobSprite->getParent()->getChildren();
unsigned int uChildIndex = pBrothers->getIndexOfObject(pobSprite);
@ -430,7 +430,7 @@ unsigned int CCSpriteSheet::atlasIndexForChild(CCSprite *pobSprite, INT32 nZ)
// add child helper
void CCSpriteSheet::insertChild(CCSprite *pobSprite, UINT32 uIndex)
void CCSpriteSheet::insertChild(CCSprite *pobSprite, unsigned int uIndex)
{
pobSprite->useSpriteSheetRender(this);
pobSprite->setAtlasIndex(uIndex);

View File

@ -1,26 +1,26 @@
/****************************************************************************
Copyright (c) 2010 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
/****************************************************************************
Copyright (c) 2010 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include <stdlib.h>
@ -60,7 +60,7 @@ void tgaLoadHeader(FILE *pFile, tImageTGA *psInfo) {
// loads the image pixels. You shouldn't call this function directly
void tgaLoadImageData(FILE *pFile, tImageTGA *psInfo) {
INT32 mode,total,i;
int mode,total,i;
unsigned char aux;
// mode equal the number of components for each pixel
@ -83,9 +83,9 @@ void tgaLoadImageData(FILE *pFile, tImageTGA *psInfo) {
// loads the RLE encoded image pixels. You shouldn't call this function directly
void tgaLoadRLEImageData(FILE *pFile, tImageTGA *psInfo)
{
UINT32 mode,total,i, index = 0;
unsigned int mode,total,i, index = 0;
unsigned char aux[4], runlength = 0;
UINT32 skip = 0, flag = 0;
unsigned int skip = 0, flag = 0;
// mode equal the number of components for each pixel
mode = psInfo->pixelDepth / 8;
@ -141,10 +141,10 @@ void tgaLoadRLEImageData(FILE *pFile, tImageTGA *psInfo)
void tgaFlipImage( tImageTGA *psInfo )
{
// mode equal the number of components for each pixel
INT32 mode = psInfo->pixelDepth / 8;
INT32 rowbytes = psInfo->width*mode;
int mode = psInfo->pixelDepth / 8;
int rowbytes = psInfo->width*mode;
unsigned char *row = (unsigned char *)malloc(rowbytes);
INT32 y;
int y;
if (row == NULL) return;
@ -164,7 +164,7 @@ tImageTGA * tgaLoad(const char *pszFilename) {
FILE *file;
tImageTGA *info;
INT32 mode,total;
int mode,total;
// allocate memory for the info struct and check!
info = (tImageTGA *)malloc(sizeof(tImageTGA));
@ -243,7 +243,7 @@ tImageTGA * tgaLoad(const char *pszFilename) {
// converts RGB to greyscale
void tgaRGBtogreyscale(tImageTGA *psInfo) {
INT32 mode,i,j;
int mode,i,j;
unsigned char *newImageData;

View File

@ -1,32 +1,32 @@
/****************************************************************************
Copyright (c) 2010 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __SUPPORT_DATA_SUPPORT_TGALIB_H__
#define __SUPPORT_DATA_SUPPORT_TGALIB_H__
#include "platform/platform.h"
/****************************************************************************
Copyright (c) 2010 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __SUPPORT_DATA_SUPPORT_TGALIB_H__
#define __SUPPORT_DATA_SUPPORT_TGALIB_H__
#include "platform/platform.h"
enum {
TGA_OK,
TGA_ERROR_FILE_OPEN,
@ -38,7 +38,7 @@ enum {
/** TGA format */
typedef struct sImageTGA {
INT32 status;
int status;
unsigned char type, pixelDepth;
/** map width */
@ -49,7 +49,7 @@ typedef struct sImageTGA {
/** raw data */
unsigned char *imageData;
INT32 flipped;
int flipped;
} tImageTGA;
/// load the image header fields. We only keep those that matter!
@ -65,6 +65,6 @@ tImageTGA * tgaLoad(const char *pszFilename);
void tgaRGBtogreyscale(tImageTGA *psInfo);
/// releases the memory used for the image
void tgaDestroy(tImageTGA *psInfo);
#endif // __SUPPORT_DATA_SUPPORT_TGALIB_H__
void tgaDestroy(tImageTGA *psInfo);
#endif // __SUPPORT_DATA_SUPPORT_TGALIB_H__

View File

@ -1,26 +1,26 @@
/****************************************************************************
Copyright (c) 2010 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
/****************************************************************************
Copyright (c) 2010 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "CCPVRTexture.h"
#include "ccMacros.h"
@ -209,7 +209,7 @@ bool CCPVRTexture::createGLTexture()
glBindTexture(GL_TEXTURE_2D, m_uName);
}
for (UINT32 i=0; i < m_pImageData->count(); i++)
for (unsigned int i=0; i < m_pImageData->count(); i++)
{
/// @todo NSData data = m_pImageData->getObjectAtIndex(i);
/// @todo NSData glCompressedTexImage2D(GL_TEXTURE_2D, i, m_uInternalFormat, width, height, 0, [data length], [data bytes]);
@ -245,11 +245,11 @@ CCPVRTexture * CCPVRTexture::initWithContentsOfFile(const char* path)
m_bRetainName = false; // cocos2d integration
/// @todo
// if (!data || ![self unpackPVRData:data] || ![self createGLTexture])
// {
// [self release];
// self = nil;
// }
// if (!data || ![self unpackPVRData:data] || ![self createGLTexture])
// {
// [self release];
// self = nil;
// }
return this;
}

View File

@ -1,35 +1,35 @@
/****************************************************************************
Copyright (c) 2010 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
/****************************************************************************
Copyright (c) 2010 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
/*
* Support for RGBA_4_4_4_4 and RGBA_5_5_5_1 was copied from:
* https://devforums.apple.com/message/37855#37855 by a1studmuffin
*/
#include "CCTexture2D.h"
#include "CCTexture2D.h"
#include <GLES/glext.h>
#include "ccConfig.h"
@ -82,12 +82,12 @@ CCTexture2DPixelFormat CCTexture2D::getPixelFormat()
return m_ePixelFormat;
}
UINT32 CCTexture2D::getPixelsWide()
unsigned int CCTexture2D::getPixelsWide()
{
return m_uPixelsWide;
}
UINT32 CCTexture2D::getPixelsHigh()
unsigned int CCTexture2D::getPixelsHigh()
{
return m_uPixelsHigh;
}
@ -127,7 +127,7 @@ bool CCTexture2D::getHasPremultipliedAlpha()
return m_bHasPremultipliedAlpha;
}
CCTexture2D * CCTexture2D::initWithData(const void *data, CCTexture2DPixelFormat pixelFormat, UINT32 pixelsWide, UINT32 pixelsHigh, CGSize contentSize)
CCTexture2D * CCTexture2D::initWithData(const void *data, CCTexture2DPixelFormat pixelFormat, unsigned int pixelsWide, unsigned int pixelsHigh, CGSize contentSize)
{
glGenTextures(1, &m_uName);
glBindTexture(GL_TEXTURE_2D, m_uName);
@ -173,10 +173,10 @@ CCTexture2D * CCTexture2D::initWithData(const void *data, CCTexture2DPixelFormat
std::string CCTexture2D::description(void)
{
char des[100];
sprintf_s(des, 100, "<CCTexture2D | Name = %u | Dimensions = %u x %u | Coordinates = (%.2f, %.2f)>", m_uName, m_uPixelsWide, m_uPixelsHigh, m_fMaxS, m_fMaxT);
std::string ret(des);
char des[100];
sprintf_s(des, 100, "<CCTexture2D | Name = %u | Dimensions = %u x %u | Coordinates = (%.2f, %.2f)>", m_uName, m_uPixelsWide, m_uPixelsHigh, m_fMaxS, m_fMaxT);
std::string ret(des);
return ret;
}
@ -184,7 +184,7 @@ std::string CCTexture2D::description(void)
CCTexture2D* CCTexture2D::initWithImage(UIImage * uiImage)
{
UINT32 POTWide, POTHigh;
unsigned int POTWide, POTHigh;
if(uiImage == NULL)
{
@ -221,9 +221,9 @@ CCTexture2D* CCTexture2D::initWithImage(UIImage * uiImage)
return this;
}
/// @todo to be checked
CCTexture2D * CCTexture2D::initPremultipliedATextureWithImage(UIImage *image, UINT32 POTWide, UINT32 POTHigh)
CCTexture2D * CCTexture2D::initPremultipliedATextureWithImage(UIImage *image, unsigned int POTWide, unsigned int POTHigh)
{
UINT32 i;
unsigned int i;
void* data = NULL;
void* tempData =NULL;
unsigned int* inPixel32 = NULL;
@ -264,25 +264,25 @@ CCTexture2D * CCTexture2D::initPremultipliedATextureWithImage(UIImage *image, UI
case kCCTexture2DPixelFormat_RGB5A1:
// colorSpace = CGColorSpaceCreateDeviceRGB();
// data = malloc(POTHigh * POTWide * 4);
// info = hasAlpha ? kCGImageAlphaPremultipliedLast : kCGImageAlphaNoneSkipLast;
// context = CGBitmapContextCreate(data, POTWide, POTHigh, 8, 4 * POTWide, colorSpace, info | kCGBitmapByteOrder32Big);
// CGColorSpaceRelease(colorSpace);
// info = hasAlpha ? kCGImageAlphaPremultipliedLast : kCGImageAlphaNoneSkipLast;
// context = CGBitmapContextCreate(data, POTWide, POTHigh, 8, 4 * POTWide, colorSpace, info | kCGBitmapByteOrder32Big);
// CGColorSpaceRelease(colorSpace);
// break;
case kCCTexture2DPixelFormat_RGB565:
// colorSpace = CGColorSpaceCreateDeviceRGB();
// data = malloc(POTHigh * POTWide * 4);
// info = kCGImageAlphaNoneSkipLast;
// context = CGBitmapContextCreate(data, POTWide, POTHigh, 8, 4 * POTWide, colorSpace, info | kCGBitmapByteOrder32Big);
// CGColorSpaceRelease(colorSpace);
// info = kCGImageAlphaNoneSkipLast;
// context = CGBitmapContextCreate(data, POTWide, POTHigh, 8, 4 * POTWide, colorSpace, info | kCGBitmapByteOrder32Big);
// CGColorSpaceRelease(colorSpace);
// break;
case kCCTexture2DPixelFormat_A8:
// data = malloc(POTHigh * POTWide);
// info = kCGImageAlphaOnly;
// context = CGBitmapContextCreate(data, POTWide, POTHigh, 8, POTWide, NULL, info);
/// @todo Get image data and convert to POT mode
tempData = static_cast<void*>(image->getRGBA8888Data());
NSAssert(tempData != NULL, "NULL image data.");
// info = kCGImageAlphaOnly;
// context = CGBitmapContextCreate(data, POTWide, POTHigh, 8, POTWide, NULL, info);
/// @todo Get image data and convert to POT mode
tempData = static_cast<void*>(image->getRGBA8888Data());
NSAssert(tempData != NULL, "NULL image data.");
if(image->width() == POTWide && image->height() == POTHigh)
{
data = tempData;
@ -295,12 +295,12 @@ CCTexture2D * CCTexture2D::initPremultipliedATextureWithImage(UIImage *image, UI
UINT8* pPixelData = (UINT8*) tempData;
UINT8* pTargetData = (UINT8*) data;
for(UINT32 y=0; y<image->height(); ++y)
for(unsigned int y=0; y<image->height(); ++y)
{
memcpy(pTargetData+POTWide*4*y, pPixelData+(image->width())*4*y, (image->width())*4);
}
CCX_SAFE_DELETE(tempData);
}
}
break;
default:
NSAssert(0, "Invalid pixel format");
@ -308,9 +308,9 @@ CCTexture2D * CCTexture2D::initPremultipliedATextureWithImage(UIImage *image, UI
}
// CGContextClearRect(context, CGRectMake(0, 0, POTWide, POTHigh));
// CGContextTranslateCTM(context, 0, POTHigh - imageSize.height);
// CGContextDrawImage(context, CGRectMake(0, 0, CGImageGetWidth(image), CGImageGetHeight(image)), image);
// CGContextClearRect(context, CGRectMake(0, 0, POTWide, POTHigh));
// CGContextTranslateCTM(context, 0, POTHigh - imageSize.height);
// CGContextDrawImage(context, CGRectMake(0, 0, CGImageGetWidth(image), CGImageGetHeight(image)), image);
// Repack the pixel data into the right format
@ -359,8 +359,8 @@ CCTexture2D * CCTexture2D::initPremultipliedATextureWithImage(UIImage *image, UI
data = tempData;
}
if (data)
{
if (data)
{
this->initWithData(data, pixelFormat, POTWide, POTHigh, imageSize);
// should be after calling super init
@ -368,7 +368,7 @@ CCTexture2D * CCTexture2D::initPremultipliedATextureWithImage(UIImage *image, UI
//CGContextRelease(context);
CCX_SAFE_DELETE(data);
}
}
return this;
}
@ -544,12 +544,12 @@ CCTexture2D * CCTexture2D::initWithPVRTCData(const void *data, int level, int bp
CCTexture2D * CCTexture2D::initWithPVRTCFile(const char* file)
{
if (! CCConfiguration::sharedConfiguration()->isSupportsPVRTC())
{
if (! CCConfiguration::sharedConfiguration()->isSupportsPVRTC())
{
CCLOG("cocos2d: WARNING: PVRTC images is not supported");
this->release();
return NULL;
}
}
CCPVRTexture *pvr = new CCPVRTexture();
pvr = pvr->initWithContentsOfFile(file);
@ -562,7 +562,7 @@ CCTexture2D * CCTexture2D::initWithPVRTCFile(const char* file)
m_fMaxT = 1.0f;
m_uPixelsWide = pvr->getWidth(); // width
m_uPixelsHigh = pvr->getHeight(); // height
/// be careful : UINT32 to float
/// be careful : unsigned int to float
m_tContentSize = CGSizeMake(static_cast<float>(m_uPixelsWide), static_cast<float>(m_uPixelsHigh));
pvr->release();
@ -629,4 +629,4 @@ CCTexture2DPixelFormat CCTexture2D::defaultAlphaPixelFormat()
{
return g_defaultAlphaPixelFormat;
}

View File

@ -1,27 +1,27 @@
/****************************************************************************
Copyright (c) 2010 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
/****************************************************************************
Copyright (c) 2010 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "Cocos2dDefine.h"
// cocos2d
#include "CCTextureAtlas.h"
@ -31,6 +31,8 @@ THE SOFTWARE.
// support
#include "CCTexture2D.h"
#include <math.h>
//According to some tests GL_TRIANGLE_STRIP is slower, MUCH slower. Probably I'm doing something very wrong
// implementation CCTextureAtlas
@ -55,12 +57,12 @@ CCTextureAtlas::~CCTextureAtlas()
m_pTexture->release();
}
UINT32 CCTextureAtlas::getTotalQuads()
unsigned int CCTextureAtlas::getTotalQuads()
{
return m_uTotalQuads;
}
UINT32 CCTextureAtlas::getCapacity()
unsigned int CCTextureAtlas::getCapacity()
{
return m_uCapacity;
}
@ -87,7 +89,7 @@ void CCTextureAtlas::setQuads(ccV3F_C4B_T2F_Quad *var)
// TextureAtlas - alloc & init
CCTextureAtlas * CCTextureAtlas::textureAtlasWithFile(const char* file, UINT32 capacity)
CCTextureAtlas * CCTextureAtlas::textureAtlasWithFile(const char* file, unsigned int capacity)
{
CCTextureAtlas * pTextureAtlas = new CCTextureAtlas();
pTextureAtlas->initWithFile(file, capacity);
@ -95,7 +97,7 @@ CCTextureAtlas * CCTextureAtlas::textureAtlasWithFile(const char* file, UINT32 c
return pTextureAtlas;
}
CCTextureAtlas * CCTextureAtlas::textureAtlasWithTexture(CCTexture2D *tex, UINT32 capacity)
CCTextureAtlas * CCTextureAtlas::textureAtlasWithTexture(CCTexture2D *tex, unsigned int capacity)
{
CCTextureAtlas * pTextureAtlas = new CCTextureAtlas();
pTextureAtlas->initWithTexture(tex, capacity);
@ -103,7 +105,7 @@ CCTextureAtlas * CCTextureAtlas::textureAtlasWithTexture(CCTexture2D *tex, UINT3
return pTextureAtlas;
}
CCTextureAtlas * CCTextureAtlas::initWithFile(const char * file, UINT32 capacity)
CCTextureAtlas * CCTextureAtlas::initWithFile(const char * file, unsigned int capacity)
{
// retained in property
CCTexture2D *tex = CCTextureCache::sharedTextureCache()->addImage(file);
@ -111,7 +113,7 @@ CCTextureAtlas * CCTextureAtlas::initWithFile(const char * file, UINT32 capacity
return initWithTexture(tex, capacity);
}
CCTextureAtlas * CCTextureAtlas::initWithTexture(CCTexture2D *tex, UINT32 capacity)
CCTextureAtlas * CCTextureAtlas::initWithTexture(CCTexture2D *tex, unsigned int capacity)
{
m_uCapacity = capacity;
@ -142,17 +144,17 @@ CCTextureAtlas * CCTextureAtlas::initWithTexture(CCTexture2D *tex, UINT32 capaci
std::string CCTextureAtlas::description()
{
char des[100];
sprintf_s(des, 100, "<CCTextureAtlas | totalQuads = %u>", m_uTotalQuads);
std::string ret(des);
char des[100];
sprintf_s(des, 100, "<CCTextureAtlas | totalQuads = %u>", m_uTotalQuads);
std::string ret(des);
return ret;
}
void CCTextureAtlas::initIndices()
{
for( UINT32 i=0; i < m_uCapacity; i++)
for( unsigned int i=0; i < m_uCapacity; i++)
{
#if CC_TEXTURE_ATLAS_USE_TRIANGLE_STRIP
m_pIndices[i*6+0] = i*4+0;
@ -188,16 +190,16 @@ void CCTextureAtlas::initIndices()
// TextureAtlas - Update, Insert, Move & Remove
void CCTextureAtlas::updateQuad(ccV3F_C4B_T2F_Quad *quad, UINT32 index)
void CCTextureAtlas::updateQuad(ccV3F_C4B_T2F_Quad *quad, unsigned int index)
{
NSAssert( index >= 0 && index < m_uCapacity, "updateQuadWithTexture: Invalid index");
m_uTotalQuads = MAX( index+1, m_uTotalQuads);
m_uTotalQuads = max( index+1, m_uTotalQuads);
m_pQuads[index] = *quad;
}
void CCTextureAtlas::insertQuad(ccV3F_C4B_T2F_Quad *quad, UINT32 index)
void CCTextureAtlas::insertQuad(ccV3F_C4B_T2F_Quad *quad, unsigned int index)
{
NSAssert( index >= 0 && index < m_uCapacity, "insertQuadWithTexture: Invalid index");
@ -216,7 +218,7 @@ void CCTextureAtlas::insertQuad(ccV3F_C4B_T2F_Quad *quad, UINT32 index)
m_pQuads[index] = *quad;
}
void CCTextureAtlas::insertQuadFromIndex(UINT32 oldIndex, UINT32 newIndex)
void CCTextureAtlas::insertQuadFromIndex(unsigned int oldIndex, unsigned int newIndex)
{
NSAssert( newIndex >= 0 && newIndex < m_uTotalQuads, "insertQuadFromIndex:atIndex: Invalid index");
NSAssert( oldIndex >= 0 && oldIndex < m_uTotalQuads, "insertQuadFromIndex:atIndex: Invalid index");
@ -224,7 +226,7 @@ void CCTextureAtlas::insertQuadFromIndex(UINT32 oldIndex, UINT32 newIndex)
if( oldIndex == newIndex )
return;
UINT32 howMany = std::abs( oldIndex - newIndex);
unsigned int howMany = std::abs( oldIndex - newIndex);
int dst = oldIndex;
int src = oldIndex + 1;
if( oldIndex > newIndex) {
@ -238,11 +240,11 @@ void CCTextureAtlas::insertQuadFromIndex(UINT32 oldIndex, UINT32 newIndex)
m_pQuads[newIndex] = quadsBackup;
}
void CCTextureAtlas::removeQuadAtIndex(UINT32 index)
void CCTextureAtlas::removeQuadAtIndex(unsigned int index)
{
NSAssert( index >= 0 && index < m_uTotalQuads, "removeQuadAtIndex: Invalid index");
UINT32 remaining = (m_uTotalQuads-1) - index;
unsigned int remaining = (m_uTotalQuads-1) - index;
// last object doesn't need to be moved
@ -262,13 +264,13 @@ void CCTextureAtlas::removeAllQuads()
}
// TextureAtlas - Resize
bool CCTextureAtlas::resizeCapacity(UINT32 newCapacity)
bool CCTextureAtlas::resizeCapacity(unsigned int newCapacity)
{
if( newCapacity == m_uCapacity )
return true;
// update capacity and totolQuads
m_uTotalQuads = MIN(m_uTotalQuads, newCapacity);
m_uTotalQuads = min(m_uTotalQuads, newCapacity);
m_uCapacity = newCapacity;
void * tmpQuads = realloc( m_pQuads, sizeof(m_pQuads[0]) * m_uCapacity );
@ -307,7 +309,7 @@ void CCTextureAtlas::drawQuads()
this->drawNumberOfQuads(m_uTotalQuads);
}
void CCTextureAtlas::drawNumberOfQuads(UINT32 n)
void CCTextureAtlas::drawNumberOfQuads(unsigned int n)
{
glBindTexture(GL_TEXTURE_2D, m_pTexture->getName());
@ -365,4 +367,4 @@ void CCTextureAtlas::drawNumberOfQuads(UINT32 n)
#endif // CC_TEXTURE_ATLAS_USES_VBO
}

View File

@ -1,35 +1,34 @@
/****************************************************************************
Copyright (c) 2010 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include <stack>
#include <string>
/****************************************************************************
Copyright (c) 2010 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include <stack>
#include <string>
#include <cctype>
#include "CCTextureCache.h"
#include "CCTexture2D.h"
#include "ccMacros.h"
#include "cocoa/NSData.h"
#include "platform/platform.h"
#include "CCDirector.h"
/// @todo EAGLContext static EAGLContext *auxEAGLcontext = NULL;
@ -77,13 +76,13 @@ CCTextureCache::~CCTextureCache()
{
CCLOG("cocos2d: deallocing CCTextureCache.");
/// @todo release
// [textures release];
// [dictLock release];
// [contextLock release];
// [auxEAGLcontext release];
// auxEAGLcontext = nil;
// sharedTextureCache = nil;
// [super dealloc];
// [textures release];
// [dictLock release];
// [contextLock release];
// [auxEAGLcontext release];
// auxEAGLcontext = nil;
// sharedTextureCache = nil;
// [super dealloc];
}
void CCTextureCache::purgeSharedTextureCache()
@ -94,10 +93,10 @@ void CCTextureCache::purgeSharedTextureCache()
std::string CCTextureCache::description()
{
char des[100];
sprintf_s(des, 100, "<CCTextureCache | Number of textures = %u>", m_pTextures->count());
std::string ret(des);
char des[100];
sprintf_s(des, 100, "<CCTextureCache | Number of textures = %u>", m_pTextures->count());
std::string ret(des);
return ret;
}
@ -146,26 +145,30 @@ void CCTextureCache::addImageAsync(const char* filename, NSObject *target, fpAsy
// optimization
CCTexture2D * tex;
//
// if ( (tex = m_pTextures->objectForKey(filename)) )
// {
// target->
// }
//
// if( (tex=[textures objectForKey: filename] ) ) {
// [target performSelector:selector withObject:tex];
// return;
// }
//
// // schedule the load
//
// CCAsyncObject *asyncObject = [[CCAsyncObject alloc] init];
// asyncObject.selector = selector;
// asyncObject.target = target;
// asyncObject.data = filename;
//
// [NSThread detachNewThreadSelector:@selector(addImageWithAsyncObject:) toTarget:self withObject:asyncObject];
// [asyncObject release];
//
// if ( (tex = m_pTextures->objectForKey(filename)) )
// {
// target->
// }
//
// if( (tex=[textures objectForKey: filename] ) ) {
// [target performSelector:selector withObject:tex];
// return;
// }
//
// // schedule the load
//
// CCAsyncObject *asyncObject = [[CCAsyncObject alloc] init];
// asyncObject.selector = selector;
// asyncObject.target = target;
// asyncObject.data = filename;
//
// [NSThread detachNewThreadSelector:@selector(addImageWithAsyncObject:) toTarget:self withObject:asyncObject];
// [asyncObject release];
}
CCTexture2D * CCTextureCache::addImage(const char * path)
@ -189,12 +192,12 @@ CCTexture2D * CCTextureCache::addImage(const char * path)
// all images are handled by UIImage except PVR extension that is handled by our own handler
// if ( [[path lowercaseString] hasSuffix:@".pvr"] )
for (UINT32 i = 0; i < temp.length(); ++i)
for (unsigned int i = 0; i < temp.length(); ++i)
temp[i] = tolower(temp[i]);
if (temp.find(".pvr"))
{
tex = this->addPVRTCImage(fullpath.c_str());
}
if (temp.find(".pvr"))
{
tex = this->addPVRTCImage(fullpath.c_str());
}
else
{
// prevents overloading the autorelease pool
@ -227,10 +230,10 @@ CCTexture2D* CCTextureCache::addPVRTCImage(const char* path, int bpp, bool hasAl
CCTexture2D * tex;
std::string temp(path);
if ( (tex = m_pTextures->objectForKey(temp)) )
{
return tex;
}
if ( (tex = m_pTextures->objectForKey(temp)) )
{
return tex;
}
// Split up directory and filename
std::string fullpath( CCFileUtils::fullPathFromRelativePath(path) );
@ -307,15 +310,15 @@ void CCTextureCache::removeUnusedTextures()
{
std::vector<std::string> keys = m_pTextures->allKeys();
std::vector<std::string>::iterator it;
for (it = keys.begin(); it <= keys.end(); it++)
{
CCTexture2D *value = m_pTextures->objectForKey(*it);
if (value->retainCount() == 1)
{
CCLOG("cocos2d: CCTextureCache: removing unused texture: %s", (*it).c_str());
m_pTextures->removeObjectForKey(*it);
}
}
for (it = keys.begin(); it <= keys.end(); it++)
{
CCTexture2D *value = m_pTextures->objectForKey(*it);
if (value->retainCount() == 1)
{
CCLOG("cocos2d: CCTextureCache: removing unused texture: %s", (*it).c_str());
m_pTextures->removeObjectForKey(*it);
}
}
}
void CCTextureCache::removeTexture(CCTexture2D* tex)
@ -325,10 +328,10 @@ void CCTextureCache::removeTexture(CCTexture2D* tex)
std::vector<std::string> keys = m_pTextures->allKeysForObject(tex);
for (UINT32 i = 0; i < keys.size(); i++)
{
m_pTextures->removeObjectForKey(keys[i]);
}
for (unsigned int i = 0; i < keys.size(); i++)
{
m_pTextures->removeObjectForKey(keys[i]);
}
}
void CCTextureCache::removeTextureForKey(const std::string & textureKeyName)

View File

@ -56,13 +56,13 @@ CCTouchDispatcher* CCTouchDispatcher::getSharedDispatcher(void)
}
/*
+(id) allocWithZone:(NSZone *)zone
{
@synchronized(self) {
NSAssert(sharedDispatcher == nil, @"Attempted to allocate a second instance of a singleton.");
return [super allocWithZone:zone];
}
return nil; // on subsequent allocation attempts return nil
+(id) allocWithZone:(NSZone *)zone
{
@synchronized(self) {
NSAssert(sharedDispatcher == nil, @"Attempted to allocate a second instance of a singleton.");
return [super allocWithZone:zone];
}
return nil; // on subsequent allocation attempts return nil
}
*/
@ -96,12 +96,12 @@ CCTouchDispatcher::~CCTouchDispatcher(void)
m_pHandlersToRemove->release();
}
//
// handlers management
//
// handlers management
//
void CCTouchDispatcher::forceAddHandler(CCTouchHandler *pHandler, NSMutableArray<CCTouchHandler*> *pArray)
{
UINT32 u = 0;
unsigned int u = 0;
NSMutableArray<CCTouchHandler*>::NSMutableArrayIterator iter;
for (iter = pArray->begin(); iter != pArray->end(); ++iter)
@ -226,10 +226,10 @@ void CCTouchDispatcher::setPriority(int nPriority, CCTouchDelegate *pDelegate)
assert(0);
}
//
// dispatch events
//
void CCTouchDispatcher::touches(NSSet *pTouches, UIEvent *pEvent, UINT32 uIndex)
// dispatch events
//
void CCTouchDispatcher::touches(NSSet *pTouches, UIEvent *pEvent, unsigned int uIndex)
{
assert(uIndex > 0 && uIndex < 4);
@ -237,15 +237,15 @@ void CCTouchDispatcher::touches(NSSet *pTouches, UIEvent *pEvent, UINT32 uIndex)
m_bLocked = true;
// optimization to prevent a mutable copy when it is not necessary
UINT32 uTargetedHandlersCount = m_pTargetedHandlers->count();
UINT32 uStandardHandlersCount = m_pStandardHandlers->count();
unsigned int uTargetedHandlersCount = m_pTargetedHandlers->count();
unsigned int uStandardHandlersCount = m_pStandardHandlers->count();
bool bNeedsMutableSet = (uTargetedHandlersCount && uStandardHandlersCount);
pMutableTouches = (bNeedsMutableSet ? pTouches->mutableCopy() : pTouches);
struct ccTouchHandlerHelperData sHelper = m_sHandlerHelperData[uIndex];
//
// process the target handlers 1st
//
// process the target handlers 1st
//
if (uTargetedHandlersCount > 0)
{
@ -301,8 +301,8 @@ void CCTouchDispatcher::touches(NSSet *pTouches, UIEvent *pEvent, UINT32 uIndex)
}
}
//
// process standard handlers 2nd
//
// process standard handlers 2nd
//
if (uStandardHandlersCount > 0 && pMutableTouches->count() > 0)
{
@ -335,9 +335,9 @@ void CCTouchDispatcher::touches(NSSet *pTouches, UIEvent *pEvent, UINT32 uIndex)
pMutableTouches->release();
}
//
// Optimization. To prevent a [handlers copy] which is expensive
// the add/removes/quit is done after the iterations
//
// Optimization. To prevent a [handlers copy] which is expensive
// the add/removes/quit is done after the iterations
//
m_bLocked = false;
if (m_bToRemove)

View File

@ -29,60 +29,60 @@ THE SOFTWARE.
#include "cocoa/NSObject.h"
#include "cocoa/NSMutableArray.h"
typedef enum
{
ccTouchSelectorBeganBit = 1 << 0,
ccTouchSelectorMovedBit = 1 << 1,
ccTouchSelectorEndedBit = 1 << 2,
ccTouchSelectorCancelledBit = 1 << 3,
ccTouchSelectorAllBits = ( ccTouchSelectorBeganBit | ccTouchSelectorMovedBit | ccTouchSelectorEndedBit | ccTouchSelectorCancelledBit),
} ccTouchSelectorFlag;
enum {
ccTouchBegan,
ccTouchMoved,
ccTouchEnded,
ccTouchCancelled,
ccTouchMax,
};
class NSSet;
class UIEvent;
struct ccTouchHandlerHelperData {
// we only use the type
typedef enum
{
ccTouchSelectorBeganBit = 1 << 0,
ccTouchSelectorMovedBit = 1 << 1,
ccTouchSelectorEndedBit = 1 << 2,
ccTouchSelectorCancelledBit = 1 << 3,
ccTouchSelectorAllBits = ( ccTouchSelectorBeganBit | ccTouchSelectorMovedBit | ccTouchSelectorEndedBit | ccTouchSelectorCancelledBit),
} ccTouchSelectorFlag;
enum {
ccTouchBegan,
ccTouchMoved,
ccTouchEnded,
ccTouchCancelled,
ccTouchMax,
};
class NSSet;
class UIEvent;
struct ccTouchHandlerHelperData {
// we only use the type
// void (StandardTouchDelegate::*touchesSel)(NSSet*, UIEvent*);
// void (TargetedTouchDelegate::*touchSel)(NSTouch*, UIEvent*);
int m_type;
int m_type;
};
class EGLTouchDelegate
{
public:
virtual void touchesBegan(NSSet* touches, UIEvent* pEvent) = 0;
virtual void touchesMoved(NSSet* touches, UIEvent* pEvent) = 0;
virtual void touchesEnded(NSSet* touches, UIEvent* pEvent) = 0;
virtual void touchesBegan(NSSet* touches, UIEvent* pEvent) = 0;
virtual void touchesMoved(NSSet* touches, UIEvent* pEvent) = 0;
virtual void touchesEnded(NSSet* touches, UIEvent* pEvent) = 0;
virtual void touchesCancelled(NSSet* touches, UIEvent* pEvent) = 0;
};
/** CCTouchDispatcher.
Singleton that handles all the touch events.
The dispatcher dispatches events to the registered TouchHandlers.
There are 2 different type of touch handlers:
- Standard Touch Handlers
- Targeted Touch Handlers
The Standard Touch Handlers work like the CocoaTouch touch handler: a set of touches is passed to the delegate.
On the other hand, the Targeted Touch Handlers only receive 1 touch at the time, and they can "swallow" touches (avoid the propagation of the event).
Firstly, the dispatcher sends the received touches to the targeted touches.
These touches can be swallowed by the Targeted Touch Handlers. If there are still remaining touches, then the remaining touches will be sent
to the Standard Touch Handlers.
@since v0.8.0
/** CCTouchDispatcher.
Singleton that handles all the touch events.
The dispatcher dispatches events to the registered TouchHandlers.
There are 2 different type of touch handlers:
- Standard Touch Handlers
- Targeted Touch Handlers
The Standard Touch Handlers work like the CocoaTouch touch handler: a set of touches is passed to the delegate.
On the other hand, the Targeted Touch Handlers only receive 1 touch at the time, and they can "swallow" touches (avoid the propagation of the event).
Firstly, the dispatcher sends the received touches to the targeted touches.
These touches can be swallowed by the Targeted Touch Handlers. If there are still remaining touches, then the remaining touches will be sent
to the Standard Touch Handlers.
@since v0.8.0
*/
class CCTouchHandler;
class CCTouchDispatcher : public NSObject, public EGLTouchDelegate
@ -97,35 +97,35 @@ public:
bool isDispatchEvents(void);
void setDispatchEvents(bool bDispatchEvents);
/** Adds a standard touch delegate to the dispatcher's list.
See StandardTouchDelegate description.
IMPORTANT: The delegate will be retained.
/** Adds a standard touch delegate to the dispatcher's list.
See StandardTouchDelegate description.
IMPORTANT: The delegate will be retained.
*/
void addStandardDelegate(CCStandardTouchDelegate *pDelegate, int nPriority);
/** Adds a targeted touch delegate to the dispatcher's list.
See TargetedTouchDelegate description.
IMPORTANT: The delegate will be retained.
/** Adds a targeted touch delegate to the dispatcher's list.
See TargetedTouchDelegate description.
IMPORTANT: The delegate will be retained.
*/
void addTargetedDelegate(CCTargetedTouchDelegate *pDelegate, int nPriority, bool bSwallowsTouches);
/** Removes a touch delegate.
The delegate will be released
/** Removes a touch delegate.
The delegate will be released
*/
void removeDelegate(CCTouchDelegate *pDelegate);
// Removes all touch delegates, releasing all the delegates
void removeAllDelegates(void);
/** Changes the priority of a previously added delegate. The lower the number,
/** Changes the priority of a previously added delegate. The lower the number,
the higher the priority */
void setPriority(int nPriority, CCTouchDelegate *pDelegate);
void touches(NSSet *pTouches, UIEvent *pEvent, UINT32 uIndex);
void touches(NSSet *pTouches, UIEvent *pEvent, unsigned int uIndex);
virtual void touchesBegan(NSSet* touches, UIEvent* pEvent);
virtual void touchesMoved(NSSet* touches, UIEvent* pEvent);
virtual void touchesEnded(NSSet* touches, UIEvent* pEvent);
virtual void touchesBegan(NSSet* touches, UIEvent* pEvent);
virtual void touchesMoved(NSSet* touches, UIEvent* pEvent);
virtual void touchesEnded(NSSet* touches, UIEvent* pEvent);
virtual void touchesCancelled(NSSet* touches, UIEvent* pEvent);
public:

View File

@ -36,27 +36,27 @@ void CCTouchHandler::setDelegate(CCTouchDelegate *pDelegate)
m_pDelegate = pDelegate;
}
INT32 CCTouchHandler::getPriority(void)
int CCTouchHandler::getPriority(void)
{
return m_nPriority;
}
void CCTouchHandler::setPriority(Int32 nPriority)
void CCTouchHandler::setPriority(int nPriority)
{
m_nPriority = nPriority;
}
INT32 CCTouchHandler::getEnabledSelectors(void)
int CCTouchHandler::getEnabledSelectors(void)
{
return m_nEnabledSelectors;
}
void CCTouchHandler::setEnalbedSelectors(Int32 nValue)
void CCTouchHandler::setEnalbedSelectors(int nValue)
{
m_nEnabledSelectors = nValue;
}
CCTouchHandler* CCTouchHandler::handlerWithDelegate(CCTouchDelegate *pDelegate, Int32 nPriority)
CCTouchHandler* CCTouchHandler::handlerWithDelegate(CCTouchDelegate *pDelegate, int nPriority)
{
CCTouchHandler *pHandler = new CCTouchHandler();
pHandler->autorelease();
@ -64,7 +64,7 @@ CCTouchHandler* CCTouchHandler::handlerWithDelegate(CCTouchDelegate *pDelegate,
return pHandler->initWithDelegate(pDelegate, nPriority);
}
CCTouchHandler* CCTouchHandler::initWithDelegate(CCTouchDelegate *pDelegate, Int32 nPriority)
CCTouchHandler* CCTouchHandler::initWithDelegate(CCTouchDelegate *pDelegate, int nPriority)
{
assert(pDelegate != NULL);
@ -81,19 +81,19 @@ CCTouchHandler::~CCTouchHandler(void)
}
// implementation of CCStandardTouchHandler
CCTouchHandler* CCStandardTouchHandler::initWithDelegate(CCTouchDelegate *pDelegate, Int32 nPriority)
CCTouchHandler* CCStandardTouchHandler::initWithDelegate(CCTouchDelegate *pDelegate, int nPriority)
{
if (__super::initWithDelegate(pDelegate, nPriority))
{
/*
* we can not do this in c++
if( [del respondsToSelector:@selector(ccTouchesBegan:withEvent:)] )
enabledSelectors_ |= ccTouchSelectorBeganBit;
if( [del respondsToSelector:@selector(ccTouchesMoved:withEvent:)] )
enabledSelectors_ |= ccTouchSelectorMovedBit;
if( [del respondsToSelector:@selector(ccTouchesEnded:withEvent:)] )
enabledSelectors_ |= ccTouchSelectorEndedBit;
if( [del respondsToSelector:@selector(ccTouchesCancelled:withEvent:)] )
if( [del respondsToSelector:@selector(ccTouchesBegan:withEvent:)] )
enabledSelectors_ |= ccTouchSelectorBeganBit;
if( [del respondsToSelector:@selector(ccTouchesMoved:withEvent:)] )
enabledSelectors_ |= ccTouchSelectorMovedBit;
if( [del respondsToSelector:@selector(ccTouchesEnded:withEvent:)] )
enabledSelectors_ |= ccTouchSelectorEndedBit;
if( [del respondsToSelector:@selector(ccTouchesCancelled:withEvent:)] )
enabledSelectors_ |= ccTouchSelectorCancelledBit;
*/
}
@ -101,7 +101,7 @@ CCTouchHandler* CCStandardTouchHandler::initWithDelegate(CCTouchDelegate *pDeleg
return this;
}
CCStandardTouchHandler* CCStandardTouchHandler::handlerWithDelegate(CCStandardTouchDelegate *pDelegate, Int32 nPriority)
CCStandardTouchHandler* CCStandardTouchHandler::handlerWithDelegate(CCStandardTouchDelegate *pDelegate, int nPriority)
{
CCStandardTouchHandler* pTouchHandler = new CCStandardTouchHandler();
@ -128,7 +128,7 @@ NSMutableSet* CCTargetedTouchHandler::getClaimedTouches(void)
return m_pClaimedTouches;
}
CCTargetedTouchHandler* CCTargetedTouchHandler::handlerWithDelegate(CCTouchDelegate *pDelegate, Int32 nPriority, bool bSwallow)
CCTargetedTouchHandler* CCTargetedTouchHandler::handlerWithDelegate(CCTouchDelegate *pDelegate, int nPriority, bool bSwallow)
{
CCTargetedTouchHandler *pTargetedHandler = new CCTargetedTouchHandler();
pTargetedHandler->initWithDelegate(pDelegate, nPriority, bSwallow);
@ -137,7 +137,7 @@ CCTargetedTouchHandler* CCTargetedTouchHandler::handlerWithDelegate(CCTouchDeleg
return pTargetedHandler;
}
CCTouchHandler* CCTargetedTouchHandler::initWithDelegate(CCTouchDelegate *pDelegate, Int32 nPriority, bool bSwallow)
CCTouchHandler* CCTargetedTouchHandler::initWithDelegate(CCTouchDelegate *pDelegate, int nPriority, bool bSwallow)
{
if (__super::initWithDelegate(pDelegate, nPriority))
{
@ -145,13 +145,13 @@ CCTouchHandler* CCTargetedTouchHandler::initWithDelegate(CCTouchDelegate *pDeleg
m_bSwallowsTouches = bSwallow;
/*
if( [aDelegate respondsToSelector:@selector(ccTouchBegan:withEvent:)] )
enabledSelectors_ |= ccTouchSelectorBeganBit;
if( [aDelegate respondsToSelector:@selector(ccTouchMoved:withEvent:)] )
enabledSelectors_ |= ccTouchSelectorMovedBit;
if( [aDelegate respondsToSelector:@selector(ccTouchEnded:withEvent:)] )
enabledSelectors_ |= ccTouchSelectorEndedBit;
if( [aDelegate respondsToSelector:@selector(ccTouchCancelled:withEvent:)] )
if( [aDelegate respondsToSelector:@selector(ccTouchBegan:withEvent:)] )
enabledSelectors_ |= ccTouchSelectorBeganBit;
if( [aDelegate respondsToSelector:@selector(ccTouchMoved:withEvent:)] )
enabledSelectors_ |= ccTouchSelectorMovedBit;
if( [aDelegate respondsToSelector:@selector(ccTouchEnded:withEvent:)] )
enabledSelectors_ |= ccTouchSelectorEndedBit;
if( [aDelegate respondsToSelector:@selector(ccTouchCancelled:withEvent:)] )
enabledSelectors_ |= ccTouchSelectorCancelledBit;
*/
}

View File

@ -30,9 +30,9 @@ THE SOFTWARE.
#include "cocoa/NSObject.h"
#include "cocoa/NSSet.h"
/**
CCTouchHandler
Object than contains the delegate and priority of the event handler.
/**
CCTouchHandler
Object than contains the delegate and priority of the event handler.
*/
class CCTouchHandler : public NSObject
{
@ -44,42 +44,42 @@ public:
void setDelegate(CCTouchDelegate *pDelegate);
// priority
INT32 getPriority(void);
void setPriority(INT32 nPriority);
int getPriority(void);
void setPriority(int nPriority);
// enabled selectors
INT32 getEnabledSelectors(void);
void setEnalbedSelectors(INT32 nValue);
int getEnabledSelectors(void);
void setEnalbedSelectors(int nValue);
// initializes a TouchHandler with a delegate and a priority
virtual CCTouchHandler* initWithDelegate(CCTouchDelegate *pDelegate, INT32 nPriority);
virtual CCTouchHandler* initWithDelegate(CCTouchDelegate *pDelegate, int nPriority);
public:
// allocates a TouchHandler with a delegate and a priority
static CCTouchHandler* handlerWithDelegate(CCTouchDelegate *pDelegate, INT32 nPriority);
static CCTouchHandler* handlerWithDelegate(CCTouchDelegate *pDelegate, int nPriority);
protected:
CCTouchDelegate *m_pDelegate;
INT32 m_nPriority;
INT32 m_nEnabledSelectors;
int m_nPriority;
int m_nEnabledSelectors;
};
/** CCStandardTouchHandler
It forwardes each event to the delegate.
/** CCStandardTouchHandler
It forwardes each event to the delegate.
*/
class CCStandardTouchHandler : public CCTouchHandler
{
public:
virtual CCTouchHandler* initWithDelegate(CCTouchDelegate *pDelegate, INT32 nPriority);
virtual CCTouchHandler* initWithDelegate(CCTouchDelegate *pDelegate, int nPriority);
public:
static CCStandardTouchHandler* handlerWithDelegate(CCStandardTouchDelegate *pDelegate, INT32 nPriority);
static CCStandardTouchHandler* handlerWithDelegate(CCStandardTouchDelegate *pDelegate, int nPriority);
};
/**
CCTargetedTouchHandler
Object than contains the claimed touches and if it swallos touches.
Used internally by TouchDispatcher
/**
CCTargetedTouchHandler
Object than contains the claimed touches and if it swallos touches.
Used internally by TouchDispatcher
*/
class CCTargetedTouchHandler : public CCTouchHandler
{
@ -93,10 +93,10 @@ public:
// MutableSet that contains the claimed touches
NSMutableSet* getClaimedTouches(void);
CCTouchHandler* initWithDelegate(CCTouchDelegate *pDelegate, INT32 nPriority, bool bSwallow);
CCTouchHandler* initWithDelegate(CCTouchDelegate *pDelegate, int nPriority, bool bSwallow);
public:
static CCTargetedTouchHandler* handlerWithDelegate(CCTouchDelegate *pDelegate, INT32 nPriority, bool bSwallow);
static CCTargetedTouchHandler* handlerWithDelegate(CCTouchDelegate *pDelegate, int nPriority, bool bSwallow);
protected:
bool m_bSwallowsTouches;