mirror of https://github.com/axmolengine/axmol.git
fixed #451,remove the code of support mac platform.
1. Remove the EventDispatcher. 2. Refactor CCLayer, CCMenu and CCParticleSystemPoint. 3. Modify the project file of win32, wophone and android.
This commit is contained in:
parent
3bac490581
commit
d4dbedca4d
|
@ -31,17 +31,16 @@ cocoa/CCSet.cpp \
|
|||
cocoa/CCZone.cpp \
|
||||
cocos2d.cpp \
|
||||
effects/CCGrabber.cpp \
|
||||
event_dispatcher/CCEventDispatcher.cpp \
|
||||
event_dispatcher/CCKeyboardEventDelegate.cpp \
|
||||
event_dispatcher/CCMouseEventDelegate.cpp \
|
||||
keypad_dispatcher/CCKeypadDelegate.cpp \
|
||||
keypad_dispatcher/CCKeypadDispatcher.cpp \
|
||||
label_nodes/CCLabelAtlas.cpp \
|
||||
label_nodes/CCLabelBMFont.cpp \
|
||||
label_nodes/CCLabelTTF.cpp \
|
||||
layers_scenes_transitions_nodes/CCLayer.cpp \
|
||||
layers_scenes_transitions_nodes/CCScene.cpp \
|
||||
layers_scenes_transitions_nodes/CCTransitionPageTurn.cpp \
|
||||
layers_scenes_transitions_nodes/CCTransitionRadial.cpp \
|
||||
menu_nodes/CCMenu.cpp \
|
||||
menu_nodes/CCMenuItem.cpp \
|
||||
misc_nodes/CCMotionStreak.cpp \
|
||||
misc_nodes/CCProgressTimer.cpp \
|
||||
|
@ -49,12 +48,11 @@ misc_nodes/CCRenderTexture.cpp \
|
|||
misc_nodes/CCRibbon.cpp \
|
||||
particle_nodes/CCParticleExamples.cpp \
|
||||
particle_nodes/CCParticleSystem.cpp \
|
||||
particle_nodes/CCParticleSystemPoint.cpp \
|
||||
particle_nodes/CCParticleSystemQuad.cpp \
|
||||
platform/CCDirector_mobile.cpp \
|
||||
platform/CCFileUtils.cpp \
|
||||
platform/CCGrid_mobile.cpp \
|
||||
platform/CCLayer_mobile.cpp \
|
||||
platform/CCMenu_mobile.cpp \
|
||||
platform/CCNode_mobile.cpp \
|
||||
platform/CCGL.cpp \
|
||||
platform/CCImage.cpp \
|
||||
|
@ -62,7 +60,6 @@ platform/CCStdC.cpp \
|
|||
platform/CCSAXParser.cpp \
|
||||
platform/CCThread.cpp \
|
||||
platform/CCCommon.cpp \
|
||||
platform/CCParticleSystemPoint_mobile.cpp \
|
||||
platform/CCTransition_mobile.cpp \
|
||||
platform/platform.cpp \
|
||||
platform/android/CCEGLView_android.cpp \
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2010-2011 cocos2d-x.org
|
||||
Copyright (c) 2010£2011 cocos2d-x.org
|
||||
Copyright (c) 2009 On-Core
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
|
|
@ -1,740 +0,0 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2010-2011 cocos2d-x.org
|
||||
Copyright (c) 2010 Ricardo Quesada
|
||||
|
||||
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 "ccMacros.h"
|
||||
#include "CCEventDispatcher.h"
|
||||
#include "../support/data_support/uthash.h" // hack: uthash needs to be imported before utlist to prevent warning
|
||||
#include "../support/data_support/utlist.h"
|
||||
|
||||
namespace cocos2d {
|
||||
|
||||
static CCEventDispatcher *s_pEventDispatcher = NULL;
|
||||
|
||||
typedef struct _listEntry
|
||||
{
|
||||
struct _listEntry *prev;
|
||||
struct _listEntry *next;
|
||||
CCObject* pHandle;
|
||||
int priority;
|
||||
} tListEntry;
|
||||
|
||||
|
||||
#if CC_DIRECTOR_MAC_USE_DISPLAY_LINK_THREAD
|
||||
|
||||
#define QUEUE_EVENT_MAX 128
|
||||
struct _eventQueue {
|
||||
SEL_EventHandler selector;
|
||||
CCEvent *pEvent;
|
||||
};
|
||||
|
||||
static struct _eventQueue eventQueue[QUEUE_EVENT_MAX];
|
||||
static int s_nEventQueueCount = 0;
|
||||
|
||||
#endif // CC_DIRECTOR_MAC_USE_DISPLAY_LINK_THREAD
|
||||
|
||||
CCEventDispatcher* CCEventDispatcher::sharedDispatcher(void)
|
||||
{
|
||||
// synchronized ??
|
||||
if (s_pEventDispatcher == NULL)
|
||||
{
|
||||
s_pEventDispatcher = new CCEventDispatcher();
|
||||
s_pEventDispatcher->init();
|
||||
}
|
||||
|
||||
return s_pEventDispatcher;
|
||||
}
|
||||
|
||||
bool CCEventDispatcher::init()
|
||||
{
|
||||
m_bDispatchEvents = true;
|
||||
|
||||
m_pKeyboardDelegates = NULL;
|
||||
m_pMouseDelegates = NULL;
|
||||
|
||||
#if CC_DIRECTOR_MAC_USE_DISPLAY_LINK_THREAD
|
||||
s_nEventQueueCount = 0;
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CCEventDispatcher::addMouseDelegate(CCMouseEventDelegate* pDelegate, int priority)
|
||||
{
|
||||
if (!pDelegate)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CCMouseEventHandle* pHandle = CCMouseEventHandle::handlerWithDelegate(pDelegate);
|
||||
addDelegate(pHandle, priority, &m_pMouseDelegates);
|
||||
}
|
||||
|
||||
/** removes a mouse delegate */
|
||||
void CCEventDispatcher::removeMouseDelegate(CCMouseEventDelegate* pDelegate)
|
||||
{
|
||||
if (!pDelegate)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
tListEntry *entry, *tmp;
|
||||
DL_FOREACH_SAFE(m_pMouseDelegates, entry, tmp )
|
||||
{
|
||||
if (!(entry->pHandle))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
CCMouseEventHandle* pHandle = (CCMouseEventHandle*) entry->pHandle;
|
||||
if (pHandle->getDelegate() == pDelegate)
|
||||
{
|
||||
DL_DELETE(m_pMouseDelegates, entry );
|
||||
pHandle->release();
|
||||
free(entry);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Removes all mouse delegates, releasing all the delegates */
|
||||
void CCEventDispatcher::removeAllMouseDelegates()
|
||||
{
|
||||
removeAllDelegatesFromList(&m_pMouseDelegates);
|
||||
}
|
||||
|
||||
void CCEventDispatcher::addKeyboardDelegate(CCKeyboardEventDelegate* pDelegate, int priority)
|
||||
{
|
||||
if (!pDelegate)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CCKeyboardEventHandle* pHandle = CCKeyboardEventHandle::handlerWithDelegate(pDelegate);
|
||||
addDelegate(pHandle, priority, &m_pKeyboardDelegates);
|
||||
}
|
||||
|
||||
/** removes a mouse delegate */
|
||||
void CCEventDispatcher::removeKeyboardDelegate(CCKeyboardEventDelegate* pDelegate)
|
||||
{
|
||||
if (!pDelegate)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
tListEntry *entry, *tmp;
|
||||
DL_FOREACH_SAFE(m_pKeyboardDelegates, entry, tmp )
|
||||
{
|
||||
if (!(entry->pHandle))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
CCKeyboardEventHandle* pHandle = (CCKeyboardEventHandle*) entry->pHandle;
|
||||
if (pHandle->getDelegate() == pDelegate)
|
||||
{
|
||||
DL_DELETE(m_pKeyboardDelegates, entry );
|
||||
pHandle->release();
|
||||
free(entry);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Removes all mouse delegates, releasing all the delegates */
|
||||
void CCEventDispatcher::removeAllKeyboardDelegates()
|
||||
{
|
||||
removeAllDelegatesFromList(&m_pKeyboardDelegates);
|
||||
}
|
||||
|
||||
void CCEventDispatcher::addDelegate(CCObject* pHandle, int priority, _listEntry** pList)
|
||||
{
|
||||
if (! pHandle)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
tListEntry *listElement = (tListEntry*) malloc( sizeof(*listElement) );
|
||||
|
||||
pHandle->retain();
|
||||
listElement->pHandle = pHandle;
|
||||
listElement->priority = priority;
|
||||
listElement->next = listElement->prev = NULL;
|
||||
|
||||
// empty list ?
|
||||
if( ! *pList )
|
||||
{
|
||||
DL_APPEND( *pList, listElement );
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
bool added = false;
|
||||
|
||||
for( tListEntry *elem = *pList; elem ; elem = elem->next )
|
||||
{
|
||||
if( priority < elem->priority )
|
||||
{
|
||||
if( elem == *pList )
|
||||
{
|
||||
DL_PREPEND(*pList, listElement);
|
||||
}
|
||||
else
|
||||
{
|
||||
listElement->next = elem;
|
||||
listElement->prev = elem->prev;
|
||||
|
||||
elem->prev->next = listElement;
|
||||
elem->prev = listElement;
|
||||
}
|
||||
|
||||
added = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Not added? priority has the higher value. Append it.
|
||||
if( !added )
|
||||
{
|
||||
DL_APPEND(*pList, listElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CCEventDispatcher::removeAllDelegatesFromList(_listEntry** pList)
|
||||
{
|
||||
tListEntry *entry, *tmp;
|
||||
|
||||
DL_FOREACH_SAFE( *pList, entry, tmp )
|
||||
{
|
||||
DL_DELETE( *pList, entry );
|
||||
free(entry);
|
||||
}
|
||||
}
|
||||
|
||||
bool CCEventDispatcher::getIsDispatchEvents()
|
||||
{
|
||||
return m_bDispatchEvents;
|
||||
}
|
||||
|
||||
void CCEventDispatcher::setIsDispatchEvents(bool bDispatch)
|
||||
{
|
||||
m_bDispatchEvents = bDispatch;
|
||||
}
|
||||
|
||||
//
|
||||
// Mouse events
|
||||
//
|
||||
|
||||
//
|
||||
// Left
|
||||
//
|
||||
void CCEventDispatcher::mouseDown(CCEvent *pEvent)
|
||||
{
|
||||
if(m_bDispatchEvents)
|
||||
{
|
||||
tListEntry *entry, *tmp;
|
||||
|
||||
DL_FOREACH_SAFE( m_pMouseDelegates, entry, tmp )
|
||||
{
|
||||
CCMouseEventHandle* pHandle = (CCMouseEventHandle*) entry->pHandle;
|
||||
if (!pHandle)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
CCMouseEventDelegate* pDelegate = pHandle->getDelegate();
|
||||
if (!pDelegate)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
bool bSwallows = pDelegate->ccMouseDown(pEvent);
|
||||
if(bSwallows)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CCEventDispatcher::mouseMoved(CCEvent *pEvent)
|
||||
{
|
||||
if(m_bDispatchEvents)
|
||||
{
|
||||
tListEntry *entry, *tmp;
|
||||
|
||||
DL_FOREACH_SAFE( m_pMouseDelegates, entry, tmp )
|
||||
{
|
||||
CCMouseEventHandle* pHandle = (CCMouseEventHandle*) entry->pHandle;
|
||||
if (!pHandle)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
CCMouseEventDelegate* pDelegate = pHandle->getDelegate();
|
||||
if (!pDelegate)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
bool bSwallows = pDelegate->ccMouseMoved(pEvent);
|
||||
if(bSwallows)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CCEventDispatcher::mouseDragged(CCEvent *pEvent)
|
||||
{
|
||||
if(m_bDispatchEvents)
|
||||
{
|
||||
tListEntry *entry, *tmp;
|
||||
|
||||
DL_FOREACH_SAFE( m_pMouseDelegates, entry, tmp )
|
||||
{
|
||||
CCMouseEventHandle* pHandle = (CCMouseEventHandle*) entry->pHandle;
|
||||
if (!pHandle)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
CCMouseEventDelegate* pDelegate = pHandle->getDelegate();
|
||||
if (!pDelegate)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
bool bSwallows = pDelegate->ccMouseDragged(pEvent);
|
||||
if(bSwallows)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CCEventDispatcher::mouseUp(CCEvent *pEvent)
|
||||
{
|
||||
if(m_bDispatchEvents)
|
||||
{
|
||||
tListEntry *entry, *tmp;
|
||||
|
||||
DL_FOREACH_SAFE( m_pMouseDelegates, entry, tmp )
|
||||
{
|
||||
CCMouseEventHandle* pHandle = (CCMouseEventHandle*) entry->pHandle;
|
||||
if (!pHandle)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
CCMouseEventDelegate* pDelegate = pHandle->getDelegate();
|
||||
if (!pDelegate)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
bool bSwallows = pDelegate->ccMouseUp(pEvent);
|
||||
if(bSwallows)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Mouse Right
|
||||
//
|
||||
void CCEventDispatcher::rightMouseDown(CCEvent *pEvent)
|
||||
{
|
||||
if(m_bDispatchEvents)
|
||||
{
|
||||
tListEntry *entry, *tmp;
|
||||
|
||||
DL_FOREACH_SAFE( m_pMouseDelegates, entry, tmp )
|
||||
{
|
||||
CCMouseEventHandle* pHandle = (CCMouseEventHandle*) entry->pHandle;
|
||||
if (!pHandle)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
CCMouseEventDelegate* pDelegate = pHandle->getDelegate();
|
||||
if (!pDelegate)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
bool bSwallows = pDelegate->ccRightMouseDown(pEvent);
|
||||
if(bSwallows)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CCEventDispatcher::rightMouseDragged(CCEvent *pEvent)
|
||||
{
|
||||
if(m_bDispatchEvents)
|
||||
{
|
||||
tListEntry *entry, *tmp;
|
||||
|
||||
DL_FOREACH_SAFE( m_pMouseDelegates, entry, tmp )
|
||||
{
|
||||
CCMouseEventHandle* pHandle = (CCMouseEventHandle*) entry->pHandle;
|
||||
if (!pHandle)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
CCMouseEventDelegate* pDelegate = pHandle->getDelegate();
|
||||
if (!pDelegate)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
bool bSwallows = pDelegate->ccRightMouseDragged(pEvent);
|
||||
if(bSwallows)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CCEventDispatcher::rightMouseUp(CCEvent * pEvent)
|
||||
{
|
||||
if(m_bDispatchEvents)
|
||||
{
|
||||
tListEntry *entry, *tmp;
|
||||
|
||||
DL_FOREACH_SAFE( m_pMouseDelegates, entry, tmp )
|
||||
{
|
||||
CCMouseEventHandle* pHandle = (CCMouseEventHandle*) entry->pHandle;
|
||||
if (!pHandle)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
CCMouseEventDelegate* pDelegate = pHandle->getDelegate();
|
||||
if (!pDelegate)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
bool bSwallows = pDelegate->ccRightMouseUp(pEvent);
|
||||
if(bSwallows)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Mouse Other
|
||||
//
|
||||
void CCEventDispatcher::otherMouseDown(CCEvent *pEvent)
|
||||
{
|
||||
if(m_bDispatchEvents)
|
||||
{
|
||||
tListEntry *entry, *tmp;
|
||||
|
||||
DL_FOREACH_SAFE( m_pMouseDelegates, entry, tmp )
|
||||
{
|
||||
CCMouseEventHandle* pHandle = (CCMouseEventHandle*) entry->pHandle;
|
||||
if (!pHandle)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
CCMouseEventDelegate* pDelegate = pHandle->getDelegate();
|
||||
if (!pDelegate)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
bool bSwallows = pDelegate->ccOtherMouseDown(pEvent);
|
||||
if(bSwallows)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CCEventDispatcher::otherMouseDragged(CCEvent *pEvent)
|
||||
{
|
||||
if(m_bDispatchEvents)
|
||||
{
|
||||
tListEntry *entry, *tmp;
|
||||
|
||||
DL_FOREACH_SAFE( m_pMouseDelegates, entry, tmp )
|
||||
{
|
||||
CCMouseEventHandle* pHandle = (CCMouseEventHandle*) entry->pHandle;
|
||||
if (!pHandle)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
CCMouseEventDelegate* pDelegate = pHandle->getDelegate();
|
||||
if (!pDelegate)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
bool bSwallows = pDelegate->ccOtherMouseDragged(pEvent);
|
||||
if(bSwallows)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CCEventDispatcher::otherMouseUp(CCEvent *pEvent)
|
||||
{
|
||||
if(m_bDispatchEvents)
|
||||
{
|
||||
tListEntry *entry, *tmp;
|
||||
|
||||
DL_FOREACH_SAFE( m_pMouseDelegates, entry, tmp )
|
||||
{
|
||||
CCMouseEventHandle* pHandle = (CCMouseEventHandle*) entry->pHandle;
|
||||
if (!pHandle)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
CCMouseEventDelegate* pDelegate = pHandle->getDelegate();
|
||||
if (!pDelegate)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
bool bSwallows = pDelegate->ccOtherMouseUp(pEvent);
|
||||
if(bSwallows)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Scroll Wheel
|
||||
//
|
||||
void CCEventDispatcher::scrollWheel(CCEvent *pEvent)
|
||||
{
|
||||
if(m_bDispatchEvents)
|
||||
{
|
||||
tListEntry *entry, *tmp;
|
||||
|
||||
DL_FOREACH_SAFE( m_pMouseDelegates, entry, tmp )
|
||||
{
|
||||
CCMouseEventHandle* pHandle = (CCMouseEventHandle*) entry->pHandle;
|
||||
if (!pHandle)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
CCMouseEventDelegate* pDelegate = pHandle->getDelegate();
|
||||
if (!pDelegate)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
bool bSwallows = pDelegate->ccScrollWheel(pEvent);
|
||||
if(bSwallows)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Mouse enter / exit
|
||||
void CCEventDispatcher::mouseExited(CCEvent *pEvent)
|
||||
{
|
||||
if(m_bDispatchEvents)
|
||||
{
|
||||
tListEntry *entry, *tmp;
|
||||
|
||||
DL_FOREACH_SAFE( m_pMouseDelegates, entry, tmp )
|
||||
{
|
||||
CCMouseEventHandle* pHandle = (CCMouseEventHandle*) entry->pHandle;
|
||||
if (!pHandle)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
CCMouseEventDelegate* pDelegate = pHandle->getDelegate();
|
||||
if (!pDelegate)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
pDelegate->ccMouseEntered(pEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CCEventDispatcher::mouseEntered(CCEvent *pEvent)
|
||||
{
|
||||
if(m_bDispatchEvents)
|
||||
{
|
||||
tListEntry *entry, *tmp;
|
||||
|
||||
DL_FOREACH_SAFE( m_pMouseDelegates, entry, tmp )
|
||||
{
|
||||
CCMouseEventHandle* pHandle = (CCMouseEventHandle*) entry->pHandle;
|
||||
if (!pHandle)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
CCMouseEventDelegate* pDelegate = pHandle->getDelegate();
|
||||
if (!pDelegate)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
pDelegate->ccMouseExited(pEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Keyboard events
|
||||
void CCEventDispatcher::keyDown(CCEvent *pEvent)
|
||||
{
|
||||
if(m_bDispatchEvents)
|
||||
{
|
||||
tListEntry *entry, *tmp;
|
||||
|
||||
DL_FOREACH_SAFE( m_pKeyboardDelegates, entry, tmp )
|
||||
{
|
||||
CCKeyboardEventHandle* pHandle = (CCKeyboardEventHandle*) entry->pHandle;
|
||||
if (!pHandle)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
CCKeyboardEventDelegate* pDelegate = pHandle->getDelegate();
|
||||
if (!pDelegate)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
bool bSwallows = pDelegate->ccKeyDown(pEvent);
|
||||
if (bSwallows)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CCEventDispatcher::keyUp(CCEvent *pEvent)
|
||||
{
|
||||
if(m_bDispatchEvents)
|
||||
{
|
||||
tListEntry *entry, *tmp;
|
||||
|
||||
DL_FOREACH_SAFE( m_pKeyboardDelegates, entry, tmp )
|
||||
{
|
||||
CCKeyboardEventHandle* pHandle = (CCKeyboardEventHandle*) entry->pHandle;
|
||||
if (!pHandle)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
CCKeyboardEventDelegate* pDelegate = pHandle->getDelegate();
|
||||
if (!pDelegate)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
bool bSwallows = pDelegate->ccKeyUp(pEvent);
|
||||
if (bSwallows)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CCEventDispatcher::flagsChanged(CCEvent *pEvent)
|
||||
{
|
||||
if(m_bDispatchEvents)
|
||||
{
|
||||
tListEntry *entry, *tmp;
|
||||
|
||||
DL_FOREACH_SAFE( m_pKeyboardDelegates, entry, tmp )
|
||||
{
|
||||
CCKeyboardEventHandle* pHandle = (CCKeyboardEventHandle*) entry->pHandle;
|
||||
if (!pHandle)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
CCKeyboardEventDelegate* pDelegate = pHandle->getDelegate();
|
||||
if (!pDelegate)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
bool bSwallows = pDelegate->ccFlagsChanged(pEvent);
|
||||
if (bSwallows)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CCEventDispatcher::touchesBeganWithEvent(CCEvent *pEvent)
|
||||
{
|
||||
if (m_bDispatchEvents )
|
||||
{
|
||||
CCLOG("Touch Events: Not supported yet");
|
||||
}
|
||||
}
|
||||
|
||||
void CCEventDispatcher::touchesMovedWithEvent(CCEvent *pEvent)
|
||||
{
|
||||
if (m_bDispatchEvents )
|
||||
{
|
||||
CCLOG("Touch Events: Not supported yet");
|
||||
}
|
||||
}
|
||||
|
||||
void CCEventDispatcher::touchesEndedWithEvent(CCEvent *pEvent)
|
||||
{
|
||||
if (m_bDispatchEvents )
|
||||
{
|
||||
CCLOG("Touch Events: Not supported yet");
|
||||
}
|
||||
}
|
||||
|
||||
void CCEventDispatcher::touchesCancelledWithEvent(CCEvent *pEvent)
|
||||
{
|
||||
if (m_bDispatchEvents )
|
||||
{
|
||||
CCLOG("Touch Events: Not supported yet");
|
||||
}
|
||||
}
|
||||
|
||||
#if CC_DIRECTOR_MAC_USE_DISPLAY_LINK_THREAD
|
||||
|
||||
void CCEventDispatcher::queueEvent(CCEvent* pEvent, SEL_EventHandler selector)
|
||||
{
|
||||
CCAssert( s_nEventQueueCount < QUEUE_EVENT_MAX, "CCEventDispatcher: recompile. Increment QUEUE_EVENT_MAX value");
|
||||
|
||||
eventQueue[s_nEventQueueCount].selector = selector;
|
||||
eventQueue[s_nEventQueueCount].pEvent = (CCEvent*) (pEvent->copy());
|
||||
|
||||
s_nEventQueueCount++;
|
||||
}
|
||||
|
||||
void CCEventDispatcher::dispatchQueuedEvents()
|
||||
{
|
||||
for( int i=0; i < s_nEventQueueCount; i++ )
|
||||
{
|
||||
// SEL_EventHandler sel = eventQueue[i].selector;
|
||||
CCEvent *pEvent = eventQueue[i].pEvent;
|
||||
|
||||
|
||||
//[self performSelector:sel withObject:event]; // @todo
|
||||
pEvent->release();
|
||||
}
|
||||
|
||||
s_nEventQueueCount = 0;
|
||||
}
|
||||
|
||||
#endif // CC_DIRECTOR_MAC_USE_DISPLAY_LINK_THREAD
|
||||
|
||||
} // namespace cocos2d
|
|
@ -1,91 +0,0 @@
|
|||
/****************************************************************************
|
||||
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 "CCKeyboardEventDelegate.h"
|
||||
#include "ccMacros.h"
|
||||
|
||||
namespace cocos2d {
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
// CCKeyboardEventHandle
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
CCKeyboardEventDelegate* CCKeyboardEventHandle::getDelegate()
|
||||
{
|
||||
return m_pDelegate;
|
||||
}
|
||||
|
||||
CCKeyboardEventHandle::~CCKeyboardEventHandle()
|
||||
{
|
||||
if (m_pDelegate)
|
||||
{
|
||||
m_pDelegate->KeyboardDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
void CCKeyboardEventHandle::setDelegate(CCKeyboardEventDelegate *pDelegate)
|
||||
{
|
||||
if (pDelegate)
|
||||
{
|
||||
pDelegate->KeyboardKeep();
|
||||
}
|
||||
|
||||
if (m_pDelegate)
|
||||
{
|
||||
m_pDelegate->KeyboardDestroy();
|
||||
}
|
||||
m_pDelegate = pDelegate;
|
||||
}
|
||||
|
||||
bool CCKeyboardEventHandle::initWithDelegate(CCKeyboardEventDelegate *pDelegate)
|
||||
{
|
||||
CCAssert(pDelegate != NULL, "It's a wrong delegate!");
|
||||
|
||||
m_pDelegate = pDelegate;
|
||||
pDelegate->KeyboardKeep();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
CCKeyboardEventHandle* CCKeyboardEventHandle::handlerWithDelegate(CCKeyboardEventDelegate *pDelegate)
|
||||
{
|
||||
CCKeyboardEventHandle* pHandler = new CCKeyboardEventHandle;
|
||||
|
||||
if (pHandler)
|
||||
{
|
||||
if (pHandler->initWithDelegate(pDelegate))
|
||||
{
|
||||
pHandler->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
CC_SAFE_RELEASE_NULL(pHandler);
|
||||
}
|
||||
}
|
||||
|
||||
return pHandler;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,91 +0,0 @@
|
|||
/****************************************************************************
|
||||
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 "CCMouseEventDelegate.h"
|
||||
#include "ccMacros.h"
|
||||
|
||||
namespace cocos2d {
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
// CCMouseEventHandle
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
CCMouseEventDelegate* CCMouseEventHandle::getDelegate()
|
||||
{
|
||||
return m_pDelegate;
|
||||
}
|
||||
|
||||
CCMouseEventHandle::~CCMouseEventHandle()
|
||||
{
|
||||
if (m_pDelegate)
|
||||
{
|
||||
m_pDelegate->MouseDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
void CCMouseEventHandle::setDelegate(CCMouseEventDelegate *pDelegate)
|
||||
{
|
||||
if (pDelegate)
|
||||
{
|
||||
pDelegate->MouseKeep();
|
||||
}
|
||||
|
||||
if (m_pDelegate)
|
||||
{
|
||||
m_pDelegate->MouseDestroy();
|
||||
}
|
||||
m_pDelegate = pDelegate;
|
||||
}
|
||||
|
||||
bool CCMouseEventHandle::initWithDelegate(CCMouseEventDelegate *pDelegate)
|
||||
{
|
||||
CCAssert(pDelegate != NULL, "It's a wrong delegate!");
|
||||
|
||||
m_pDelegate = pDelegate;
|
||||
pDelegate->MouseKeep();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
CCMouseEventHandle* CCMouseEventHandle::handlerWithDelegate(CCMouseEventDelegate *pDelegate)
|
||||
{
|
||||
CCMouseEventHandle* pHandler = new CCMouseEventHandle;
|
||||
|
||||
if (pHandler)
|
||||
{
|
||||
if (pHandler->initWithDelegate(pDelegate))
|
||||
{
|
||||
pHandler->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
CC_SAFE_RELEASE_NULL(pHandler);
|
||||
}
|
||||
}
|
||||
|
||||
return pHandler;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
/****************************************************************************
|
||||
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 __CCEvent_H__
|
||||
#define __CCEvent_H__
|
||||
|
||||
|
||||
#endif
|
|
@ -1,132 +0,0 @@
|
|||
/****************************************************************************
|
||||
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 __CCEVENT_DISPATCHER_H__
|
||||
#define __CCEVENT_DISPATCHER_H__
|
||||
|
||||
#include "CCMouseEventDelegate.h"
|
||||
#include "CCKeyboardEventDelegate.h"
|
||||
#include "ccConfig.h"
|
||||
#include "selector_protocol.h"
|
||||
|
||||
namespace cocos2d {
|
||||
|
||||
struct _listEntry;
|
||||
|
||||
/** CCEventDispatcher
|
||||
|
||||
This is object is responsible for dispatching the events:
|
||||
- Mouse events
|
||||
- Keyboard events
|
||||
- Touch events
|
||||
|
||||
Only available on Mac
|
||||
*/
|
||||
class CCEventDispatcher : public CCObject
|
||||
{
|
||||
public:
|
||||
static CCEventDispatcher* sharedDispatcher();
|
||||
bool init(void);
|
||||
|
||||
/** Adds a mouse delegate to the dispatcher's list.
|
||||
Delegates with a lower priority value will be called before higher priority values.
|
||||
All the events will be propgated to all the delegates, unless the one delegate returns YES.
|
||||
|
||||
IMPORTANT: The delegate will be retained.
|
||||
*/
|
||||
void addMouseDelegate(CCMouseEventDelegate* pDelegate, int priority);
|
||||
|
||||
/** removes a mouse delegate */
|
||||
void removeMouseDelegate(CCMouseEventDelegate* pDelegate);
|
||||
|
||||
/** Removes all mouse delegates, releasing all the delegates */
|
||||
void removeAllMouseDelegates();
|
||||
|
||||
/** Adds a Keyboard delegate to the dispatcher's list.
|
||||
Delegates with a lower priority value will be called before higher priority values.
|
||||
All the events will be propgated to all the delegates, unless the one delegate returns YES.
|
||||
|
||||
IMPORTANT: The delegate will be retained.
|
||||
*/
|
||||
void addKeyboardDelegate(CCKeyboardEventDelegate* pDelegate, int priority);
|
||||
|
||||
/** removes a mouse delegate */
|
||||
void removeKeyboardDelegate(CCKeyboardEventDelegate* pDelegate);
|
||||
|
||||
/** Removes all mouse delegates, releasing all the delegates */
|
||||
void removeAllKeyboardDelegates();
|
||||
|
||||
/** Mouse events */
|
||||
// left
|
||||
void mouseDown(CCEvent *pEvent);
|
||||
void mouseMoved(CCEvent *pEvent);
|
||||
void mouseDragged(CCEvent *pEvent);
|
||||
void mouseUp(CCEvent *pEvent);
|
||||
|
||||
// right
|
||||
void rightMouseDown(CCEvent *pEvent);
|
||||
void rightMouseDragged(CCEvent *pEvent);
|
||||
void rightMouseUp(CCEvent *pEvent);
|
||||
|
||||
// other
|
||||
void otherMouseDown(CCEvent *pEvent);
|
||||
void otherMouseDragged(CCEvent *pEvent);
|
||||
void otherMouseUp(CCEvent *pEvent);
|
||||
|
||||
// scroll Wheel
|
||||
void scrollWheel(CCEvent *pEvent);
|
||||
|
||||
// Mouse enter / exit
|
||||
void mouseExited(CCEvent *pEvent);
|
||||
void mouseEntered(CCEvent *pEvent);
|
||||
|
||||
/** keyboard events */
|
||||
void keyDown(CCEvent *pEvent);
|
||||
void keyUp(CCEvent *pEvent);
|
||||
void flagsChanged(CCEvent *pEvent);
|
||||
|
||||
void touchesBeganWithEvent(CCEvent *pEvent);
|
||||
void touchesMovedWithEvent(CCEvent *pEvent);
|
||||
void touchesEndedWithEvent(CCEvent *pEvent);
|
||||
void touchesCancelledWithEvent(CCEvent *pEvent);
|
||||
|
||||
#if CC_DIRECTOR_MAC_USE_DISPLAY_LINK_THREAD
|
||||
void dispatchQueuedEvents();
|
||||
void queueEvent(CCEvent* pEvent, SEL_EventHandler selector);
|
||||
#endif
|
||||
|
||||
CC_PROPERTY(bool, m_bDispatchEvents, IsDispatchEvents)
|
||||
|
||||
protected:
|
||||
void addDelegate(CCObject* pHandle, int priority, _listEntry** pList);
|
||||
void removeAllDelegatesFromList(_listEntry** pList);
|
||||
|
||||
protected:
|
||||
struct _listEntry* m_pKeyboardDelegates;
|
||||
struct _listEntry* m_pMouseDelegates;
|
||||
};
|
||||
|
||||
} //namespace cocos2d
|
||||
|
||||
#endif // __CCEVENT_DISPATCHER_H__
|
|
@ -1,79 +0,0 @@
|
|||
/****************************************************************************
|
||||
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 __CCKEYBOARD_EVENT_DELEGATE_H__
|
||||
#define __CCKEYBOARD_EVENT_DELEGATE_H__
|
||||
|
||||
#include "CCTouch.h"
|
||||
#include "CCObject.h"
|
||||
|
||||
namespace cocos2d {
|
||||
|
||||
class CC_DLL CCKeyboardEventDelegate
|
||||
{
|
||||
public:
|
||||
//! call the release() in child layer
|
||||
virtual void KeyboardDestroy() {}
|
||||
//! call the retain() in child layer
|
||||
virtual void KeyboardKeep() {}
|
||||
|
||||
/** called when the "keyUp" event is received.
|
||||
Return YES to avoid propagating the event to other delegates.
|
||||
*/
|
||||
virtual bool ccKeyUp(CCEvent* pEvent) { return false; }
|
||||
|
||||
/** called when the "keyDown" event is received.
|
||||
Return YES to avoid propagating the event to other delegates.
|
||||
*/
|
||||
virtual bool ccKeyDown(CCEvent* pEvent) { return false; }
|
||||
|
||||
/** called when the "flagsChanged" event is received.
|
||||
Return YES to avoid propagating the event to other delegates.
|
||||
*/
|
||||
virtual bool ccFlagsChanged(CCEvent* pEvent) { return false; }
|
||||
};
|
||||
|
||||
class CC_DLL CCKeyboardEventHandle : public CCObject
|
||||
{
|
||||
public:
|
||||
virtual ~CCKeyboardEventHandle(void);
|
||||
|
||||
/** delegate */
|
||||
CCKeyboardEventDelegate* getDelegate();
|
||||
void setDelegate(CCKeyboardEventDelegate *pDelegate);
|
||||
|
||||
/** initializes a CCKeyboardEventHandle with a delegate */
|
||||
virtual bool initWithDelegate(CCKeyboardEventDelegate *pDelegate);
|
||||
|
||||
public:
|
||||
/** allocates a CCKeyboardEventHandle with a delegate */
|
||||
static CCKeyboardEventHandle* handlerWithDelegate(CCKeyboardEventDelegate *pDelegate);
|
||||
|
||||
protected:
|
||||
CCKeyboardEventDelegate* m_pDelegate;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -31,8 +31,6 @@ THE SOFTWARE.
|
|||
#include "CCTouchDelegateProtocol.h"
|
||||
#include "CCAccelerometerDelegate.h"
|
||||
#include "CCKeypadDelegate.h"
|
||||
#include "CCMouseEventDelegate.h"
|
||||
#include "CCKeyboardEventDelegate.h"
|
||||
|
||||
namespace cocos2d {
|
||||
|
||||
|
@ -45,7 +43,7 @@ All features from CCNode are valid, plus the following new features:
|
|||
- It can receive iPhone Touches
|
||||
- It can receive Accelerometer input
|
||||
*/
|
||||
class CC_DLL CCLayer : public CCNode, public CCTouchDelegate, public CCAccelerometerDelegate, public CCKeypadDelegate, public CCKeyboardEventDelegate, public CCMouseEventDelegate
|
||||
class CC_DLL CCLayer : public CCNode, public CCTouchDelegate, public CCAccelerometerDelegate, public CCKeypadDelegate
|
||||
{
|
||||
public:
|
||||
CCLayer();
|
||||
|
@ -67,12 +65,6 @@ public:
|
|||
virtual void KeypadDestroy();
|
||||
virtual void KeypadKeep();
|
||||
|
||||
virtual void KeyboardDestroy(void);
|
||||
virtual void KeyboardKeep(void);
|
||||
|
||||
virtual void MouseDestroy();
|
||||
virtual void MouseKeep();
|
||||
|
||||
/** If isTouchEnabled, this method is called onEnter. Override it to change the
|
||||
way CCLayer receives touch events.
|
||||
( Default: CCTouchDispatcher::sharedDispatcher()->addStandardDelegate(this,0); )
|
||||
|
@ -85,20 +77,6 @@ public:
|
|||
*/
|
||||
virtual void registerWithTouchDispatcher(void);
|
||||
|
||||
/** priority of the mouse event delegate.
|
||||
Default 0.
|
||||
Override this method to set another priority.
|
||||
@since v0.99.5
|
||||
*/
|
||||
virtual int mouseDelegatePriority() { return 0; }
|
||||
|
||||
/** priority of the keyboard event delegate.
|
||||
Default 0.
|
||||
Override this method to set another priority.
|
||||
@since v0.99.5
|
||||
*/
|
||||
virtual int keyboardDelegatePriority() { return 0; }
|
||||
|
||||
/** whether or not it will receive Touch events.
|
||||
You can enable / disable touch events with this property.
|
||||
Only the touches of this node will be affected. This "method" is not propagated to it's children.
|
||||
|
@ -110,16 +88,6 @@ public:
|
|||
@since v0.8.1
|
||||
*/
|
||||
CC_PROPERTY(bool, m_bIsAccelerometerEnabled, IsAccelerometerEnabled)
|
||||
/** whether or not it will receive Keyboard events
|
||||
You can enable / disable Keyboard events with this property.
|
||||
@since v0.99.5
|
||||
*/
|
||||
CC_PROPERTY(bool, m_bIsKeyboardEnabled, IsKeyboardEnabled)
|
||||
/** whether or not it will receive mouse events
|
||||
You can enable / disable mouse events with this property.
|
||||
@since v0.99.5
|
||||
*/
|
||||
CC_PROPERTY(bool, m_bIsMouseEnabled, IsMouseEnabled)
|
||||
/** whether or not it will receive keypad events
|
||||
You can enable / disable accelerometer events with this property.
|
||||
it's new in cocos2d-x
|
||||
|
|
|
@ -96,16 +96,6 @@ namespace cocos2d{
|
|||
virtual void ccTouchCancelled(CCTouch *touch, CCEvent* event);
|
||||
virtual void ccTouchMoved(CCTouch* touch, CCEvent* event);
|
||||
|
||||
/**
|
||||
@brief For PC event handle functions
|
||||
@since v0.99.5
|
||||
*/
|
||||
virtual int mouseDelegatePriority();
|
||||
virtual CCMenuItem* itemForMouseEvent(CCEvent * pEvent);
|
||||
virtual bool ccMouseDown(CCEvent * pEvent);
|
||||
virtual bool ccMouseDragged(CCEvent * pEvent);
|
||||
virtual bool ccMouseUp(CCEvent * pEvent);
|
||||
|
||||
virtual void destroy(void);
|
||||
virtual void keep(void);
|
||||
|
||||
|
|
|
@ -1,151 +0,0 @@
|
|||
/****************************************************************************
|
||||
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 __CCMOUSE_EVENT_DELEGATE_H__
|
||||
#define __CCMOUSE_EVENT_DELEGATE_H__
|
||||
|
||||
#include "CCTouch.h"
|
||||
#include "CCObject.h"
|
||||
|
||||
namespace cocos2d {
|
||||
|
||||
class CC_DLL CCMouseEventDelegate
|
||||
{
|
||||
public:
|
||||
//! call the release() in child layer
|
||||
virtual void MouseDestroy() {}
|
||||
//! call the retain() in child layer
|
||||
virtual void MouseKeep() {}
|
||||
|
||||
//
|
||||
// left
|
||||
//
|
||||
/** called when the "mouseDown" event is received.
|
||||
Return YES to avoid propagating the event to other delegates.
|
||||
*/
|
||||
virtual bool ccMouseDown(CCEvent* pEvent) { return false; }
|
||||
|
||||
/** called when the "mouseDragged" event is received.
|
||||
Return YES to avoid propagating the event to other delegates.
|
||||
*/
|
||||
virtual bool ccMouseDragged(CCEvent* pEvent) { return false; }
|
||||
|
||||
/** called when the "mouseMoved" event is received.
|
||||
Return YES to avoid propagating the event to other delegates.
|
||||
By default, "mouseMoved" is disabled. To enable it, send the "setAcceptsMouseMovedEvents:YES" message to the main window.
|
||||
*/
|
||||
virtual bool ccMouseMoved(CCEvent* pEvent) { return false; }
|
||||
|
||||
/** called when the "mouseUp" event is received.
|
||||
Return YES to avoid propagating the event to other delegates.
|
||||
*/
|
||||
virtual bool ccMouseUp(CCEvent* pEvent) { return false; }
|
||||
|
||||
|
||||
//
|
||||
// right
|
||||
//
|
||||
|
||||
/** called when the "rightMouseDown" event is received.
|
||||
Return YES to avoid propagating the event to other delegates.
|
||||
*/
|
||||
virtual bool ccRightMouseDown(CCEvent* pEvent) { return false; }
|
||||
|
||||
/** called when the "rightMouseDragged" event is received.
|
||||
Return YES to avoid propagating the event to other delegates.
|
||||
*/
|
||||
virtual bool ccRightMouseDragged(CCEvent* pEvent) { return false; }
|
||||
|
||||
/** called when the "rightMouseUp" event is received.
|
||||
Return YES to avoid propagating the event to other delegates.
|
||||
*/
|
||||
virtual bool ccRightMouseUp(CCEvent* pEvent) { return false; }
|
||||
|
||||
//
|
||||
// other
|
||||
//
|
||||
|
||||
/** called when the "otherMouseDown" event is received.
|
||||
Return YES to avoid propagating the event to other delegates.
|
||||
*/
|
||||
virtual bool ccOtherMouseDown(CCEvent* pEvent) { return false; }
|
||||
|
||||
/** called when the "otherMouseDragged" event is received.
|
||||
Return YES to avoid propagating the event to other delegates.
|
||||
*/
|
||||
virtual bool ccOtherMouseDragged(CCEvent* pEvent) { return false; }
|
||||
|
||||
/** called when the "otherMouseUp" event is received.
|
||||
Return YES to avoid propagating the event to other delegates.
|
||||
*/
|
||||
virtual bool ccOtherMouseUp(CCEvent* pEvent) { return false; }
|
||||
|
||||
//
|
||||
// scroll wheel
|
||||
//
|
||||
|
||||
/** called when the "scrollWheel" event is received.
|
||||
Return YES to avoid propagating the event to other delegates.
|
||||
*/
|
||||
virtual bool ccScrollWheel(CCEvent *pEvent) { return false; }
|
||||
|
||||
|
||||
//
|
||||
// enter / exit
|
||||
//
|
||||
|
||||
/** called when the "mouseEntered" event is received.
|
||||
Return YES to avoid propagating the event to other delegates.
|
||||
*/
|
||||
virtual void ccMouseEntered(CCEvent *pEvent) {}
|
||||
|
||||
/** called when the "mouseExited" event is received.
|
||||
Return YES to avoid propagating the event to other delegates.
|
||||
*/
|
||||
virtual void ccMouseExited(CCEvent *pEvent) {}
|
||||
};
|
||||
|
||||
class CC_DLL CCMouseEventHandle : public CCObject
|
||||
{
|
||||
public:
|
||||
virtual ~CCMouseEventHandle(void);
|
||||
|
||||
/** delegate */
|
||||
CCMouseEventDelegate* getDelegate();
|
||||
void setDelegate(CCMouseEventDelegate *pDelegate);
|
||||
|
||||
/** initializes a CCMouseEventHandle with a delegate */
|
||||
virtual bool initWithDelegate(CCMouseEventDelegate *pDelegate);
|
||||
|
||||
public:
|
||||
/** allocates a CCMouseEventHandle with a delegate */
|
||||
static CCMouseEventHandle* handlerWithDelegate(CCMouseEventDelegate *pDelegate);
|
||||
|
||||
protected:
|
||||
CCMouseEventDelegate* m_pDelegate;
|
||||
};
|
||||
|
||||
} //namespace cocos2d
|
||||
|
||||
#endif // __CCMOUSE_EVENT_DELEGATE_H__
|
|
@ -22,9 +22,55 @@ 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 __CC_PARTICLE_SYSTEM_POINT_H__
|
||||
#define __CC_PARTICLE_SYSTEM_POINT_H__
|
||||
#ifndef __CC_PARTICLE_SYSTEM_POINT_MOBILE_H__
|
||||
#define __CC_PARTICLE_SYSTEM_POINT_MOBILE_H__
|
||||
|
||||
#include "platform/CCParticleSystemPoint_platform.h"
|
||||
/*#include "Availability.h"*/
|
||||
#include "CCParticleSystem.h"
|
||||
|
||||
#endif //__CC_PARTICLE_SYSTEM_POINT_H__
|
||||
namespace cocos2d {
|
||||
|
||||
#define CC_MAX_PARTICLE_SIZE 64
|
||||
|
||||
/** @brief CCParticleSystemPoint is a subclass of CCParticleSystem
|
||||
Attributes of a Particle System:
|
||||
* All the attributes of Particle System
|
||||
|
||||
Features:
|
||||
* consumes small memory: uses 1 vertex (x,y) per particle, no need to assign tex coordinates
|
||||
* size can't be bigger than 64
|
||||
* the system can't be scaled since the particles are rendered using GL_POINT_SPRITE
|
||||
|
||||
Limitations:
|
||||
* On 3rd gen iPhone devices and iPads, this node performs MUCH slower than CCParticleSystemQuad.
|
||||
*/
|
||||
class CC_DLL CCParticleSystemPoint : public CCParticleSystem
|
||||
{
|
||||
public:
|
||||
CCParticleSystemPoint()
|
||||
:m_pVertices(NULL)
|
||||
{}
|
||||
virtual ~CCParticleSystemPoint();
|
||||
// super methods
|
||||
virtual bool initWithTotalParticles(int numberOfParticles);
|
||||
virtual void updateQuadWithParticle(tCCParticle* particle, CCPoint newPosition);
|
||||
virtual void postStep();
|
||||
virtual void draw();
|
||||
virtual void setStartSpin(float var);
|
||||
virtual void setStartSpinVar(float var);
|
||||
virtual void setEndSpin(float var);
|
||||
virtual void setEndSpinVar(float var);
|
||||
virtual void setStartSize(float var);
|
||||
virtual void setEndSize(float var);
|
||||
protected:
|
||||
//! Array of (x,y,size)
|
||||
ccPointSprite *m_pVertices;
|
||||
//! vertices buffer id
|
||||
# if CC_USES_VBO
|
||||
GLuint m_uVerticesID;
|
||||
#endif
|
||||
};
|
||||
|
||||
}// namespace cocos2d
|
||||
|
||||
#endif //__CC_PARTICLE_SYSTEM_POINT_MOBILE_H__
|
||||
|
|
|
@ -37,8 +37,6 @@ CCLayer::CCLayer()
|
|||
:m_bIsTouchEnabled(false)
|
||||
,m_bIsAccelerometerEnabled(false)
|
||||
,m_bIsKeypadEnabled(false)
|
||||
,m_bIsMouseEnabled(false)
|
||||
,m_bIsKeyboardEnabled(false)
|
||||
{
|
||||
m_eTouchDelegateType = ccTouchDeletateAllBit;
|
||||
m_tAnchorPoint = ccp(0.5f, 0.5f);
|
||||
|
@ -115,47 +113,6 @@ void CCLayer::KeypadKeep()
|
|||
this->retain();
|
||||
}
|
||||
|
||||
void CCLayer::KeyboardDestroy(void)
|
||||
{
|
||||
this->release();
|
||||
}
|
||||
|
||||
void CCLayer::KeyboardKeep(void)
|
||||
{
|
||||
this->retain();
|
||||
}
|
||||
|
||||
void CCLayer::MouseDestroy()
|
||||
{
|
||||
this->release();
|
||||
}
|
||||
|
||||
void CCLayer::MouseKeep()
|
||||
{
|
||||
this->retain();
|
||||
}
|
||||
|
||||
|
||||
bool CCLayer::getIsMouseEnabled()
|
||||
{
|
||||
return m_bIsMouseEnabled;
|
||||
}
|
||||
|
||||
void CCLayer::setIsMouseEnabled(bool enabled)
|
||||
{
|
||||
CCLOG("cocos2d: CCLayer: unsupportted!");
|
||||
}
|
||||
|
||||
bool CCLayer::getIsKeyboardEnabled()
|
||||
{
|
||||
return m_bIsKeyboardEnabled;
|
||||
}
|
||||
|
||||
void CCLayer::setIsKeyboardEnabled(bool enabled)
|
||||
{
|
||||
CCLOG("cocos2d: CCLayer: unsupportted!");
|
||||
}
|
||||
|
||||
/// isTouchEnabled getter
|
||||
bool CCLayer::getIsTouchEnabled()
|
||||
{
|
||||
|
@ -234,7 +191,6 @@ void CCLayer::setIsKeypadEnabled(bool enabled)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/// Callbacks
|
||||
void CCLayer::onEnter()
|
||||
{
|
|
@ -199,36 +199,6 @@ namespace cocos2d{
|
|||
}
|
||||
}
|
||||
|
||||
int CCMenu::mouseDelegatePriority()
|
||||
{
|
||||
CCLOG("cocos2d: CCMenu: unsupported");
|
||||
return -1;/** @todo upto-0.99.5 use NSIntegerMin+1 instead*/
|
||||
}
|
||||
|
||||
CCMenuItem* CCMenu::itemForMouseEvent(CCEvent * pEvent)
|
||||
{
|
||||
CCLOG("cocos2d: CCMenu: unsupported");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool CCMenu::ccMouseUp(CCEvent * pEvent)
|
||||
{
|
||||
CCLOG("cocos2d: CCMenu: unsupported");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CCMenu::ccMouseDown(CCEvent * pEvent)
|
||||
{
|
||||
CCLOG("cocos2d: CCMenu: unsupported");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CCMenu::ccMouseDragged(CCEvent * pEvent)
|
||||
{
|
||||
CCLOG("cocos2d: CCMenu: unsupported");
|
||||
return false;
|
||||
}
|
||||
|
||||
void CCMenu::destroy(void)
|
||||
{
|
||||
release();
|
|
@ -30,7 +30,6 @@
|
|||
// ARMv7, Mac or Simulator use "Quad" particle
|
||||
#if defined(__ARM_NEON__) || \
|
||||
(CC_TARGET_PLATFORM == CC_PLATFORM_AIRPLAY) || \
|
||||
(CC_TARGET_PLATFORM == CC_PLATFORM_MAC) || \
|
||||
(CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || \
|
||||
(CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || \
|
||||
(CC_TARGET_PLATFORM == CC_PLATFORM_WOPHONE) || \
|
||||
|
|
|
@ -23,9 +23,6 @@ THE SOFTWARE.
|
|||
****************************************************************************/
|
||||
|
||||
#include "CCGL.h"
|
||||
|
||||
#if defined(CC_PLATFORM_MOBILE)
|
||||
|
||||
#include "CCStdC.h"
|
||||
|
||||
NS_CC_BEGIN;
|
||||
|
@ -129,5 +126,3 @@ void gluLookAt(float fEyeX, float fEyeY, float fEyeZ,
|
|||
}
|
||||
|
||||
NS_CC_END;
|
||||
|
||||
#endif // CC_PLATFORM_MOBILE
|
||||
|
|
|
@ -31,8 +31,6 @@ THE SOFTWARE.
|
|||
|
||||
#include "CCEGLView.h"
|
||||
|
||||
// iOS
|
||||
#if defined(CC_PLATFORM_MOBILE)
|
||||
#define CC_GLVIEW cocos2d::CCEGLView
|
||||
#define ccglOrtho glOrthof
|
||||
#define ccglClearDepth glClearDepthf
|
||||
|
@ -49,26 +47,6 @@ THE SOFTWARE.
|
|||
#define CC_GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0_OES
|
||||
#define CC_GL_FRAMEBUFFER_COMPLETE GL_FRAMEBUFFER_COMPLETE_OES
|
||||
|
||||
// Mac
|
||||
#elif defined(CC_PLATFORM_PC)
|
||||
#define CC_GLVIEW MacGLView
|
||||
#define ccglOrtho glOrtho
|
||||
#define ccglClearDepth glClearDepth
|
||||
#define ccglGenerateMipmap glGenerateMipmap
|
||||
#define ccglGenFramebuffers glGenFramebuffers
|
||||
#define ccglBindFramebuffer glBindFramebuffer
|
||||
#define ccglFramebufferTexture2D glFramebufferTexture2D
|
||||
#define ccglDeleteFramebuffers glDeleteFramebuffers
|
||||
#define ccglCheckFramebufferStatus glCheckFramebufferStatus
|
||||
#define ccglTranslate glTranslated
|
||||
|
||||
#define CC_GL_FRAMEBUFFER GL_FRAMEBUFFER
|
||||
#define CC_GL_FRAMEBUFFER_BINDING GL_FRAMEBUFFER_BINDING
|
||||
#define CC_GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0
|
||||
#define CC_GL_FRAMEBUFFER_COMPLETE GL_FRAMEBUFFER_COMPLETE
|
||||
|
||||
#endif
|
||||
|
||||
#include "CCCommon.h"
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
||||
|
@ -76,11 +54,6 @@ THE SOFTWARE.
|
|||
#include "OpenGLES/ES1/glext.h"
|
||||
#endif
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
|
||||
#include <OpenGL/gl.h>
|
||||
#include <OpenGL/glu.h>
|
||||
#endif
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
#include <GLES/gl.h>
|
||||
#include <GLES/glext.h>
|
||||
|
@ -100,8 +73,6 @@ THE SOFTWARE.
|
|||
#include <IwGL.h>
|
||||
#endif
|
||||
|
||||
#if defined(CC_PLATFORM_MOBILE)
|
||||
|
||||
NS_CC_BEGIN;
|
||||
|
||||
/*
|
||||
|
@ -118,6 +89,4 @@ void CC_DLL gluPerspective(GLfloat fovy, GLfloat aspect, GLfloat zNear, GLfloat
|
|||
|
||||
NS_CC_END;
|
||||
|
||||
#endif
|
||||
|
||||
#endif // __PLATFOMR_CCGL_H__
|
||||
|
|
|
@ -1,75 +0,0 @@
|
|||
/****************************************************************************
|
||||
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 __CC_PARTICLE_SYSTEM_POINT_MOBILE_H__
|
||||
#define __CC_PARTICLE_SYSTEM_POINT_MOBILE_H__
|
||||
|
||||
/*#include "Availability.h"*/
|
||||
#include "CCParticleSystem.h"
|
||||
|
||||
namespace cocos2d {
|
||||
|
||||
#define CC_MAX_PARTICLE_SIZE 64
|
||||
|
||||
/** @brief CCParticleSystemPoint is a subclass of CCParticleSystem
|
||||
Attributes of a Particle System:
|
||||
* All the attributes of Particle System
|
||||
|
||||
Features:
|
||||
* consumes small memory: uses 1 vertex (x,y) per particle, no need to assign tex coordinates
|
||||
* size can't be bigger than 64
|
||||
* the system can't be scaled since the particles are rendered using GL_POINT_SPRITE
|
||||
|
||||
Limitations:
|
||||
* On 3rd gen iPhone devices and iPads, this node performs MUCH slower than CCParticleSystemQuad.
|
||||
*/
|
||||
class CC_DLL CCParticleSystemPoint : public CCParticleSystem
|
||||
{
|
||||
public:
|
||||
CCParticleSystemPoint()
|
||||
:m_pVertices(NULL)
|
||||
{}
|
||||
virtual ~CCParticleSystemPoint();
|
||||
// super methods
|
||||
virtual bool initWithTotalParticles(int numberOfParticles);
|
||||
virtual void updateQuadWithParticle(tCCParticle* particle, CCPoint newPosition);
|
||||
virtual void postStep();
|
||||
virtual void draw();
|
||||
virtual void setStartSpin(float var);
|
||||
virtual void setStartSpinVar(float var);
|
||||
virtual void setEndSpin(float var);
|
||||
virtual void setEndSpinVar(float var);
|
||||
virtual void setStartSize(float var);
|
||||
virtual void setEndSize(float var);
|
||||
protected:
|
||||
//! Array of (x,y,size)
|
||||
ccPointSprite *m_pVertices;
|
||||
//! vertices buffer id
|
||||
# if CC_USES_VBO
|
||||
GLuint m_uVerticesID;
|
||||
#endif
|
||||
};
|
||||
|
||||
}// namespace cocos2d
|
||||
|
||||
#endif //__CC_PARTICLE_SYSTEM_POINT_MOBILE_H__
|
|
@ -1,36 +0,0 @@
|
|||
/****************************************************************************
|
||||
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 __CC_PARTICLE_SYSTEM_POINT_PLATFORM_H__
|
||||
#define __CC_PARTICLE_SYSTEM_POINT_PLATFORM_H__
|
||||
|
||||
#include "CCPlatformConfig.h"
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
|
||||
#error
|
||||
//#include "mac/CCParticleSystemPoint_mac.h"
|
||||
#else
|
||||
#include "CCParticleSystemPoint_mobile.h"
|
||||
#endif
|
||||
|
||||
#endif //__CC_PARTICLE_SYSTEM_POINT_PLATFORM_H__
|
|
@ -40,11 +40,10 @@ There are config below:
|
|||
// define supported target platform macro which CC uses.
|
||||
#define CC_PLATFORM_UNKNOWN 0
|
||||
#define CC_PLATFORM_IOS 1
|
||||
#define CC_PLATFORM_MAC 2
|
||||
#define CC_PLATFORM_ANDROID 3
|
||||
#define CC_PLATFORM_WOPHONE 4
|
||||
#define CC_PLATFORM_WIN32 5
|
||||
#define CC_PLATFORM_AIRPLAY 6
|
||||
#define CC_PLATFORM_ANDROID 2
|
||||
#define CC_PLATFORM_WOPHONE 3
|
||||
#define CC_PLATFORM_WIN32 4
|
||||
#define CC_PLATFORM_AIRPLAY 5
|
||||
|
||||
// Determine tartet platform by compile environment macro.
|
||||
#define CC_TARGET_PLATFORM CC_PLATFORM_UNKNOWN
|
||||
|
@ -57,12 +56,6 @@ There are config below:
|
|||
#define CC_SUPPORT_UNICODE 0
|
||||
#endif
|
||||
|
||||
// mac
|
||||
#if ! CC_TARGET_PLATFORM && defined(TARGET_OS_MAC)
|
||||
#undef CC_TARGET_PLATFORM
|
||||
#define CC_TARGET_PLATFORM CC_PLATFORM_MAC
|
||||
#endif
|
||||
|
||||
// android
|
||||
#if ! CC_TARGET_PLATFORM && defined(ANDROID)
|
||||
#undef CC_TARGET_PLATFORM
|
||||
|
@ -102,11 +95,6 @@ There are config below:
|
|||
#define CC_TARGET_PLATFORM CC_PLATFORM_IOS
|
||||
#endif
|
||||
|
||||
#if defined(CC_UNDER_MAC)
|
||||
#undef CC_TARGET_PLATFORM
|
||||
#define CC_TARGET_PLATFORM CC_PLATFORM_MAC
|
||||
#endif
|
||||
|
||||
#if defined(CC_UNDER_ANDROID)
|
||||
#undef CC_TARGET_PLATFORM
|
||||
#define CC_TARGET_PLATFORM CC_PLATFORM_ANDROID
|
||||
|
@ -153,13 +141,6 @@ There are config below:
|
|||
#error "Can not recognize the target platform, compling under a unsupported platform?"
|
||||
#endif
|
||||
|
||||
// distinguish mobile platforms and pc platforms
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
|
||||
#define CC_PLATFORM_PC
|
||||
#else
|
||||
#define CC_PLATFORM_MOBILE
|
||||
#endif
|
||||
|
||||
// cocos2d-x havn't support multi-thread yet
|
||||
#undef CC_SUPPORT_MULTITHREAD
|
||||
#define CC_SUPPORT_MULTITHREAD 0
|
||||
|
@ -173,9 +154,5 @@ There are config below:
|
|||
|
||||
#endif // CC_PLATFORM_WIN32
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
|
||||
#error cofnig
|
||||
#endif // CC_PLATFORM_MAC
|
||||
|
||||
#endif // __CC_PLATFORM_CONFIG_H__
|
||||
|
||||
|
|
|
@ -30,12 +30,8 @@
|
|||
#include "ccConfig.h"
|
||||
#include "CCPlatformConfig.h"
|
||||
|
||||
#if defined(CC_PLATFORM_MOBILE)
|
||||
#define MacGLView void
|
||||
#define NSWindow void
|
||||
#elif defined(CC_PLATFORM_PC)
|
||||
#include "platform/MacGLView.h"
|
||||
#endif
|
||||
|
||||
/** @def CC_ENABLE_CACHE_TEXTTURE_DATA
|
||||
Enable it if you want to cache the texture data.
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
/****************************************************************************
|
||||
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 __PLATFORM_MAC_CCDIRECTOR_DISPLAYLINK_MAC_WRAPPER
|
||||
#define __PLATFORM_MAC_CCDIRECTOR_DISPLAYLINK_MAC_WRAPPER
|
||||
|
||||
#import <QuartzCore/CVDisplayLink.h>
|
||||
|
||||
@interface CCDirectorDisplayLinkMacWrapper
|
||||
{
|
||||
CVDisplayLinkRef displayLink;
|
||||
NSThread *runningThread_;
|
||||
}
|
||||
|
||||
@property(nonatomic, readonly)NSThread *runningThread_;
|
||||
|
||||
+(CCDirectorDisplayLinkMacWrapper*)sharedDisplayLinkMacWrapper;
|
||||
-(void)startAnimation;
|
||||
-(void)stopAnimation;
|
||||
|
||||
@end
|
||||
|
||||
#endif // __PLATFORM_MAC_CCDIRECTOR_DISPLAYLINK_MAC_WRAPPER
|
|
@ -1,141 +0,0 @@
|
|||
/****************************************************************************
|
||||
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.
|
||||
****************************************************************************/
|
||||
#import "CCDirectorDisplayLinkMacWrapper.h"
|
||||
#import "ccConfig.h"
|
||||
|
||||
@implementation CCDirectorDisplayLinkMacWrapper
|
||||
|
||||
static CCDirectorDisplayLinkMacWrapper* sharedDisplayLinkMacWrapper;
|
||||
|
||||
@synthesize runningThread = runningThread_;
|
||||
|
||||
+(CCDirectorDisplayLinkMacWrapper*)sharedDisplayLinkMacWrapper
|
||||
{
|
||||
if (! sharedDisplayLinkMacWrapper)
|
||||
{
|
||||
sharedDiplayLinkMacWrapper = [CCDirectorDisplayLinkMacWrapper new];
|
||||
}
|
||||
|
||||
return sharedDiplayLinkMacWrapper;
|
||||
}
|
||||
|
||||
- (void) init
|
||||
{
|
||||
runningThread_ = nil;
|
||||
displayLink = nil;
|
||||
}
|
||||
|
||||
- (CVReturn) getFrameForTime:(const CVTimeStamp*)outputTime
|
||||
{
|
||||
#if CC_DIRECTOR_MAC_USE_DISPLAY_LINK_THREAD
|
||||
if( ! runningThread_ )
|
||||
runningThread_ = [NSThread currentThread];
|
||||
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
[self drawScene];
|
||||
[[CCEventDispatcher sharedDispatcher] dispatchQueuedEvents];
|
||||
|
||||
[[NSRunLoop currentRunLoop] run];
|
||||
|
||||
[pool release];
|
||||
|
||||
#else
|
||||
[self performSelector:@selector(drawScene) onThread:runningThread_ withObject:nil waitUntilDone:YES];
|
||||
#endif
|
||||
|
||||
return kCVReturnSuccess;
|
||||
}
|
||||
|
||||
// This is the renderer output callback function
|
||||
static CVReturn MyDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeStamp* now, const CVTimeStamp* outputTime, CVOptionFlags flagsIn, CVOptionFlags* flagsOut, void* displayLinkContext)
|
||||
{
|
||||
CVReturn result = [(CCDirectorDisplayLinkMacWrapper*)displayLinkContext getFrameForTime:outputTime];
|
||||
return result;
|
||||
}
|
||||
|
||||
- (void) startAnimation
|
||||
{
|
||||
#if ! CC_DIRECTOR_MAC_USE_DISPLAY_LINK_THREAD
|
||||
runningThread_ = [[NSThread alloc] initWithTarget:self selector:@selector(mainLoop) object:nil];
|
||||
[runningThread_ start];
|
||||
#endif
|
||||
|
||||
// Create a display link capable of being used with all active displays
|
||||
CVDisplayLinkCreateWithActiveCGDisplays(&displayLink);
|
||||
|
||||
// Set the renderer output callback function
|
||||
CVDisplayLinkSetOutputCallback(displayLink, &MyDisplayLinkCallback, self);
|
||||
|
||||
// Set the display link for the current renderer
|
||||
CGLContextObj cglContext = [[openGLView_ openGLContext] CGLContextObj];
|
||||
CGLPixelFormatObj cglPixelFormat = [[openGLView_ pixelFormat] CGLPixelFormatObj];
|
||||
CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext(displayLink, cglContext, cglPixelFormat);
|
||||
|
||||
// Activate the display link
|
||||
CVDisplayLinkStart(displayLink);
|
||||
}
|
||||
|
||||
- (void) mainLoop
|
||||
{
|
||||
cocos2d::CCDirector::sharedDirector()->mainLoop();
|
||||
}
|
||||
|
||||
- (void) stopAnimation
|
||||
{
|
||||
if( displayLink ) {
|
||||
CVDisplayLinkStop(displayLink);
|
||||
CVDisplayLinkRelease(displayLink);
|
||||
displayLink = NULL;
|
||||
|
||||
#if ! CC_DIRECTOR_MAC_USE_DISPLAY_LINK_THREAD
|
||||
[runningThread_ cancel];
|
||||
[runningThread_ release];
|
||||
runningThread_ = nil;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
-(void) dealloc
|
||||
{
|
||||
if( displayLink )
|
||||
{
|
||||
CVDisplayLinkStop(displayLink);
|
||||
CVDisplayLinkRelease(displayLink);
|
||||
}
|
||||
|
||||
sharedDisplayLinkMacWrapper = nil;
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
//
|
||||
// Draw the Scene
|
||||
//
|
||||
- (void) drawScene
|
||||
{
|
||||
cocos2d::CCDirector::sharedDirector()->drawScene();
|
||||
}
|
||||
|
||||
@end
|
|
@ -1,923 +0,0 @@
|
|||
/****************************************************************************
|
||||
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 "CCDirector.h"
|
||||
#include "CCScene.h"
|
||||
#include "NSMutableArray.h"
|
||||
#include "CCScheduler.h"
|
||||
#include "ccMacros.h"
|
||||
#include "CCXCocos2dDefine.h"
|
||||
#include "CCTouchDispatcher.h"
|
||||
#include "support/opengl_support/glu.h"
|
||||
#include "CGPointExtension.h"
|
||||
#include "CCTransition.h"
|
||||
#include "CCTextureCache.h"
|
||||
#include "CCTransition.h"
|
||||
#include "CCSpriteFrameCache.h"
|
||||
#include "NSAutoreleasePool.h"
|
||||
#include "platform/platform.h"
|
||||
#include "CCXApplication.h"
|
||||
#include "CCLabelBMFont.h"
|
||||
#include "CCActionManager.h"
|
||||
#include "CCLabelTTF.h"
|
||||
#include "CCConfiguration.h"
|
||||
#include "CCKeypadDispatcher.h"
|
||||
#include "CCGL.h"
|
||||
#include "CCDirectorDisplayLinkMacWrapper.h"
|
||||
|
||||
#if CC_ENABLE_PROFILERS
|
||||
#include "support/CCProfiling.h"
|
||||
#endif // CC_ENABLE_PROFILERS
|
||||
|
||||
#include <string>
|
||||
|
||||
using namespace std;
|
||||
using namespace cocos2d;
|
||||
namespace cocos2d
|
||||
{
|
||||
|
||||
// singleton stuff
|
||||
static CCDisplayLinkDirector s_sharedDirector;
|
||||
static bool s_bFirstRun = true;
|
||||
|
||||
#define kDefaultFPS 60 // 60 frames per second
|
||||
extern const char* cocos2dVersion(void);
|
||||
|
||||
CCDirector* CCDirector::sharedDirector(void)
|
||||
{
|
||||
if (s_bFirstRun)
|
||||
{
|
||||
s_sharedDirector.init();
|
||||
s_bFirstRun = false;
|
||||
}
|
||||
|
||||
return &s_sharedDirector;
|
||||
}
|
||||
|
||||
bool CCDirector::init(void)
|
||||
{
|
||||
CCLOG("cocos2d: %s", cocos2dVersion());
|
||||
|
||||
CCLOG("cocos2d: Using Director Type: CCDirectorDisplayLink");
|
||||
|
||||
// scenes
|
||||
m_pRunningScene = NULL;
|
||||
m_pNextScene = NULL;
|
||||
|
||||
m_pNotificationNode = NULL;
|
||||
|
||||
m_dOldAnimationInterval = m_dAnimationInterval = 1.0 / kDefaultFPS;
|
||||
m_pobScenesStack = new NSMutableArray<CCScene*>();
|
||||
|
||||
// Set default projection (3D)
|
||||
m_eProjection = kCCDirectorProjectionDefault;
|
||||
|
||||
// projection delegate if "Custom" projection is used
|
||||
m_pProjectionDelegate = NULL;
|
||||
|
||||
// FPS
|
||||
m_bDisplayFPS = false;
|
||||
m_nFrames = 0;
|
||||
m_pszFPS = new char[10];
|
||||
m_pLastUpdate = new struct cc_timeval();
|
||||
|
||||
// paused ?
|
||||
m_bPaused = false;
|
||||
|
||||
m_obWinSizeInPixels = m_obWinSizeInPoints = CGSizeZero;
|
||||
|
||||
m_pobOpenGLView = NULL;
|
||||
|
||||
m_bIsFullScreen = false;
|
||||
m_nResizeMode = kCCDirectorResize_AutoScale;
|
||||
|
||||
m_pFullScreenGLView = NULL;
|
||||
m_pFullScreenWindow = NULL;
|
||||
m_pWindowGLView = NULL;
|
||||
m_winOffset = CGPointZero;
|
||||
|
||||
// create autorelease pool
|
||||
NSPoolManager::getInstance()->push();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
CCDirector::~CCDirector(void)
|
||||
{
|
||||
CCLOGINFO("cocos2d: deallocing %p", this);
|
||||
|
||||
#if CC_DIRECTOR_FAST_FPS
|
||||
CCX_SAFE_RELEASE(m_pFPSLabel);
|
||||
#endif
|
||||
|
||||
CCX_SAFE_RELEASE(m_pRunningScene);
|
||||
CCX_SAFE_RELEASE(m_pNotificationNode);
|
||||
CCX_SAFE_RELEASE(m_pobScenesStack);
|
||||
|
||||
// pop the autorelease pool
|
||||
NSPoolManager::getInstance()->pop();
|
||||
|
||||
// delete m_pLastUpdate
|
||||
CCX_SAFE_DELETE(m_pLastUpdate);
|
||||
|
||||
// delete last compute time
|
||||
CCX_SAFE_DELETE(m_pLastComputeFrameRate);
|
||||
|
||||
CCKeypadDispatcher::purgeSharedDispatcher();
|
||||
|
||||
// delete fps string
|
||||
delete []m_pszFPS;
|
||||
|
||||
[m_pFullScreenGLView release];
|
||||
[m_pFullScreenWindow release];
|
||||
[m_pWindowGLView release];
|
||||
[[CCDirectorDisplayLinkMacWrapper sharedDisplayLinkMacWrapper] release];
|
||||
}
|
||||
|
||||
void CCDirector::setGLDefaultValues(void)
|
||||
{
|
||||
// This method SHOULD be called only after openGLView_ was initialized
|
||||
assert(m_pobOpenGLView);
|
||||
|
||||
setAlphaBlending(true);
|
||||
setDepthTest(true);
|
||||
setProjection(m_eProjection);
|
||||
|
||||
// set other opengl default values
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
#if CC_DIRECTOR_FAST_FPS
|
||||
if (! m_pFPSLabel)
|
||||
{
|
||||
m_pFPSLabel = CCLabelTTF::labelWithString("00.0", "Arial", 24);
|
||||
m_pFPSLabel->retain();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// Draw the SCene
|
||||
void CCDirector::drawScene(void)
|
||||
{
|
||||
// calculate "global" dt
|
||||
calculateDeltaTime();
|
||||
|
||||
//tick before glClear: issue #533
|
||||
if (! m_bPaused)
|
||||
{
|
||||
CCScheduler::sharedScheduler()->tick(m_fDeltaTime);
|
||||
}
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
/* 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)
|
||||
{
|
||||
setNextScene();
|
||||
}
|
||||
|
||||
glPushMatrix();
|
||||
|
||||
// By default enable VertexArray, ColorArray, TextureCoordArray and Texture2D
|
||||
CC_ENABLE_DEFAULT_GL_STATES();
|
||||
|
||||
// draw the scene
|
||||
if (m_pRunningScene)
|
||||
{
|
||||
m_pRunningScene->visit();
|
||||
}
|
||||
|
||||
// draw the notifications node
|
||||
if (m_pNotificationNode)
|
||||
{
|
||||
m_pNotificationNode->visit();
|
||||
}
|
||||
|
||||
if (m_bDisplayFPS)
|
||||
{
|
||||
showFPS();
|
||||
}
|
||||
|
||||
#if CC_ENABLE_PROFILERS
|
||||
showProfilers();
|
||||
#endif
|
||||
|
||||
CC_DISABLE_DEFAULT_GL_STATES();
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
// swap buffers
|
||||
if (m_pobOpenGLView)
|
||||
{
|
||||
m_pobOpenGLView->swapBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
void CCDirector::calculateDeltaTime(void)
|
||||
{
|
||||
struct cc_timeval now;
|
||||
|
||||
if (CCTime::gettimeofdayCocos2d(&now, NULL) != 0)
|
||||
{
|
||||
CCLOG("error in gettimeofday");
|
||||
m_fDeltaTime = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
// new delta time
|
||||
if (m_bNextDeltaTimeZero)
|
||||
{
|
||||
m_fDeltaTime = 0;
|
||||
m_bNextDeltaTimeZero = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_fDeltaTime = (now.tv_sec - m_pLastUpdate->tv_sec) + (now.tv_usec - m_pLastUpdate->tv_usec) / 1000000.0f;
|
||||
m_fDeltaTime = MAX(0, m_fDeltaTime);
|
||||
}
|
||||
|
||||
*m_pLastUpdate = now;
|
||||
}
|
||||
|
||||
|
||||
// m_dAnimationInterval
|
||||
void CCDirector::setAnimationInterval(double dValue)
|
||||
{
|
||||
CCLOG("cocos2d: Director#setAnimationInterval. Overrride me");
|
||||
assert(0);
|
||||
}
|
||||
|
||||
|
||||
// m_pobOpenGLView
|
||||
|
||||
void CCDirector::setOpenGLView(CC_GLVIEW *pobOpenGLView)
|
||||
{
|
||||
assert(pobOpenGLView);
|
||||
|
||||
if (m_pobOpenGLView != pobOpenGLView)
|
||||
{
|
||||
[m_pobOpenGLView release];
|
||||
m_pobOpenGLView = [pobOpenGLView retain];
|
||||
|
||||
|
||||
|
||||
// set size
|
||||
m_obWinSizeInPixels = m_obWinSizeInPoints = NSSizeToCGSize([pobOpenGLView bounds].size);
|
||||
|
||||
setGLDefaultValues();
|
||||
|
||||
// cache the NSWindow and NSOpgenGLView created from the NIB
|
||||
if (!m_bIsFullScreen && !m_pWindowGLView)
|
||||
{
|
||||
m_pWindowGLView = [pobOpenGLView retain];
|
||||
m_originalWinSize = m_obWinSizeInPixels;
|
||||
}
|
||||
|
||||
// for DirectorDisplayLink, because the it doesn't override setOpenGLView
|
||||
|
||||
CCEventDispatcher *eventDispatcher = [CCEventDispatcher sharedDispatcher];
|
||||
[m_pobOpenGLView setEventDelegate: eventDispatcher];
|
||||
[eventDispatcher setDispatchEvents: YES];
|
||||
|
||||
// Enable Touches. Default no.
|
||||
[pobOpenGLView setAcceptsTouchEvents:NO];
|
||||
// [view setAcceptsTouchEvents:YES];
|
||||
|
||||
|
||||
// Synchronize buffer swaps with vertical refresh rate
|
||||
[[pobOpenGLView openGLContext] makeCurrentContext];
|
||||
GLint swapInt = 1;
|
||||
[[pobOpenGLView openGLContext] setValues:&swapInt forParameter:NSOpenGLCPSwapInterval];
|
||||
}
|
||||
}
|
||||
|
||||
void CCDirector::setNextDeltaTimeZero(bool bNextDeltaTimeZero)
|
||||
{
|
||||
m_bNextDeltaTimeZero = bNextDeltaTimeZero;
|
||||
}
|
||||
|
||||
void CCDirector::setProjection(ccDirectorProjection kProjection)
|
||||
{
|
||||
CGSize size = m_obWinSizeInPixels;
|
||||
|
||||
CGPoint offset = CGPointZero;
|
||||
float widthAspect = size.width;
|
||||
float heightAspect = size.height;
|
||||
|
||||
if( m_nResizeMode == kCCDirectorResize_AutoScale && ! CGSizeEqualToSize(m_originalWinSize, CGSizeZero ) )
|
||||
{
|
||||
size = m_originalWinSize;
|
||||
|
||||
float aspect = m_originalWinSize.width / m_originalWinSize.height;
|
||||
widthAspect = m_obWinSizeInPixels.width;
|
||||
heightAspect = m_obWinSizeInPixels.width / aspect;
|
||||
|
||||
if( heightAspect > m_obWinSizeInPixels.height )
|
||||
{
|
||||
widthAspect = m_obWinSizeInPixels.height * aspect;
|
||||
heightAspect = m_obWinSizeInPixels.height;
|
||||
}
|
||||
|
||||
m_winOffset.x = (m_obWinSizeInPixels.width - widthAspect) / 2;
|
||||
m_winOffset.y = (m_obWinSizeInPixels.height - heightAspect) / 2;
|
||||
|
||||
offset = m_winOffset;
|
||||
}
|
||||
|
||||
switch (kProjection) {
|
||||
case kCCDirectorProjection2D:
|
||||
glViewport(offset.x, offset.y, widthAspect, heightAspect);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
ccglOrtho(0, size.width, 0, size.height, -1024, 1024);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
break;
|
||||
|
||||
case kCCDirectorProjection3D:
|
||||
glViewport(offset.x, offset.y, widthAspect, heightAspect);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
gluPerspective(60, (GLfloat)widthAspect/heightAspect, 0.1f, 1500.0f);
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
|
||||
float eyeZ = size.height * getZEye() / m_obWinSizeInPixels.height;
|
||||
|
||||
gluLookAt( size.width/2, size.height/2, eyeZ,
|
||||
size.width/2, size.height/2, 0,
|
||||
0.0f, 1.0f, 0.0f);
|
||||
break;
|
||||
|
||||
case kCCDirectorProjectionCustom:
|
||||
if(m_pProjectionDelegate)
|
||||
{
|
||||
m_pProjectionDelegate->updateProjection();
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
CCLOG("cocos2d: Director: unrecognized projecgtion");
|
||||
break;
|
||||
}
|
||||
|
||||
m_eProjection = kProjection;
|
||||
}
|
||||
|
||||
void CCDirector::purgeCachedData(void)
|
||||
{
|
||||
CCLabelBMFont::purgeCachedData();
|
||||
CCTextureCache::purgeSharedTextureCache();
|
||||
}
|
||||
|
||||
float CCDirector::getZEye(void)
|
||||
{
|
||||
return (m_obWinSizeInPixels.height / 1.1566f);
|
||||
}
|
||||
|
||||
void CCDirector::setAlphaBlending(bool bOn)
|
||||
{
|
||||
if (bOn)
|
||||
{
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(CC_BLEND_SRC, CC_BLEND_DST);
|
||||
}
|
||||
else
|
||||
{
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
}
|
||||
|
||||
void CCDirector::setDepthTest(bool bOn)
|
||||
{
|
||||
if (bOn)
|
||||
{
|
||||
ccglClearDepth(1.0f);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
|
||||
}
|
||||
else
|
||||
{
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
}
|
||||
}
|
||||
|
||||
CGPoint CCDirector::convertToGL(CGPoint obPoint)
|
||||
{
|
||||
assert(0);
|
||||
return CGPointZero;
|
||||
}
|
||||
|
||||
CGPoint CCDirector::convertToUI(CGPoint obPoint)
|
||||
{
|
||||
assert(0);
|
||||
return CGPointZero;
|
||||
}
|
||||
|
||||
CGSize CCDirector::getWinSize(void)
|
||||
{
|
||||
if (m_nResizeMode == kCCDirectorResize_AutoScale)
|
||||
{
|
||||
return m_originalWinSize;
|
||||
}
|
||||
|
||||
return m_obWinSizeInPixels;
|
||||
}
|
||||
|
||||
CGSize CCDirector::getWinSizeInPixels()
|
||||
{
|
||||
return getWinSize();
|
||||
}
|
||||
|
||||
// return the current frame size
|
||||
CGSize CCDirector::getDisplaySizeInPixels(void)
|
||||
{
|
||||
return m_obWinSizeInPixels;
|
||||
}
|
||||
|
||||
void CCDirector::reshapeProjection(CGSize newWindowSize)
|
||||
{
|
||||
m_obWinSizeInPixels = m_originalWinSize = newWindowSize;
|
||||
setProjection(m_eProjection);
|
||||
}
|
||||
|
||||
// scene management
|
||||
|
||||
void CCDirector::runWithScene(CCScene *pScene)
|
||||
{
|
||||
assert(pScene != NULL);
|
||||
assert(m_pRunningScene == NULL);
|
||||
|
||||
pushScene(pScene);
|
||||
startAnimation();
|
||||
}
|
||||
|
||||
void CCDirector::replaceScene(CCScene *pScene)
|
||||
{
|
||||
assert(pScene != NULL);
|
||||
|
||||
unsigned int index = m_pobScenesStack->count();
|
||||
|
||||
m_bSendCleanupToScene = true;
|
||||
m_pobScenesStack->replaceObjectAtIndex(index - 1, pScene);
|
||||
|
||||
m_pNextScene = pScene;
|
||||
}
|
||||
|
||||
void CCDirector::pushScene(CCScene *pScene)
|
||||
{
|
||||
assert(pScene);
|
||||
|
||||
m_bSendCleanupToScene = false;
|
||||
|
||||
m_pobScenesStack->addObject(pScene);
|
||||
m_pNextScene = pScene;
|
||||
}
|
||||
|
||||
void CCDirector::popScene(void)
|
||||
{
|
||||
assert(m_pRunningScene != NULL);
|
||||
|
||||
m_pobScenesStack->removeLastObject();
|
||||
unsigned int c = m_pobScenesStack->count();
|
||||
|
||||
if (c == 0)
|
||||
{
|
||||
end();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_bSendCleanupToScene = true;
|
||||
m_pNextScene = m_pobScenesStack->getObjectAtIndex(c - 1);
|
||||
}
|
||||
}
|
||||
|
||||
void CCDirector::end(void)
|
||||
{
|
||||
// don't release the event handlers
|
||||
// They are needed in case the director is run again
|
||||
CCTouchDispatcher::sharedDispatcher()->removeAllDelegates();
|
||||
|
||||
m_pRunningScene->onExit();
|
||||
m_pRunningScene->cleanup();
|
||||
m_pRunningScene->release();
|
||||
|
||||
m_pRunningScene = NULL;
|
||||
m_pNextScene = NULL;
|
||||
|
||||
// remove all objects, but don't release it.
|
||||
// runWithScene might be executed after 'end'.
|
||||
m_pobScenesStack->removeAllObjects();
|
||||
|
||||
stopAnimation();
|
||||
|
||||
#if CC_DIRECTOR_FAST_FPS
|
||||
CCX_SAFE_RELEASE_NULL(m_pFPSLabel);
|
||||
#endif
|
||||
|
||||
CCX_SAFE_RELEASE_NULL(m_pProjectionDelegate);
|
||||
|
||||
// purge bitmap cache
|
||||
CCLabelBMFont::purgeCachedData();
|
||||
|
||||
// purge all managers
|
||||
CCAnimationCache::purgeSharedAnimationCache();
|
||||
CCSpriteFrameCache::purgeSharedSpriteFrameCache();
|
||||
CCActionManager::sharedManager()->purgeSharedManager();
|
||||
CCScheduler::purgeSharedScheduler();
|
||||
CCTextureCache::purgeSharedTextureCache();
|
||||
|
||||
// OpenGL view
|
||||
[m_pobOpenGLView release];
|
||||
m_pobOpenGLView = NULL;
|
||||
}
|
||||
|
||||
void CCDirector::setNextScene(void)
|
||||
{
|
||||
ccSceneFlag runningSceneType = ccNormalScene;
|
||||
ccSceneFlag newSceneType = m_pNextScene->getSceneType();
|
||||
|
||||
if (m_pRunningScene)
|
||||
{
|
||||
runningSceneType = m_pRunningScene->getSceneType();
|
||||
}
|
||||
|
||||
// If it is not a transition, call onExit/cleanup
|
||||
/*if (! newIsTransition)*/
|
||||
if (! (newSceneType & ccTransitionScene))
|
||||
{
|
||||
if (m_pRunningScene)
|
||||
{
|
||||
m_pRunningScene->onExit();
|
||||
}
|
||||
|
||||
// issue #709. the root node (scene) should receive the cleanup message too
|
||||
// otherwise it might be leaked.
|
||||
if (m_bSendCleanupToScene && m_pRunningScene)
|
||||
{
|
||||
m_pRunningScene->cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
if (m_pRunningScene)
|
||||
{
|
||||
m_pRunningScene->release();
|
||||
}
|
||||
m_pRunningScene = m_pNextScene;
|
||||
m_pNextScene->retain();
|
||||
m_pNextScene = NULL;
|
||||
|
||||
if (! (runningSceneType & ccTransitionScene) && m_pRunningScene)
|
||||
{
|
||||
m_pRunningScene->onEnter();
|
||||
m_pRunningScene->onEnterTransitionDidFinish();
|
||||
}
|
||||
}
|
||||
|
||||
void CCDirector::pause(void)
|
||||
{
|
||||
if (m_bPaused)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_dOldAnimationInterval = m_dAnimationInterval;
|
||||
|
||||
// when paused, don't consume CPU
|
||||
setAnimationInterval(1 / 4.0);
|
||||
m_bPaused = true;
|
||||
}
|
||||
|
||||
void CCDirector::resume(void)
|
||||
{
|
||||
if (! m_bPaused)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
setAnimationInterval(m_dOldAnimationInterval);
|
||||
|
||||
if (CCTime::gettimeofdayCocos2d(m_pLastUpdate, NULL) != 0)
|
||||
{
|
||||
CCLOG("cocos2d: Director: Error in gettimeofday");
|
||||
}
|
||||
|
||||
m_bPaused = false;
|
||||
m_fDeltaTime = 0;
|
||||
}
|
||||
|
||||
void CCDirector::startAnimation(void)
|
||||
{
|
||||
CCLOG("cocos2d: Director#startAnimation. Overrride me");
|
||||
assert(0);
|
||||
}
|
||||
|
||||
void CCDirector::stopAnimation(void)
|
||||
{
|
||||
CCLOG("cocos2d: Director#stopAnimation. Overrride me");
|
||||
assert(0);
|
||||
}
|
||||
|
||||
void CCDirector::mainLoop(void)
|
||||
{
|
||||
CCLOG("cocos2d: Director#preMainLoop. Overrride me");
|
||||
assert(0);
|
||||
}
|
||||
|
||||
#if CC_DIRECTOR_FAST_FPS
|
||||
// display the FPS using a LabelAtlas
|
||||
// updates the FPS every frame
|
||||
void CCDirector::showFPS(void)
|
||||
{
|
||||
m_nFrames++;
|
||||
m_fAccumDt += m_fDeltaTime;
|
||||
|
||||
if (m_fAccumDt > CC_DIRECTOR_FPS_INTERVAL)
|
||||
{
|
||||
m_fFrameRate = m_nFrames / m_fAccumDt;
|
||||
m_nFrames = 0;
|
||||
m_fAccumDt = 0;
|
||||
|
||||
sprintf(m_pszFPS, "%.1f", m_fFrameRate);
|
||||
m_pFPSLabel->setString(m_pszFPS);
|
||||
}
|
||||
|
||||
m_pFPSLabel->draw();
|
||||
}
|
||||
#endif // CC_DIRECTOR_FAST_FPS
|
||||
|
||||
void CCDirector::showProfilers()
|
||||
{
|
||||
#if CC_ENABLE_PROFILERS
|
||||
m_fAccumDtForProfiler += m_fDeltaTime;
|
||||
if (m_fAccumDtForProfiler > 1.0f)
|
||||
{
|
||||
m_fAccumDtForProfiler = 0;
|
||||
CCProfiler::sharedProfiler()->displayTimers();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/***************************************************
|
||||
* mobile platforms specific functions
|
||||
**************************************************/
|
||||
|
||||
// is the view currently attached
|
||||
bool CCDirector::isOpenGLAttached(void)
|
||||
{
|
||||
assert(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
void CCDirector::updateContentScaleFactor()
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
|
||||
// detach or attach to a view or a window
|
||||
bool CCDirector::detach(void)
|
||||
{
|
||||
assert(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
void CCDirector::setDepthBufferFormat(tDepthBufferFormat kDepthBufferFormat)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
void CCDirector::setPixelFormat(tPixelFormat kPixelFormat)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
tPixelFormat CCDirector::getPiexFormat(void)
|
||||
{
|
||||
assert(false);
|
||||
return m_ePixelFormat;
|
||||
}
|
||||
|
||||
bool CCDirector::setDirectorType(ccDirectorType obDirectorType)
|
||||
{
|
||||
// we only support CCDisplayLinkDirector
|
||||
CCDirector::sharedDirector();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CCDirector::enableRetinaDisplay(bool enabled)
|
||||
{
|
||||
assert(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
CGFloat CCDirector::getContentScaleFactor(void)
|
||||
{
|
||||
assert(false);
|
||||
return m_fContentScaleFactor;
|
||||
}
|
||||
|
||||
void CCDirector::setContentScaleFactor(CGFloat scaleFactor)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
void CCDirector::applyOrientation(void)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
ccDeviceOrientation CCDirector::getDeviceOrientation(void)
|
||||
{
|
||||
assert(false);
|
||||
return m_eDeviceOrientation;
|
||||
}
|
||||
|
||||
void CCDirector::setDeviceOrientation(ccDeviceOrientation kDeviceOrientation)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
/***************************************************
|
||||
* PC platforms specific functions, such as mac
|
||||
**************************************************/
|
||||
|
||||
CGPoint CCDirector::convertEventToGL(NSEvent *event);
|
||||
{
|
||||
///@todo NSEvent have not implemented
|
||||
return CGPointZero;
|
||||
}
|
||||
|
||||
bool CCDirector::isFullScreen(void)
|
||||
{
|
||||
return m_bIsFullScreen;
|
||||
}
|
||||
|
||||
void CCDirector::setResizeMode(int resizeMode)
|
||||
{
|
||||
assert("not supported.");
|
||||
}
|
||||
|
||||
int CCDirector::getResizeMode(void);
|
||||
{
|
||||
assert("not supported.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
void CCDirector::setFullScreen(bool fullscreen)
|
||||
{
|
||||
// Mac OS X 10.6 and later offer a simplified mechanism to create full-screen contexts
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_5
|
||||
|
||||
if( m_bIsFullScreen != fullscreen )
|
||||
{
|
||||
m_bIsFullScreen = fullscreen;
|
||||
|
||||
if( fullscreen )
|
||||
{
|
||||
// create the fullscreen view/window
|
||||
NSRect mainDisplayRect, viewRect;
|
||||
|
||||
// Create a screen-sized window on the display you want to take over
|
||||
// Note, mainDisplayRect has a non-zero origin if the key window is on a secondary display
|
||||
mainDisplayRect = [[NSScreen mainScreen] frame];
|
||||
m_pFullScreenWindow = [[NSWindow alloc] initWithContentRect:mainDisplayRect
|
||||
styleMask:NSBorderlessWindowMask
|
||||
backing:NSBackingStoreBuffered
|
||||
defer:YES];
|
||||
|
||||
// Set the window level to be above the menu bar
|
||||
[m_pFullScreenWindow setLevel:NSMainMenuWindowLevel+1];
|
||||
|
||||
// Perform any other window configuration you desire
|
||||
[m_pFullScreenWindow setOpaque:YES];
|
||||
[m_pFullScreenWindow setHidesOnDeactivate:YES];
|
||||
|
||||
// Create a view with a double-buffered OpenGL context and attach it to the window
|
||||
// By specifying the non-fullscreen context as the shareContext, we automatically inherit the OpenGL objects (textures, etc) it has defined
|
||||
viewRect = NSMakeRect(0.0, 0.0, mainDisplayRect.size.width, mainDisplayRect.size.height);
|
||||
|
||||
m_pFullScreenGLView = [[MacGLView alloc] initWithFrame:viewRect shareContext:[m_pobOpenGLView openGLContext]];
|
||||
|
||||
[m_pFullScreenWindow setContentView:m_pFullScreenGLView];
|
||||
|
||||
// Show the window
|
||||
[m_pFullScreenWindow makeKeyAndOrderFront:self];
|
||||
|
||||
[self setOpenGLView:fullScreenGLView_];
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
[m_pFullScreenWindow release];
|
||||
[m_pFullScreenGLView release];
|
||||
m_pFullScreenWindow = nil;
|
||||
m_pFullScreenGLView = nil;
|
||||
|
||||
[[m_pFullScreenGLView openGLContext] makeCurrentContext];
|
||||
setOpenGLView(m_pFullScreenGLView);
|
||||
}
|
||||
|
||||
[m_pobOpenGLView setNeedsDisplay:YES];
|
||||
}
|
||||
#else
|
||||
#error Full screen is not supported for Mac OS 10.5 or older yet
|
||||
#error If you don't want FullScreen support, you can safely remove these 2 lines
|
||||
#endif
|
||||
}
|
||||
|
||||
CGPoint CCDirector::convertToLogicalCoordinates(CGPoint coordinates)
|
||||
{
|
||||
CGPoint ret;
|
||||
|
||||
if( m_nResizeMode == kCCDirectorResize_NoScale )
|
||||
{
|
||||
ret = coordinates;
|
||||
}
|
||||
else
|
||||
{
|
||||
float x_diff = m_originalWinSize.width / (m_obWinSizeInPixels.width - m_winOffset.x * 2);
|
||||
float y_diff = m_originalWinSize.height / (m_obWinSizeInPixels.height - m_winOffset.y * 2);
|
||||
|
||||
float adjust_x = (m_obWinSizeInPixels.width * x_diff - m_originalWinSize.width ) / 2;
|
||||
float adjust_y = (m_obWinSizeInPixels.height * y_diff - m_originalWinSize.height ) / 2;
|
||||
|
||||
ret = CGPointMake( (x_diff * coordinates.x) - adjust_x, ( y_diff * coordinates.y ) - adjust_y );
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/***************************************************
|
||||
* implementation of DisplayLinkDirector
|
||||
**************************************************/
|
||||
|
||||
// should we afford 4 types of director ??
|
||||
// I think DisplayLinkDirector is enough
|
||||
// so we now only support DisplayLinkDirector
|
||||
void CCDisplayLinkDirector::startAnimation(void)
|
||||
{
|
||||
if (CCTime::gettimeofdayCocos2d(m_pLastUpdate, NULL) != 0)
|
||||
{
|
||||
CCLOG("cocos2d: DisplayLinkDirector: Error on gettimeofday");
|
||||
}
|
||||
|
||||
m_bInvalid = false;
|
||||
|
||||
[[CCDirectorDisplayLinkMacWrapper sharedDisplayLinkMacWrapper] startAnimation];
|
||||
}
|
||||
|
||||
void CCDisplayLinkDirector::mainLoop(void)
|
||||
{
|
||||
if (! m_bInvalid)
|
||||
{
|
||||
drawScene();
|
||||
|
||||
// release the objects
|
||||
NSPoolManager::getInstance()->pop();
|
||||
}
|
||||
}
|
||||
|
||||
void CCDisplayLinkDirector::stopAnimation(void)
|
||||
{
|
||||
m_bInvalid = true;
|
||||
|
||||
[[CCDirectorDisplayLinkMacWrapper sharedDisplayLinkMacWrapper] stopAnimation];
|
||||
}
|
||||
|
||||
void CCDisplayLinkDirector::setAnimationInterval(double dValue)
|
||||
{
|
||||
m_dAnimationInterval = dValue;
|
||||
m_fExpectedFrameRate = (ccTime)(1 / m_dAnimationInterval);
|
||||
if (! m_bInvalid)
|
||||
{
|
||||
stopAnimation();
|
||||
startAnimation();
|
||||
}
|
||||
}
|
||||
|
||||
} //namespace cocos2d
|
|
@ -1,233 +0,0 @@
|
|||
/*
|
||||
* cocos2d for iPhone: http://www.cocos2d-iphone.org
|
||||
*
|
||||
* Copyright (c) 2010 Ricardo Quesada
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Only compile this code on Mac. These files should not be included on your iOS project.
|
||||
// But in case they are included, it won't be compiled.
|
||||
#import <Availability.h>
|
||||
#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
|
||||
#elif defined(__MAC_OS_X_VERSION_MAX_ALLOWED)
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#import "MacGLView.h"
|
||||
#import "../../Support/uthash.h" // hack: uthash needs to be imported before utlist to prevent warning
|
||||
#import "../../Support/utlist.h"
|
||||
#import "../../ccConfig.h"
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark CCMouseEventDelegate
|
||||
|
||||
/** CCMouseEventDelegate protocol.
|
||||
Implement it in your node to receive any of mouse events
|
||||
*/
|
||||
@protocol CCMouseEventDelegate <NSObject>
|
||||
@optional
|
||||
|
||||
//
|
||||
// left
|
||||
//
|
||||
/** called when the "mouseDown" event is received.
|
||||
Return YES to avoid propagating the event to other delegates.
|
||||
*/
|
||||
-(BOOL) ccMouseDown:(NSEvent*)event;
|
||||
|
||||
/** called when the "mouseDragged" event is received.
|
||||
Return YES to avoid propagating the event to other delegates.
|
||||
*/
|
||||
-(BOOL) ccMouseDragged:(NSEvent*)event;
|
||||
|
||||
/** called when the "mouseMoved" event is received.
|
||||
Return YES to avoid propagating the event to other delegates.
|
||||
By default, "mouseMoved" is disabled. To enable it, send the "setAcceptsMouseMovedEvents:YES" message to the main window.
|
||||
*/
|
||||
-(BOOL) ccMouseMoved:(NSEvent*)event;
|
||||
|
||||
/** called when the "mouseUp" event is received.
|
||||
Return YES to avoid propagating the event to other delegates.
|
||||
*/
|
||||
-(BOOL) ccMouseUp:(NSEvent*)event;
|
||||
|
||||
|
||||
//
|
||||
// right
|
||||
//
|
||||
|
||||
/** called when the "rightMouseDown" event is received.
|
||||
Return YES to avoid propagating the event to other delegates.
|
||||
*/
|
||||
-(BOOL) ccRightMouseDown:(NSEvent*)event;
|
||||
|
||||
/** called when the "rightMouseDragged" event is received.
|
||||
Return YES to avoid propagating the event to other delegates.
|
||||
*/
|
||||
-(BOOL) ccRightMouseDragged:(NSEvent*)event;
|
||||
|
||||
/** called when the "rightMouseUp" event is received.
|
||||
Return YES to avoid propagating the event to other delegates.
|
||||
*/
|
||||
-(BOOL) ccRightMouseUp:(NSEvent*)event;
|
||||
|
||||
//
|
||||
// other
|
||||
//
|
||||
|
||||
/** called when the "otherMouseDown" event is received.
|
||||
Return YES to avoid propagating the event to other delegates.
|
||||
*/
|
||||
-(BOOL) ccOtherMouseDown:(NSEvent*)event;
|
||||
|
||||
/** called when the "otherMouseDragged" event is received.
|
||||
Return YES to avoid propagating the event to other delegates.
|
||||
*/
|
||||
-(BOOL) ccOtherMouseDragged:(NSEvent*)event;
|
||||
|
||||
/** called when the "otherMouseUp" event is received.
|
||||
Return YES to avoid propagating the event to other delegates.
|
||||
*/
|
||||
-(BOOL) ccOtherMouseUp:(NSEvent*)event;
|
||||
|
||||
//
|
||||
// scroll wheel
|
||||
//
|
||||
|
||||
/** called when the "scrollWheel" event is received.
|
||||
Return YES to avoid propagating the event to other delegates.
|
||||
*/
|
||||
- (BOOL)ccScrollWheel:(NSEvent *)theEvent;
|
||||
|
||||
|
||||
//
|
||||
// enter / exit
|
||||
//
|
||||
|
||||
/** called when the "mouseEntered" event is received.
|
||||
Return YES to avoid propagating the event to other delegates.
|
||||
*/
|
||||
- (void)ccMouseEntered:(NSEvent *)theEvent;
|
||||
|
||||
/** called when the "mouseExited" event is received.
|
||||
Return YES to avoid propagating the event to other delegates.
|
||||
*/
|
||||
- (void)ccMouseExited:(NSEvent *)theEvent;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark CCKeyboardEventDelegate
|
||||
|
||||
/** CCKeyboardEventDelegate protocol.
|
||||
Implement it in your node to receive any of keyboard events
|
||||
*/
|
||||
@protocol CCKeyboardEventDelegate <NSObject>
|
||||
@optional
|
||||
/** called when the "keyUp" event is received.
|
||||
Return YES to avoid propagating the event to other delegates.
|
||||
*/
|
||||
-(BOOL) ccKeyUp:(NSEvent*)event;
|
||||
|
||||
/** called when the "keyDown" event is received.
|
||||
Return YES to avoid propagating the event to other delegates.
|
||||
*/
|
||||
-(BOOL) ccKeyDown:(NSEvent*)event;
|
||||
/** called when the "flagsChanged" event is received.
|
||||
Return YES to avoid propagating the event to other delegates.
|
||||
*/
|
||||
-(BOOL) ccFlagsChanged:(NSEvent*)event;
|
||||
@end
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark CCEventDispatcher
|
||||
|
||||
struct _listEntry;
|
||||
|
||||
/** CCEventDispatcher
|
||||
|
||||
This is object is responsible for dispatching the events:
|
||||
- Mouse events
|
||||
- Keyboard events
|
||||
- Touch events
|
||||
|
||||
Only available on Mac
|
||||
*/
|
||||
@interface CCEventDispatcher : NSObject <MacEventDelegate> {
|
||||
|
||||
BOOL dispatchEvents_;
|
||||
|
||||
struct _listEntry *keyboardDelegates_;
|
||||
struct _listEntry *mouseDelegates_;
|
||||
}
|
||||
|
||||
@property (nonatomic, readwrite) BOOL dispatchEvents;
|
||||
|
||||
|
||||
/** CCEventDispatcher singleton */
|
||||
+(CCEventDispatcher*) sharedDispatcher;
|
||||
|
||||
#pragma mark CCEventDispatcher - Mouse
|
||||
|
||||
/** Adds a mouse delegate to the dispatcher's list.
|
||||
Delegates with a lower priority value will be called before higher priority values.
|
||||
All the events will be propgated to all the delegates, unless the one delegate returns YES.
|
||||
|
||||
IMPORTANT: The delegate will be retained.
|
||||
*/
|
||||
-(void) addMouseDelegate:(id<CCMouseEventDelegate>) delegate priority:(NSInteger)priority;
|
||||
|
||||
/** removes a mouse delegate */
|
||||
-(void) removeMouseDelegate:(id) delegate;
|
||||
|
||||
/** Removes all mouse delegates, releasing all the delegates */
|
||||
-(void) removeAllMouseDelegates;
|
||||
|
||||
#pragma mark CCEventDispatcher - Keyboard
|
||||
|
||||
/** Adds a Keyboard delegate to the dispatcher's list.
|
||||
Delegates with a lower priority value will be called before higher priority values.
|
||||
All the events will be propgated to all the delegates, unless the one delegate returns YES.
|
||||
|
||||
IMPORTANT: The delegate will be retained.
|
||||
*/
|
||||
-(void) addKeyboardDelegate:(id<CCKeyboardEventDelegate>) delegate priority:(NSInteger)priority;
|
||||
|
||||
/** removes a mouse delegate */
|
||||
-(void) removeKeyboardDelegate:(id) delegate;
|
||||
|
||||
/** Removes all mouse delegates, releasing all the delegates */
|
||||
-(void) removeAllKeyboardDelegates;
|
||||
|
||||
#pragma mark CCEventDispatcher - Touches
|
||||
|
||||
// XXX
|
||||
|
||||
#pragma mark CCEventDispatcher - Dispatch Events
|
||||
|
||||
#if CC_DIRECTOR_MAC_USE_DISPLAY_LINK_THREAD
|
||||
-(void) dispatchQueuedEvents;
|
||||
#endif
|
||||
|
||||
@end
|
||||
|
||||
|
||||
#endif // __MAC_OS_X_VERSION_MAX_ALLOWED
|
|
@ -1,578 +0,0 @@
|
|||
/*
|
||||
* cocos2d for iPhone: http://www.cocos2d-iphone.org
|
||||
*
|
||||
* Copyright (c) 2010 Ricardo Quesada
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Only compile this code on Mac. These files should not be included on your iOS project.
|
||||
// But in case they are included, it won't be compiled.
|
||||
#import <Availability.h>
|
||||
#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
|
||||
#elif defined(__MAC_OS_X_VERSION_MAX_ALLOWED)
|
||||
|
||||
#import "CCEventDispatcher.h"
|
||||
#import "../../ccConfig.h"
|
||||
|
||||
static CCEventDispatcher *sharedDispatcher = nil;
|
||||
|
||||
enum {
|
||||
// mouse
|
||||
kCCImplementsMouseDown = 1 << 0,
|
||||
kCCImplementsMouseMoved = 1 << 1,
|
||||
kCCImplementsMouseDragged = 1 << 2,
|
||||
kCCImplementsMouseUp = 1 << 3,
|
||||
kCCImplementsRightMouseDown = 1 << 4,
|
||||
kCCImplementsRightMouseDragged = 1 << 5,
|
||||
kCCImplementsRightMouseUp = 1 << 6,
|
||||
kCCImplementsOtherMouseDown = 1 << 7,
|
||||
kCCImplementsOtherMouseDragged = 1 << 8,
|
||||
kCCImplementsOtherMouseUp = 1 << 9,
|
||||
kCCImplementsScrollWheel = 1 << 10,
|
||||
kCCImplementsMouseEntered = 1 << 11,
|
||||
kCCImplementsMouseExited = 1 << 12,
|
||||
|
||||
// keyboard
|
||||
kCCImplementsKeyUp = 1 << 0,
|
||||
kCCImplementsKeyDown = 1 << 1,
|
||||
kCCImplementsFlagsChanged = 1 << 2,
|
||||
};
|
||||
|
||||
|
||||
typedef struct _listEntry
|
||||
{
|
||||
struct _listEntry *prev, *next;
|
||||
id delegate;
|
||||
NSInteger priority;
|
||||
NSUInteger flags;
|
||||
} tListEntry;
|
||||
|
||||
|
||||
#if CC_DIRECTOR_MAC_USE_DISPLAY_LINK_THREAD
|
||||
|
||||
#define QUEUE_EVENT_MAX 128
|
||||
struct _eventQueue {
|
||||
SEL selector;
|
||||
NSEvent *event;
|
||||
};
|
||||
|
||||
static struct _eventQueue eventQueue[QUEUE_EVENT_MAX];
|
||||
static int eventQueueCount;
|
||||
|
||||
#endif // CC_DIRECTOR_MAC_USE_DISPLAY_LINK_THREAD
|
||||
|
||||
|
||||
@implementation CCEventDispatcher
|
||||
|
||||
@synthesize dispatchEvents=dispatchEvents_;
|
||||
|
||||
|
||||
+(CCEventDispatcher*) sharedDispatcher
|
||||
{
|
||||
@synchronized(self) {
|
||||
if (sharedDispatcher == nil)
|
||||
sharedDispatcher = [[self alloc] init]; // assignment not done here
|
||||
}
|
||||
return sharedDispatcher;
|
||||
}
|
||||
|
||||
+(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) init
|
||||
{
|
||||
if( (self = [super init]) )
|
||||
{
|
||||
// events enabled by default
|
||||
dispatchEvents_ = YES;
|
||||
|
||||
// delegates
|
||||
keyboardDelegates_ = NULL;
|
||||
mouseDelegates_ = NULL;
|
||||
|
||||
#if CC_DIRECTOR_MAC_USE_DISPLAY_LINK_THREAD
|
||||
eventQueueCount = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
#pragma mark CCEventDispatcher - add / remove delegates
|
||||
|
||||
-(void) addDelegate:(id)delegate priority:(NSInteger)priority flags:(NSUInteger)flags list:(tListEntry**)list
|
||||
{
|
||||
tListEntry *listElement = malloc( sizeof(*listElement) );
|
||||
|
||||
listElement->delegate = [delegate retain];
|
||||
listElement->priority = priority;
|
||||
listElement->flags = flags;
|
||||
listElement->next = listElement->prev = NULL;
|
||||
|
||||
// empty list ?
|
||||
if( ! *list ) {
|
||||
DL_APPEND( *list, listElement );
|
||||
|
||||
} else {
|
||||
BOOL added = NO;
|
||||
|
||||
for( tListEntry *elem = *list; elem ; elem = elem->next ) {
|
||||
if( priority < elem->priority ) {
|
||||
|
||||
if( elem == *list )
|
||||
DL_PREPEND(*list, listElement);
|
||||
else {
|
||||
listElement->next = elem;
|
||||
listElement->prev = elem->prev;
|
||||
|
||||
elem->prev->next = listElement;
|
||||
elem->prev = listElement;
|
||||
}
|
||||
|
||||
added = YES;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Not added? priority has the higher value. Append it.
|
||||
if( !added )
|
||||
DL_APPEND(*list, listElement);
|
||||
}
|
||||
}
|
||||
|
||||
-(void) removeDelegate:(id)delegate fromList:(tListEntry**)list
|
||||
{
|
||||
tListEntry *entry, *tmp;
|
||||
|
||||
// updates with priority < 0
|
||||
DL_FOREACH_SAFE( *list, entry, tmp ) {
|
||||
if( entry->delegate == delegate ) {
|
||||
DL_DELETE( *list, entry );
|
||||
[delegate release];
|
||||
free(entry);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-(void) removeAllDelegatesFromList:(tListEntry**)list
|
||||
{
|
||||
tListEntry *entry, *tmp;
|
||||
|
||||
DL_FOREACH_SAFE( *list, entry, tmp ) {
|
||||
DL_DELETE( *list, entry );
|
||||
free(entry);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
-(void) addMouseDelegate:(id<CCMouseEventDelegate>) delegate priority:(NSInteger)priority
|
||||
{
|
||||
NSUInteger flags = 0;
|
||||
|
||||
flags |= ( [delegate respondsToSelector:@selector(ccMouseDown:)] ? kCCImplementsMouseDown : 0 );
|
||||
flags |= ( [delegate respondsToSelector:@selector(ccMouseDragged:)] ? kCCImplementsMouseDragged : 0 );
|
||||
flags |= ( [delegate respondsToSelector:@selector(ccMouseMoved:)] ? kCCImplementsMouseMoved : 0 );
|
||||
flags |= ( [delegate respondsToSelector:@selector(ccMouseUp:)] ? kCCImplementsMouseUp : 0 );
|
||||
|
||||
flags |= ( [delegate respondsToSelector:@selector(ccRightMouseDown:)] ? kCCImplementsRightMouseDown : 0 );
|
||||
flags |= ( [delegate respondsToSelector:@selector(ccRightMouseDragged:)] ? kCCImplementsRightMouseDragged : 0 );
|
||||
flags |= ( [delegate respondsToSelector:@selector(ccRightMouseUp:)] ? kCCImplementsRightMouseUp : 0 );
|
||||
|
||||
flags |= ( [delegate respondsToSelector:@selector(ccOtherMouseDown:)] ? kCCImplementsOtherMouseDown : 0 );
|
||||
flags |= ( [delegate respondsToSelector:@selector(ccOtherMouseDragged:)] ? kCCImplementsOtherMouseDragged : 0 );
|
||||
flags |= ( [delegate respondsToSelector:@selector(ccOtherMouseUp:)] ? kCCImplementsOtherMouseUp : 0 );
|
||||
|
||||
flags |= ( [delegate respondsToSelector:@selector(ccMouseEntered:)] ? kCCImplementsMouseEntered : 0 );
|
||||
flags |= ( [delegate respondsToSelector:@selector(ccMouseExited:)] ? kCCImplementsMouseExited : 0 );
|
||||
|
||||
flags |= ( [delegate respondsToSelector:@selector(ccScrollWheel:)] ? kCCImplementsScrollWheel : 0 );
|
||||
|
||||
[self addDelegate:delegate priority:priority flags:flags list:&mouseDelegates_];
|
||||
}
|
||||
|
||||
-(void) removeMouseDelegate:(id) delegate
|
||||
{
|
||||
[self removeDelegate:delegate fromList:&mouseDelegates_];
|
||||
}
|
||||
|
||||
-(void) removeAllMouseDelegates
|
||||
{
|
||||
[self removeAllDelegatesFromList:&mouseDelegates_];
|
||||
}
|
||||
|
||||
-(void) addKeyboardDelegate:(id<CCKeyboardEventDelegate>) delegate priority:(NSInteger)priority
|
||||
{
|
||||
NSUInteger flags = 0;
|
||||
|
||||
flags |= ( [delegate respondsToSelector:@selector(ccKeyUp:)] ? kCCImplementsKeyUp : 0 );
|
||||
flags |= ( [delegate respondsToSelector:@selector(ccKeyDown:)] ? kCCImplementsKeyDown : 0 );
|
||||
flags |= ( [delegate respondsToSelector:@selector(ccFlagsChanged:)] ? kCCImplementsFlagsChanged : 0 );
|
||||
|
||||
[self addDelegate:delegate priority:priority flags:flags list:&keyboardDelegates_];
|
||||
}
|
||||
|
||||
-(void) removeKeyboardDelegate:(id) delegate
|
||||
{
|
||||
[self removeDelegate:delegate fromList:&keyboardDelegates_];
|
||||
}
|
||||
|
||||
-(void) removeAllKeyboardDelegates
|
||||
{
|
||||
[self removeAllDelegatesFromList:&keyboardDelegates_];
|
||||
}
|
||||
|
||||
#pragma mark CCEventDispatcher - Mouse events
|
||||
//
|
||||
// Mouse events
|
||||
//
|
||||
|
||||
//
|
||||
// Left
|
||||
//
|
||||
- (void)mouseDown:(NSEvent *)event
|
||||
{
|
||||
if( dispatchEvents_ ) {
|
||||
tListEntry *entry, *tmp;
|
||||
|
||||
DL_FOREACH_SAFE( mouseDelegates_, entry, tmp ) {
|
||||
if ( entry->flags & kCCImplementsMouseDown ) {
|
||||
void *swallows = [entry->delegate performSelector:@selector(ccMouseDown:) withObject:event];
|
||||
if( swallows )
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)mouseMoved:(NSEvent *)event
|
||||
{
|
||||
if( dispatchEvents_ ) {
|
||||
tListEntry *entry, *tmp;
|
||||
|
||||
DL_FOREACH_SAFE( mouseDelegates_, entry, tmp ) {
|
||||
if ( entry->flags & kCCImplementsMouseMoved ) {
|
||||
void *swallows = [entry->delegate performSelector:@selector(ccMouseMoved:) withObject:event];
|
||||
if( swallows )
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)mouseDragged:(NSEvent *)event
|
||||
{
|
||||
if( dispatchEvents_ ) {
|
||||
tListEntry *entry, *tmp;
|
||||
|
||||
DL_FOREACH_SAFE( mouseDelegates_, entry, tmp ) {
|
||||
if ( entry->flags & kCCImplementsMouseDragged ) {
|
||||
void *swallows = [entry->delegate performSelector:@selector(ccMouseDragged:) withObject:event];
|
||||
if( swallows )
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)mouseUp:(NSEvent *)event
|
||||
{
|
||||
if( dispatchEvents_ ) {
|
||||
tListEntry *entry, *tmp;
|
||||
|
||||
DL_FOREACH_SAFE( mouseDelegates_, entry, tmp ) {
|
||||
if ( entry->flags & kCCImplementsMouseUp ) {
|
||||
void *swallows = [entry->delegate performSelector:@selector(ccMouseUp:) withObject:event];
|
||||
if( swallows )
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Mouse Right
|
||||
//
|
||||
- (void)rightMouseDown:(NSEvent *)event
|
||||
{
|
||||
if( dispatchEvents_ ) {
|
||||
tListEntry *entry, *tmp;
|
||||
|
||||
DL_FOREACH_SAFE( mouseDelegates_, entry, tmp ) {
|
||||
if ( entry->flags & kCCImplementsRightMouseDown ) {
|
||||
void *swallows = [entry->delegate performSelector:@selector(ccRightMouseDown:) withObject:event];
|
||||
if( swallows )
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)rightMouseDragged:(NSEvent *)event
|
||||
{
|
||||
if( dispatchEvents_ ) {
|
||||
tListEntry *entry, *tmp;
|
||||
|
||||
DL_FOREACH_SAFE( mouseDelegates_, entry, tmp ) {
|
||||
if ( entry->flags & kCCImplementsRightMouseDragged ) {
|
||||
void *swallows = [entry->delegate performSelector:@selector(ccRightMouseDragged:) withObject:event];
|
||||
if( swallows )
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)rightMouseUp:(NSEvent *)event
|
||||
{
|
||||
if( dispatchEvents_ ) {
|
||||
tListEntry *entry, *tmp;
|
||||
|
||||
DL_FOREACH_SAFE( mouseDelegates_, entry, tmp ) {
|
||||
if ( entry->flags & kCCImplementsRightMouseUp ) {
|
||||
void *swallows = [entry->delegate performSelector:@selector(ccRightMouseUp:) withObject:event];
|
||||
if( swallows )
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Mouse Other
|
||||
//
|
||||
- (void)otherMouseDown:(NSEvent *)event
|
||||
{
|
||||
if( dispatchEvents_ ) {
|
||||
tListEntry *entry, *tmp;
|
||||
|
||||
DL_FOREACH_SAFE( mouseDelegates_, entry, tmp ) {
|
||||
if ( entry->flags & kCCImplementsOtherMouseDown ) {
|
||||
void *swallows = [entry->delegate performSelector:@selector(ccOtherMouseDown:) withObject:event];
|
||||
if( swallows )
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)otherMouseDragged:(NSEvent *)event
|
||||
{
|
||||
if( dispatchEvents_ ) {
|
||||
tListEntry *entry, *tmp;
|
||||
|
||||
DL_FOREACH_SAFE( mouseDelegates_, entry, tmp ) {
|
||||
if ( entry->flags & kCCImplementsOtherMouseDragged ) {
|
||||
void *swallows = [entry->delegate performSelector:@selector(ccOtherMouseDragged:) withObject:event];
|
||||
if( swallows )
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)otherMouseUp:(NSEvent *)event
|
||||
{
|
||||
if( dispatchEvents_ ) {
|
||||
tListEntry *entry, *tmp;
|
||||
|
||||
DL_FOREACH_SAFE( mouseDelegates_, entry, tmp ) {
|
||||
if ( entry->flags & kCCImplementsOtherMouseUp ) {
|
||||
void *swallows = [entry->delegate performSelector:@selector(ccOtherMouseUp:) withObject:event];
|
||||
if( swallows )
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Scroll Wheel
|
||||
//
|
||||
- (void)scrollWheel:(NSEvent *)event
|
||||
{
|
||||
if( dispatchEvents_ ) {
|
||||
tListEntry *entry, *tmp;
|
||||
|
||||
DL_FOREACH_SAFE( mouseDelegates_, entry, tmp ) {
|
||||
if ( entry->flags & kCCImplementsScrollWheel ) {
|
||||
void *swallows = [entry->delegate performSelector:@selector(ccScrollWheel:) withObject:event];
|
||||
if( swallows )
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Mouse enter / exit
|
||||
- (void)mouseExited:(NSEvent *)event
|
||||
{
|
||||
if( dispatchEvents_ ) {
|
||||
tListEntry *entry, *tmp;
|
||||
|
||||
DL_FOREACH_SAFE( mouseDelegates_, entry, tmp ) {
|
||||
if ( entry->flags & kCCImplementsMouseEntered ) {
|
||||
void *swallows = [entry->delegate performSelector:@selector(ccMouseEntered:) withObject:event];
|
||||
if( swallows )
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)mouseEntered:(NSEvent *)event
|
||||
{
|
||||
if( dispatchEvents_ ) {
|
||||
tListEntry *entry, *tmp;
|
||||
|
||||
DL_FOREACH_SAFE( mouseDelegates_, entry, tmp ) {
|
||||
if ( entry->flags & kCCImplementsMouseExited) {
|
||||
void *swallows = [entry->delegate performSelector:@selector(ccMouseExited:) withObject:event];
|
||||
if( swallows )
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#pragma mark CCEventDispatcher - Keyboard events
|
||||
|
||||
// Keyboard events
|
||||
- (void)keyDown:(NSEvent *)event
|
||||
{
|
||||
if( dispatchEvents_ ) {
|
||||
tListEntry *entry, *tmp;
|
||||
|
||||
DL_FOREACH_SAFE( keyboardDelegates_, entry, tmp ) {
|
||||
if ( entry->flags & kCCImplementsKeyDown ) {
|
||||
void *swallows = [entry->delegate performSelector:@selector(ccKeyDown:) withObject:event];
|
||||
if( swallows )
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)keyUp:(NSEvent *)event
|
||||
{
|
||||
if( dispatchEvents_ ) {
|
||||
tListEntry *entry, *tmp;
|
||||
|
||||
DL_FOREACH_SAFE( keyboardDelegates_, entry, tmp ) {
|
||||
if ( entry->flags & kCCImplementsKeyUp ) {
|
||||
void *swallows = [entry->delegate performSelector:@selector(ccKeyUp:) withObject:event];
|
||||
if( swallows )
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)flagsChanged:(NSEvent *)event
|
||||
{
|
||||
if( dispatchEvents_ ) {
|
||||
tListEntry *entry, *tmp;
|
||||
|
||||
DL_FOREACH_SAFE( keyboardDelegates_, entry, tmp ) {
|
||||
if ( entry->flags & kCCImplementsKeyUp ) {
|
||||
void *swallows = [entry->delegate performSelector:@selector(ccFlagsChanged:) withObject:event];
|
||||
if( swallows )
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#pragma mark CCEventDispatcher - Touch events
|
||||
|
||||
- (void)touchesBeganWithEvent:(NSEvent *)event
|
||||
{
|
||||
if (dispatchEvents_ ) {
|
||||
NSLog(@"Touch Events: Not supported yet");
|
||||
}
|
||||
}
|
||||
|
||||
- (void)touchesMovedWithEvent:(NSEvent *)event
|
||||
{
|
||||
if (dispatchEvents_ ) {
|
||||
NSLog(@"Touch Events: Not supported yet");
|
||||
}
|
||||
}
|
||||
|
||||
- (void)touchesEndedWithEvent:(NSEvent *)event
|
||||
{
|
||||
if (dispatchEvents_ ) {
|
||||
NSLog(@"Touch Events: Not supported yet");
|
||||
}
|
||||
}
|
||||
|
||||
- (void)touchesCancelledWithEvent:(NSEvent *)event
|
||||
{
|
||||
if (dispatchEvents_ ) {
|
||||
NSLog(@"Touch Events: Not supported yet");
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark CCEventDispatcher - queue events
|
||||
|
||||
#if CC_DIRECTOR_MAC_USE_DISPLAY_LINK_THREAD
|
||||
-(void) queueEvent:(NSEvent*)event selector:(SEL)selector
|
||||
{
|
||||
NSAssert( eventQueueCount < QUEUE_EVENT_MAX, @"CCEventDispatcher: recompile. Increment QUEUE_EVENT_MAX value");
|
||||
|
||||
eventQueue[eventQueueCount].selector = selector;
|
||||
eventQueue[eventQueueCount].event = [event copy];
|
||||
|
||||
eventQueueCount++;
|
||||
}
|
||||
|
||||
-(void) dispatchQueuedEvents
|
||||
{
|
||||
for( int i=0; i < eventQueueCount; i++ ) {
|
||||
SEL sel = eventQueue[i].selector;
|
||||
NSEvent *event = eventQueue[i].event;
|
||||
|
||||
[self performSelector:sel withObject:event];
|
||||
|
||||
[event release];
|
||||
}
|
||||
|
||||
eventQueueCount = 0;
|
||||
}
|
||||
#endif // CC_DIRECTOR_MAC_USE_DISPLAY_LINK_THREAD
|
||||
|
||||
|
||||
@end
|
||||
|
||||
#endif // __MAC_OS_X_VERSION_MAX_ALLOWED
|
|
@ -1,613 +0,0 @@
|
|||
/****************************************************************************
|
||||
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 "ccMacros.h"
|
||||
#include "effects/CCGrid.h"
|
||||
#include "CCDirector.h"
|
||||
#include "effects/CCGrabber.h"
|
||||
#include "support/ccUtils.h"
|
||||
|
||||
#include "CCGL.h"
|
||||
#include "CGPointExtension.h"
|
||||
|
||||
namespace cocos2d
|
||||
{
|
||||
// implementation of CCGridBase
|
||||
|
||||
CCGridBase* CCGridBase::gridWithSize(cocos2d::ccGridSize gridSize)
|
||||
{
|
||||
CCGridBase *pGridBase = new CCGridBase();
|
||||
|
||||
if (pGridBase)
|
||||
{
|
||||
if (pGridBase->initWithSize(gridSize))
|
||||
{
|
||||
pGridBase->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
CCX_SAFE_RELEASE_NULL(pGridBase);
|
||||
}
|
||||
}
|
||||
|
||||
return pGridBase;
|
||||
}
|
||||
|
||||
CCGridBase* CCGridBase::gridWithSize(ccGridSize gridSize, CCTexture2D *texture, bool flipped)
|
||||
{
|
||||
CCGridBase *pGridBase = new CCGridBase();
|
||||
|
||||
if (pGridBase)
|
||||
{
|
||||
if (pGridBase->initWithSize(gridSize, texture, flipped))
|
||||
{
|
||||
pGridBase->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
CCX_SAFE_RELEASE_NULL(pGridBase);
|
||||
}
|
||||
}
|
||||
|
||||
return pGridBase;
|
||||
}
|
||||
|
||||
bool CCGridBase::initWithSize(ccGridSize gridSize, CCTexture2D *pTexture, bool bFlipped)
|
||||
{
|
||||
bool bRet = true;
|
||||
|
||||
m_bActive = false;
|
||||
m_nReuseGrid = 0;
|
||||
m_sGridSize = gridSize;
|
||||
|
||||
m_pTexture = pTexture;
|
||||
CCX_SAFE_RETAIN(m_pTexture);
|
||||
m_bIsTextureFlipped = bFlipped;
|
||||
|
||||
CGSize texSize = m_pTexture->getContentSizeInPixels();
|
||||
m_obStep.x = texSize.width / m_sGridSize.x;
|
||||
m_obStep.y = texSize.height / m_sGridSize.y;
|
||||
|
||||
m_pGrabber = new CCGrabber();
|
||||
if (m_pGrabber)
|
||||
{
|
||||
m_pGrabber->grab(m_pTexture);
|
||||
}
|
||||
else
|
||||
{
|
||||
bRet = false;
|
||||
}
|
||||
|
||||
|
||||
calculateVertexPoints();
|
||||
|
||||
return bRet;
|
||||
}
|
||||
|
||||
bool CCGridBase::initWithSize(ccGridSize gridSize)
|
||||
{
|
||||
CCDirector *pDirector = CCDirector::sharedDirector();
|
||||
CGSize s = pDirector->getWinSizeInPixels();
|
||||
|
||||
unsigned int POTWide = ccNextPOT((unsigned int)s.width);
|
||||
unsigned int POTHigh = ccNextPOT((unsigned int)s.height);
|
||||
|
||||
// on mac, it use kCCTexture2DPixelFormat_RGBA8888
|
||||
CCTexture2DPixelFormat format = kCCTexture2DPixelFormat_RGBA8888;
|
||||
|
||||
void *data = calloc((int)(POTWide * POTHigh * 4), 1);
|
||||
if (! data)
|
||||
{
|
||||
CCLOG("cocos2d: CCGrid: not enough memory.");
|
||||
this->release();
|
||||
return false;
|
||||
}
|
||||
|
||||
CCTexture2D *pTexture = new CCTexture2D();
|
||||
pTexture->initWithData(data, format, POTWide, POTHigh, s);
|
||||
|
||||
free(data);
|
||||
|
||||
if (! pTexture)
|
||||
{
|
||||
CCLOG("cocos2d: CCGrid: error creating texture");
|
||||
delete this;
|
||||
return false;
|
||||
}
|
||||
|
||||
initWithSize(gridSize, pTexture, false);
|
||||
|
||||
pTexture->release();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
CCGridBase::~CCGridBase(void)
|
||||
{
|
||||
CCLOGINFO("cocos2d: deallocing %p", this);
|
||||
|
||||
setActive(false);
|
||||
CCX_SAFE_RELEASE(m_pTexture);
|
||||
CCX_SAFE_RELEASE(m_pGrabber);
|
||||
}
|
||||
|
||||
// properties
|
||||
void CCGridBase::setActive(bool bActive)
|
||||
{
|
||||
m_bActive = bActive;
|
||||
if (! bActive)
|
||||
{
|
||||
CCDirector *pDirector = CCDirector::sharedDirector();
|
||||
ccDirectorProjection proj = pDirector->getProjection();
|
||||
pDirector->setProjection(proj);
|
||||
}
|
||||
}
|
||||
|
||||
void CCGridBase::setIsTextureFlipped(bool bFlipped)
|
||||
{
|
||||
if (m_bIsTextureFlipped != bFlipped)
|
||||
{
|
||||
m_bIsTextureFlipped = bFlipped;
|
||||
calculateVertexPoints();
|
||||
}
|
||||
}
|
||||
|
||||
// mac can not applay land space
|
||||
void CCGridBase::applyLandscape(void)
|
||||
{
|
||||
CCLOG("unsupported");
|
||||
}
|
||||
|
||||
void CCGridBase::set2DProjection()
|
||||
{
|
||||
CGSize winSize = CCDirector::sharedDirector()->getWinSizeInPixels();
|
||||
|
||||
glLoadIdentity();
|
||||
glViewport((GLsizei)0, (GLsizei)0, (GLsizei)winSize.width, (GLsizei)winSize.height);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
ccglOrtho(0, winSize.width, 0, winSize.height, -1024, 1024);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
// This routine can be merged with Director
|
||||
void CCGridBase::set3DProjection()
|
||||
{
|
||||
CGSize winSize = CCDirector::sharedDirector()->getDisplaySizeInPixels();
|
||||
|
||||
glViewport(0, 0, (GLsizei)winSize.width, (GLsizei)winSize.height);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
gluPerspective(60, (GLfloat)winSize.width/winSize.height, 0.5f, 1500.0f);
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
gluLookAt( winSize.width/2, winSize.height/2, CCDirector::sharedDirector()->getZEye(),
|
||||
winSize.width/2, winSize.height/2, 0,
|
||||
0.0f, 1.0f, 0.0f
|
||||
);
|
||||
}
|
||||
|
||||
void CCGridBase::beforeDraw(void)
|
||||
{
|
||||
set2DProjection();
|
||||
m_pGrabber->beforeRender(m_pTexture);
|
||||
}
|
||||
|
||||
void CCGridBase::afterDraw(cocos2d::CCNode *pTarget)
|
||||
{
|
||||
m_pGrabber->afterRender(m_pTexture);
|
||||
|
||||
set3DProjection();
|
||||
// mac can not applay land space
|
||||
//applyLandscape();
|
||||
|
||||
if (pTarget->getCamera()->getDirty())
|
||||
{
|
||||
CGPoint offset = pTarget->getAnchorPointInPixels();
|
||||
|
||||
//
|
||||
// XXX: Camera should be applied in the AnchorPoint
|
||||
//
|
||||
ccglTranslate(offset.x, offset.y, 0);
|
||||
pTarget->getCamera()->locate();
|
||||
ccglTranslate(-offset.x, -offset.y, 0);
|
||||
}
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, m_pTexture->getName());
|
||||
|
||||
blit();
|
||||
}
|
||||
|
||||
void CCGridBase::blit(void)
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
|
||||
void CCGridBase::reuse(void)
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
|
||||
void CCGridBase::calculateVertexPoints(void)
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
|
||||
// implementation of CCGrid3D
|
||||
|
||||
CCGrid3D* CCGrid3D::gridWithSize(ccGridSize gridSize, CCTexture2D *pTexture, bool bFlipped)
|
||||
{
|
||||
CCGrid3D *pRet= new CCGrid3D();
|
||||
|
||||
if (pRet)
|
||||
{
|
||||
if (pRet->initWithSize(gridSize, pTexture, bFlipped))
|
||||
{
|
||||
pRet->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
delete pRet;
|
||||
pRet = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return pRet;
|
||||
}
|
||||
|
||||
CCGrid3D* CCGrid3D::gridWithSize(ccGridSize gridSize)
|
||||
{
|
||||
CCGrid3D *pRet= new CCGrid3D();
|
||||
|
||||
if (pRet)
|
||||
{
|
||||
if (pRet->initWithSize(gridSize))
|
||||
{
|
||||
pRet->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
delete pRet;
|
||||
pRet = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return pRet;
|
||||
}
|
||||
|
||||
CCGrid3D::~CCGrid3D(void)
|
||||
{
|
||||
free(m_pTexCoordinates);
|
||||
free(m_pVertices);
|
||||
free(m_pIndices);
|
||||
free(m_pOriginalVertices);
|
||||
}
|
||||
|
||||
void CCGrid3D::blit(void)
|
||||
{
|
||||
int n = m_sGridSize.x * m_sGridSize.y;
|
||||
|
||||
// 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_TEXTURE_COORD_ARRAY
|
||||
// Unneeded states: GL_COLOR_ARRAY
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
glVertexPointer(3, GL_FLOAT, 0, m_pVertices);
|
||||
glTexCoordPointer(2, GL_FLOAT, 0, m_pTexCoordinates);
|
||||
glDrawElements(GL_TRIANGLES, n * 6, GL_UNSIGNED_SHORT, m_pIndices);
|
||||
|
||||
// restore GL default state
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
}
|
||||
|
||||
void CCGrid3D::calculateVertexPoints(void)
|
||||
{
|
||||
float width = (float)m_pTexture->getPixelsWide();
|
||||
float height = (float)m_pTexture->getPixelsHigh();
|
||||
float imageH = m_pTexture->getContentSizeInPixels().height;
|
||||
|
||||
int x, y, i;
|
||||
|
||||
m_pVertices = malloc((m_sGridSize.x+1) * (m_sGridSize.y+1) * sizeof(ccVertex3F));
|
||||
m_pOriginalVertices = malloc((m_sGridSize.x+1) * (m_sGridSize.y+1) * sizeof(ccVertex3F));
|
||||
m_pTexCoordinates = malloc((m_sGridSize.x+1) * (m_sGridSize.y+1) * sizeof(CGPoint));
|
||||
m_pIndices = (GLushort*)malloc(m_sGridSize.x * m_sGridSize.y * sizeof(GLushort) * 6);
|
||||
|
||||
float *vertArray = (float*)m_pVertices;
|
||||
float *texArray = (float*)m_pTexCoordinates;
|
||||
GLushort *idxArray = m_pIndices;
|
||||
|
||||
for (x = 0; x < m_sGridSize.x; ++x)
|
||||
{
|
||||
for (y = 0; y < m_sGridSize.y; ++y)
|
||||
{
|
||||
int idx = (y * m_sGridSize.x) + x;
|
||||
|
||||
float x1 = x * m_obStep.x;
|
||||
float x2 = x1 + m_obStep.x;
|
||||
float y1 = y * m_obStep.y;
|
||||
float y2= y1 + m_obStep.y;
|
||||
|
||||
GLushort a = x * (m_sGridSize.y + 1) + y;
|
||||
GLushort b = (x + 1) * (m_sGridSize.y + 1) + y;
|
||||
GLushort c = (x + 1) * (m_sGridSize.y + 1) + (y + 1);
|
||||
GLushort d = x * (m_sGridSize.y + 1) + (y + 1);
|
||||
|
||||
GLushort tempidx[6] = {a, b, d, b, c, d};
|
||||
|
||||
memcpy(&idxArray[6*idx], tempidx, 6*sizeof(GLushort));
|
||||
|
||||
int l1[4] = {a*3, b*3, c*3, d*3};
|
||||
ccVertex3F e = {x1, y1, 0};
|
||||
ccVertex3F f = {x2, y1, 0};
|
||||
ccVertex3F g = {x2, y2, 0};
|
||||
ccVertex3F h = {x1, y2, 0};
|
||||
|
||||
ccVertex3F l2[4] = {e, f, g, h};
|
||||
|
||||
int tex1[4] = {a*2, b*2, c*2, d*2};
|
||||
CGPoint tex2[4] = {ccp(x1, y1), ccp(x2, y1), ccp(x2, y2), ccp(x1, y2)};
|
||||
|
||||
for (i = 0; i < 4; ++i)
|
||||
{
|
||||
vertArray[l1[i]] = l2[i].x;
|
||||
vertArray[l1[i] + 1] = l2[i].y;
|
||||
vertArray[l1[i] + 2] = l2[i].z;
|
||||
|
||||
texArray[tex1[i]] = tex2[i].x / width;
|
||||
if (m_bIsTextureFlipped)
|
||||
{
|
||||
texArray[tex1[i] + 1] = (imageH - tex2[i].y) / height;
|
||||
}
|
||||
else
|
||||
{
|
||||
texArray[tex1[i] + 1] = tex2[i].y / height;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
memcpy(m_pOriginalVertices, m_pVertices, (m_sGridSize.x+1) * (m_sGridSize.y+1) * sizeof(ccVertex3F));
|
||||
}
|
||||
|
||||
ccVertex3F CCGrid3D::vertex(ccGridSize pos)
|
||||
{
|
||||
int index = (pos.x * (m_sGridSize.y+1) + pos.y) * 3;
|
||||
float *vertArray = (float*)m_pVertices;
|
||||
|
||||
ccVertex3F vert = {vertArray[index], vertArray[index+1], vertArray[index+2]};
|
||||
|
||||
return vert;
|
||||
}
|
||||
|
||||
ccVertex3F CCGrid3D::originalVertex(cocos2d::ccGridSize pos)
|
||||
{
|
||||
int index = (pos.x * (m_sGridSize.y+1) + pos.y) * 3;
|
||||
float *vertArray = (float*)m_pOriginalVertices;
|
||||
|
||||
ccVertex3F vert = {vertArray[index], vertArray[index+1], vertArray[index+2]};
|
||||
|
||||
return vert;
|
||||
}
|
||||
|
||||
void CCGrid3D::setVertex(ccGridSize pos, ccVertex3F vertex)
|
||||
{
|
||||
int index = (pos.x * (m_sGridSize.y + 1) + pos.y) * 3;
|
||||
float *vertArray = (float*)m_pVertices;
|
||||
vertArray[index] = vertex.x;
|
||||
vertArray[index+1] = vertex.y;
|
||||
vertArray[index+2] = vertex.z;
|
||||
}
|
||||
|
||||
void CCGrid3D::reuse(void)
|
||||
{
|
||||
if (m_nReuseGrid > 0)
|
||||
{
|
||||
memcpy(m_pOriginalVertices, m_pVertices, (m_sGridSize.x+1) * (m_sGridSize.y+1) * sizeof(ccVertex3F));
|
||||
--m_nReuseGrid;
|
||||
}
|
||||
}
|
||||
|
||||
// implementation of CCTiledGrid3D
|
||||
|
||||
CCTiledGrid3D::~CCTiledGrid3D(void)
|
||||
{
|
||||
free(m_pTexCoordinates);
|
||||
free(m_pVertices);
|
||||
free(m_pOriginalVertices);
|
||||
free(m_pIndices);
|
||||
}
|
||||
|
||||
CCTiledGrid3D* CCTiledGrid3D::gridWithSize(cocos2d::ccGridSize gridSize, cocos2d::CCTexture2D *pTexture, bool bFlipped)
|
||||
{
|
||||
CCTiledGrid3D *pRet= new CCTiledGrid3D();
|
||||
|
||||
if (pRet)
|
||||
{
|
||||
if (pRet->initWithSize(gridSize, pTexture, bFlipped))
|
||||
{
|
||||
pRet->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
delete pRet;
|
||||
pRet = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return pRet;
|
||||
}
|
||||
|
||||
CCTiledGrid3D* CCTiledGrid3D::gridWithSize(cocos2d::ccGridSize gridSize)
|
||||
{
|
||||
CCTiledGrid3D *pRet= new CCTiledGrid3D();
|
||||
|
||||
if (pRet)
|
||||
{
|
||||
if (pRet->initWithSize(gridSize))
|
||||
{
|
||||
pRet->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
delete pRet;
|
||||
pRet = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return pRet;
|
||||
}
|
||||
|
||||
void CCTiledGrid3D::blit(void)
|
||||
{
|
||||
int n = m_sGridSize.x * m_sGridSize.y;
|
||||
|
||||
// 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_TEXTURE_COORD_ARRAY
|
||||
// Unneeded states: GL_COLOR_ARRAY
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
glVertexPointer(3, GL_FLOAT, 0, m_pVertices);
|
||||
glTexCoordPointer(2, GL_FLOAT, 0, m_pTexCoordinates);
|
||||
glDrawElements(GL_TRIANGLES, n*6, GL_UNSIGNED_SHORT, m_pIndices);
|
||||
|
||||
// restore default GL state
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
}
|
||||
|
||||
void CCTiledGrid3D::calculateVertexPoints(void)
|
||||
{
|
||||
float width = (float)m_pTexture->getPixelsWide();
|
||||
float height = (float)m_pTexture->getPixelsHigh();
|
||||
float imageH = m_pTexture->getContentSizeInPixels().height;
|
||||
|
||||
int numQuads = m_sGridSize.x * m_sGridSize.y;
|
||||
|
||||
m_pVertices = malloc(numQuads * 12 * sizeof(GLfloat));
|
||||
m_pOriginalVertices = malloc(numQuads * 12 * sizeof(GLfloat));
|
||||
m_pTexCoordinates = malloc(numQuads * 8 * sizeof(GLfloat));
|
||||
m_pIndices = (GLushort *)malloc(numQuads * 6 * sizeof(GLushort));
|
||||
|
||||
float *vertArray = (float*)m_pVertices;
|
||||
float *texArray = (float*)m_pTexCoordinates;
|
||||
GLushort *idxArray = m_pIndices;
|
||||
|
||||
int x, y;
|
||||
|
||||
for( x = 0; x < m_sGridSize.x; x++ )
|
||||
{
|
||||
for( y = 0; y < m_sGridSize.y; y++ )
|
||||
{
|
||||
float x1 = x * m_obStep.x;
|
||||
float x2 = x1 + m_obStep.x;
|
||||
float y1 = y * m_obStep.y;
|
||||
float y2 = y1 + m_obStep.y;
|
||||
|
||||
*vertArray++ = x1;
|
||||
*vertArray++ = y1;
|
||||
*vertArray++ = 0;
|
||||
*vertArray++ = x2;
|
||||
*vertArray++ = y1;
|
||||
*vertArray++ = 0;
|
||||
*vertArray++ = x1;
|
||||
*vertArray++ = y2;
|
||||
*vertArray++ = 0;
|
||||
*vertArray++ = x2;
|
||||
*vertArray++ = y2;
|
||||
*vertArray++ = 0;
|
||||
|
||||
float newY1 = y1;
|
||||
float newY2 = y2;
|
||||
|
||||
if (m_bIsTextureFlipped)
|
||||
{
|
||||
newY1 = imageH - y1;
|
||||
newY2 = imageH - y2;
|
||||
}
|
||||
|
||||
*texArray++ = x1 / width;
|
||||
*texArray++ = newY1 / height;
|
||||
*texArray++ = x2 / width;
|
||||
*texArray++ = newY1 / height;
|
||||
*texArray++ = x1 / width;
|
||||
*texArray++ = newY2 / height;
|
||||
*texArray++ = x2 / width;
|
||||
*texArray++ = newY2 / height;
|
||||
}
|
||||
}
|
||||
|
||||
for (x = 0; x < numQuads; x++)
|
||||
{
|
||||
idxArray[x*6+0] = x * 4 + 0;
|
||||
idxArray[x*6+1] = x * 4 + 1;
|
||||
idxArray[x*6+2] = x * 4 + 2;
|
||||
|
||||
idxArray[x*6+3] = x * 4 + 1;
|
||||
idxArray[x*6+4] = x * 4 + 2;
|
||||
idxArray[x*6+5] = x * 4 + 3;
|
||||
}
|
||||
|
||||
memcpy(m_pOriginalVertices, m_pVertices, numQuads * 12 * sizeof(GLfloat));
|
||||
}
|
||||
|
||||
void CCTiledGrid3D::setTile(cocos2d::ccGridSize pos, cocos2d::ccQuad3 coords)
|
||||
{
|
||||
int idx = (m_sGridSize.y * pos.x + pos.y) * 4 * 3;
|
||||
float *vertArray = (float*)m_pVertices;
|
||||
memcpy(&vertArray[idx], &coords, sizeof(ccQuad3));
|
||||
}
|
||||
|
||||
ccQuad3 CCTiledGrid3D::originalTile(ccGridSize pos)
|
||||
{
|
||||
int idx = (m_sGridSize.y * pos.x + pos.y) * 4 * 3;
|
||||
float *vertArray = (float*)m_pOriginalVertices;
|
||||
|
||||
ccQuad3 ret;
|
||||
memcpy(&ret, &vertArray[idx], sizeof(ccQuad3));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
ccQuad3 CCTiledGrid3D::tile(cocos2d::ccGridSize pos)
|
||||
{
|
||||
int idx = (m_sGridSize.y * pos.x + pos.y) * 4 * 3;
|
||||
float *vertArray = (float*)m_pVertices;
|
||||
|
||||
ccQuad3 ret;
|
||||
memcpy(&ret, &vertArray[idx], sizeof(ccQuad3));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void CCTiledGrid3D::reuse(void)
|
||||
{
|
||||
if (m_nReuseGrid > 0)
|
||||
{
|
||||
int numQuads = m_sGridSize.x * m_sGridSize.y;
|
||||
|
||||
memcpy(m_pOriginalVertices, m_pVertices, numQuads * 12 * sizeof(GLfloat));
|
||||
--m_nReuseGrid;
|
||||
}
|
||||
}
|
||||
} // end of namespace cocos2d
|
|
@ -1,678 +0,0 @@
|
|||
/****************************************************************************
|
||||
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 "CCEventDispatcher.h"
|
||||
#include "CCKeypadDispatcher.h"
|
||||
#include "CCDirector.h"
|
||||
#include "CGPointExtension.h"
|
||||
namespace cocos2d {
|
||||
|
||||
// CCLayer
|
||||
CCLayer::CCLayer()
|
||||
:m_bIsTouchEnabled(false)
|
||||
,m_bIsAccelerometerEnabled(false)
|
||||
,m_bIsKeypadEnabled(false)
|
||||
,m_bIsMouseEnabled(false)
|
||||
,m_bIsKeyboardEnabled(false)
|
||||
{
|
||||
m_eTouchDelegateType = ccTouchDeletateAllBit;
|
||||
m_tAnchorPoint = ccp(0.5f, 0.5f);
|
||||
m_bIsRelativeAnchorPoint = false;
|
||||
}
|
||||
|
||||
CCLayer::~CCLayer()
|
||||
{
|
||||
}
|
||||
|
||||
bool CCLayer::init()
|
||||
{
|
||||
bool bRet = false;
|
||||
do
|
||||
{
|
||||
CCDirector * pDirector;
|
||||
CCX_BREAK_IF( ! (pDirector = CCDirector::sharedDirector()) );
|
||||
this->setContentSize(pDirector->getWinSize());
|
||||
// success
|
||||
bRet = true;
|
||||
} while (0);
|
||||
return bRet;
|
||||
}
|
||||
|
||||
CCLayer *CCLayer::node()
|
||||
{
|
||||
CCLayer *pRet = new CCLayer();
|
||||
if (pRet && pRet->init())
|
||||
{
|
||||
pRet->autorelease();
|
||||
return pRet;
|
||||
}
|
||||
else
|
||||
{
|
||||
CCX_SAFE_DELETE(pRet)
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/// Touch and Accelerometer related
|
||||
|
||||
void CCLayer::registerWithTouchDispatcher()
|
||||
{
|
||||
CCLOG("cocos2d: CCLayer: unsupported!");
|
||||
}
|
||||
|
||||
void CCLayer::destroy(void)
|
||||
{
|
||||
this->release();
|
||||
}
|
||||
|
||||
void CCLayer::keep(void)
|
||||
{
|
||||
this->retain();
|
||||
}
|
||||
|
||||
void CCLayer::AccelerometerDestroy(void)
|
||||
{
|
||||
this->release();
|
||||
}
|
||||
|
||||
void CCLayer::AccelerometerKeep(void)
|
||||
{
|
||||
this->retain();
|
||||
}
|
||||
|
||||
void CCLayer::KeypadDestroy()
|
||||
{
|
||||
this->release();
|
||||
}
|
||||
|
||||
void CCLayer::KeypadKeep()
|
||||
{
|
||||
this->retain();
|
||||
}
|
||||
|
||||
void CCLayer::KeyboardDestroy(void)
|
||||
{
|
||||
this->release();
|
||||
}
|
||||
|
||||
void CCLayer::KeyboardKeep(void)
|
||||
{
|
||||
this->retain();
|
||||
}
|
||||
|
||||
void CCLayer::MouseDestroy()
|
||||
{
|
||||
this->release();
|
||||
}
|
||||
|
||||
void CCLayer::MouseKeep()
|
||||
{
|
||||
this->retain();
|
||||
}
|
||||
|
||||
bool CCLayer::getIsMouseEnabled()
|
||||
{
|
||||
return m_bIsMouseEnabled;
|
||||
}
|
||||
|
||||
void CCLayer::setIsMouseEnabled(bool enabled)
|
||||
{
|
||||
if( m_bIsMouseEnabled != enabled )
|
||||
{
|
||||
m_bIsMouseEnabled = enabled;
|
||||
|
||||
if( m_bIsRunning )
|
||||
{
|
||||
if( enabled )
|
||||
{
|
||||
CCEventDispatcher::sharedDispatcher()->addMouseDelegate(this, mouseDelegatePriority());
|
||||
}
|
||||
else
|
||||
{
|
||||
CCEventDispatcher::sharedDispatcher()->removeMouseDelegate(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CCLayer::getIsKeyboardEnabled()
|
||||
{
|
||||
return m_bIsKeyboardEnabled;
|
||||
}
|
||||
|
||||
void CCLayer::setIsKeyboardEnabled(bool enabled)
|
||||
{
|
||||
if( m_bIsKeyboardEnabled != enabled )
|
||||
{
|
||||
m_bIsKeyboardEnabled = enabled;
|
||||
|
||||
if( m_bIsRunning )
|
||||
{
|
||||
if( enabled )
|
||||
{
|
||||
CCEventDispatcher::sharedDispatcher()->addKeyboardDelegate(this, keyboardDelegatePriority());
|
||||
}
|
||||
else
|
||||
{
|
||||
CCEventDispatcher::sharedDispatcher()->removeKeyboardDelegate(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// isTouchEnabled getter
|
||||
bool CCLayer::getIsTouchEnabled()
|
||||
{
|
||||
return m_bIsTouchEnabled;
|
||||
}
|
||||
/// isTouchEnabled setter
|
||||
void CCLayer::setIsTouchEnabled(bool enabled)
|
||||
{
|
||||
CCLOG("cocos2d: CCLayer: unsupported!");
|
||||
}
|
||||
|
||||
/// isAccelerometerEnabled getter
|
||||
bool CCLayer::getIsAccelerometerEnabled()
|
||||
{
|
||||
return m_bIsAccelerometerEnabled;
|
||||
}
|
||||
/// isAccelerometerEnabled setter
|
||||
void CCLayer::setIsAccelerometerEnabled(bool enabled)
|
||||
{
|
||||
CCLOG("cocos2d: CCLayer: unsupported!");
|
||||
}
|
||||
|
||||
/// isKeypadEnabled getter
|
||||
bool CCLayer::getIsKeypadEnabled()
|
||||
{
|
||||
return m_bIsKeypadEnabled;
|
||||
}
|
||||
/// isKeypadEnabled setter
|
||||
void CCLayer::setIsKeypadEnabled(bool enabled)
|
||||
{
|
||||
if (enabled != m_bIsKeypadEnabled)
|
||||
{
|
||||
m_bIsKeypadEnabled = enabled;
|
||||
|
||||
if (m_bIsRunning)
|
||||
{
|
||||
if (enabled)
|
||||
{
|
||||
CCKeypadDispatcher::sharedDispatcher()->addDelegate(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
CCKeypadDispatcher::sharedDispatcher()->removeDelegate(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Callbacks
|
||||
void CCLayer::onEnter()
|
||||
{
|
||||
if(m_bIsMouseEnabled)
|
||||
{
|
||||
CCEventDispatcher::sharedDispatcher()->addMouseDelegate(this, mouseDelegatePriority());
|
||||
}
|
||||
|
||||
if( m_bIsKeyboardEnabled)
|
||||
{
|
||||
CCEventDispatcher::sharedDispatcher()->addKeyboardDelegate(this, keyboardDelegatePriority());
|
||||
}
|
||||
|
||||
// then iterate over all the children
|
||||
CCNode::onEnter();
|
||||
|
||||
// add this layer to concern the kaypad msg
|
||||
if (m_bIsKeypadEnabled)
|
||||
{
|
||||
CCKeypadDispatcher::sharedDispatcher()->addDelegate(this);
|
||||
}
|
||||
}
|
||||
|
||||
void CCLayer::onExit()
|
||||
{
|
||||
if(m_bIsMouseEnabled)
|
||||
{
|
||||
CCEventDispatcher::sharedDispatcher()->removeMouseDelegate(this, mouseDelegatePriority());
|
||||
}
|
||||
|
||||
if( m_bIsKeyboardEnabled)
|
||||
{
|
||||
CCEventDispatcher::sharedDispatcher()->removeKeyboardDelegate(this, keyboardDelegatePriority());
|
||||
}
|
||||
|
||||
// remove this layer from the delegates who concern the kaypad msg
|
||||
if (m_bIsKeypadEnabled)
|
||||
{
|
||||
CCKeypadDispatcher::sharedDispatcher()->removeDelegate(this);
|
||||
}
|
||||
|
||||
CCNode::onExit();
|
||||
}
|
||||
|
||||
void CCLayer::onEnterTransitionDidFinish()
|
||||
{
|
||||
CCNode::onEnterTransitionDidFinish();
|
||||
}
|
||||
|
||||
bool CCLayer::ccTouchBegan(CCTouch *pTouch, UIEvent *pEvent)
|
||||
{
|
||||
CCLOG("cocos2d: CCLayer: unsupported!");
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// ColorLayer
|
||||
//
|
||||
CCLayerColor::CCLayerColor()
|
||||
{
|
||||
}
|
||||
CCLayerColor::~CCLayerColor()
|
||||
{
|
||||
}
|
||||
|
||||
// Opacity and RGB color protocol
|
||||
/// opacity getter
|
||||
GLubyte CCLayerColor::getOpacity()
|
||||
{
|
||||
return m_cOpacity;
|
||||
}
|
||||
/// opacity setter
|
||||
void CCLayerColor::setOpacity(GLubyte var)
|
||||
{
|
||||
m_cOpacity = var;
|
||||
updateColor();
|
||||
}
|
||||
|
||||
/// color getter
|
||||
ccColor3B CCLayerColor::getColor()
|
||||
{
|
||||
return m_tColor;
|
||||
}
|
||||
|
||||
/// color setter
|
||||
void CCLayerColor::setColor(ccColor3B var)
|
||||
{
|
||||
m_tColor = var;
|
||||
updateColor();
|
||||
}
|
||||
|
||||
|
||||
/// blendFunc getter
|
||||
ccBlendFunc CCLayerColor::getBlendFunc()
|
||||
{
|
||||
return m_tBlendFunc;
|
||||
}
|
||||
/// blendFunc setter
|
||||
void CCLayerColor::setBlendFunc(ccBlendFunc var)
|
||||
{
|
||||
m_tBlendFunc = var;
|
||||
}
|
||||
|
||||
|
||||
CCLayerColor * CCLayerColor::layerWithColorWidthHeight(ccColor4B color, GLfloat width, GLfloat height)
|
||||
{
|
||||
CCLayerColor * pLayer = new CCLayerColor();
|
||||
if( pLayer && pLayer->initWithColorWidthHeight(color,width,height))
|
||||
{
|
||||
pLayer->autorelease();
|
||||
return pLayer;
|
||||
}
|
||||
CCX_SAFE_DELETE(pLayer);
|
||||
return NULL;
|
||||
}
|
||||
CCLayerColor * CCLayerColor::layerWithColor(ccColor4B color)
|
||||
{
|
||||
CCLayerColor * pLayer = new CCLayerColor();
|
||||
if(pLayer && pLayer->initWithColor(color))
|
||||
{
|
||||
pLayer->autorelease();
|
||||
return pLayer;
|
||||
}
|
||||
CCX_SAFE_DELETE(pLayer);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool CCLayerColor::initWithColorWidthHeight(ccColor4B color, GLfloat width, GLfloat height)
|
||||
{
|
||||
// default blend function
|
||||
m_tBlendFunc.src = CC_BLEND_SRC;
|
||||
m_tBlendFunc.dst = CC_BLEND_DST;
|
||||
|
||||
m_tColor.r = color.r;
|
||||
m_tColor.g = color.g;
|
||||
m_tColor.b = color.b;
|
||||
m_cOpacity = color.a;
|
||||
|
||||
for (unsigned int i=0; i<sizeof(m_pSquareVertices) / sizeof(m_pSquareVertices[0]); i++ )
|
||||
{
|
||||
m_pSquareVertices[i] = 0.0f;
|
||||
}
|
||||
|
||||
this->updateColor();
|
||||
this->setContentSize(CGSizeMake(width,height));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CCLayerColor::initWithColor(ccColor4B color)
|
||||
{
|
||||
CGSize s = CCDirector::sharedDirector()->getWinSize();
|
||||
this->initWithColorWidthHeight(color, s.width, s.height);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// override contentSize
|
||||
void CCLayerColor::setContentSize(CGSize size)
|
||||
{
|
||||
m_pSquareVertices[2] = size.width * CC_CONTENT_SCALE_FACTOR();
|
||||
m_pSquareVertices[5] = size.height * CC_CONTENT_SCALE_FACTOR();
|
||||
m_pSquareVertices[6] = size.width * CC_CONTENT_SCALE_FACTOR();
|
||||
m_pSquareVertices[7] = size.height * CC_CONTENT_SCALE_FACTOR();
|
||||
|
||||
CCLayer::setContentSize(size);
|
||||
}
|
||||
|
||||
void CCLayerColor::changeWidthAndHeight(GLfloat w ,GLfloat h)
|
||||
{
|
||||
this->setContentSize(CGSizeMake(w, h));
|
||||
}
|
||||
|
||||
void CCLayerColor::changeWidth(GLfloat w)
|
||||
{
|
||||
this->setContentSize(CGSizeMake(w, m_tContentSize.height));
|
||||
}
|
||||
|
||||
void CCLayerColor::changeHeight(GLfloat h)
|
||||
{
|
||||
this->setContentSize(CGSizeMake(m_tContentSize.width, h));
|
||||
}
|
||||
|
||||
void CCLayerColor::updateColor()
|
||||
{
|
||||
for( unsigned int i=0; i < 4; i++ )
|
||||
{
|
||||
m_pSquareColors[i * 4] = m_tColor.r;
|
||||
m_pSquareColors[i * 4 + 1] = m_tColor.g;
|
||||
m_pSquareColors[i * 4 + 2] = m_tColor.b;
|
||||
m_pSquareColors[i * 4 + 3] = m_cOpacity;
|
||||
}
|
||||
}
|
||||
|
||||
void CCLayerColor::draw()
|
||||
{
|
||||
// Default GL states: GL_TEXTURE_2D, GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY
|
||||
// Needed states: GL_VERTEX_ARRAY, GL_COLOR_ARRAY
|
||||
// Unneeded states: GL_TEXTURE_2D, GL_TEXTURE_COORD_ARRAY
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
|
||||
glVertexPointer(2, GL_FLOAT, 0, m_pSquareVertices);
|
||||
glColorPointer(4, GL_UNSIGNED_BYTE, 0, m_pSquareColors);
|
||||
|
||||
bool newBlend = false;
|
||||
if( m_tBlendFunc.src != CC_BLEND_SRC || m_tBlendFunc.dst != CC_BLEND_DST ) {
|
||||
newBlend = true;
|
||||
glBlendFunc(m_tBlendFunc.src, m_tBlendFunc.dst);
|
||||
}
|
||||
else if( m_cOpacity != 255 ) {
|
||||
newBlend = true;
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
|
||||
if( newBlend )
|
||||
glBlendFunc(CC_BLEND_SRC, CC_BLEND_DST);
|
||||
|
||||
// restore default GL state
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
//
|
||||
// CCLayerGradient
|
||||
//
|
||||
CCLayerGradient* CCLayerGradient::layerWithColor(ccColor4B start, ccColor4B end)
|
||||
{
|
||||
CCLayerGradient * pLayer = new CCLayerGradient();
|
||||
if( pLayer && pLayer->initWithColor(start, end))
|
||||
{
|
||||
pLayer->autorelease();
|
||||
return pLayer;
|
||||
}
|
||||
CCX_SAFE_DELETE(pLayer);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CCLayerGradient* CCLayerGradient::layerWithColor(ccColor4B start, ccColor4B end, CGPoint v)
|
||||
{
|
||||
CCLayerGradient * pLayer = new CCLayerGradient();
|
||||
if( pLayer && pLayer->initWithColor(start, end, v))
|
||||
{
|
||||
pLayer->autorelease();
|
||||
return pLayer;
|
||||
}
|
||||
CCX_SAFE_DELETE(pLayer);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool CCLayerGradient::initWithColor(ccColor4B start, ccColor4B end)
|
||||
{
|
||||
return initWithColor(start, end, ccp(0, -1));
|
||||
}
|
||||
|
||||
bool CCLayerGradient::initWithColor(ccColor4B start, ccColor4B end, CGPoint v)
|
||||
{
|
||||
m_endColor.r = end.r;
|
||||
m_endColor.g = end.g;
|
||||
m_endColor.b = end.b;
|
||||
|
||||
m_cEndOpacity = end.a;
|
||||
m_cStartOpacity = start.a;
|
||||
m_AlongVector = v;
|
||||
|
||||
start.a = 255;
|
||||
return CCLayerColor::initWithColor(start);
|
||||
}
|
||||
|
||||
void CCLayerGradient::updateColor()
|
||||
{
|
||||
CCLayerColor::updateColor();
|
||||
|
||||
float h = sqrtf(m_AlongVector.x * m_AlongVector.x + m_AlongVector.y * m_AlongVector.y);
|
||||
if (h == 0)
|
||||
return;
|
||||
|
||||
double c = sqrt(2.0);
|
||||
CGPoint u = ccp(m_AlongVector.x / h, m_AlongVector.y / h);
|
||||
|
||||
float opacityf = (float)m_cOpacity / 255.0f;
|
||||
|
||||
ccColor4B S = {
|
||||
(unsigned char) m_tColor.r,
|
||||
(unsigned char) m_tColor.g,
|
||||
(unsigned char) m_tColor.b,
|
||||
(unsigned char) (m_cStartOpacity * opacityf)
|
||||
};
|
||||
|
||||
ccColor4B E = {
|
||||
(unsigned char) m_endColor.r,
|
||||
(unsigned char) m_endColor.g,
|
||||
(unsigned char) m_endColor.b,
|
||||
(unsigned char) (m_cEndOpacity * opacityf)
|
||||
};
|
||||
|
||||
// (-1, -1)
|
||||
m_pSquareColors[0] = (GLubyte) (E.r + (S.r - E.r) * ((c + u.x + u.y) / (2.0f * c)));
|
||||
m_pSquareColors[1] = (GLubyte) (E.g + (S.g - E.g) * ((c + u.x + u.y) / (2.0f * c)));
|
||||
m_pSquareColors[2] = (GLubyte) (E.b + (S.b - E.b) * ((c + u.x + u.y) / (2.0f * c)));
|
||||
m_pSquareColors[3] = (GLubyte) (E.a + (S.a - E.a) * ((c + u.x + u.y) / (2.0f * c)));
|
||||
// (1, -1)
|
||||
m_pSquareColors[4] = (GLubyte) (E.r + (S.r - E.r) * ((c - u.x + u.y) / (2.0f * c)));
|
||||
m_pSquareColors[5] = (GLubyte) (E.g + (S.g - E.g) * ((c - u.x + u.y) / (2.0f * c)));
|
||||
m_pSquareColors[6] = (GLubyte) (E.b + (S.b - E.b) * ((c - u.x + u.y) / (2.0f * c)));
|
||||
m_pSquareColors[7] = (GLubyte) (E.a + (S.a - E.a) * ((c - u.x + u.y) / (2.0f * c)));
|
||||
// (-1, 1)
|
||||
m_pSquareColors[8] = (GLubyte) (E.r + (S.r - E.r) * ((c + u.x - u.y) / (2.0f * c)));
|
||||
m_pSquareColors[9] = (GLubyte) (E.g + (S.g - E.g) * ((c + u.x - u.y) / (2.0f * c)));
|
||||
m_pSquareColors[10] = (GLubyte) (E.b + (S.b - E.b) * ((c + u.x - u.y) / (2.0f * c)));
|
||||
m_pSquareColors[11] = (GLubyte) (E.a + (S.a - E.a) * ((c + u.x - u.y) / (2.0f * c)));
|
||||
// (1, 1)
|
||||
m_pSquareColors[12] = (GLubyte) (E.r + (S.r - E.r) * ((c - u.x - u.y) / (2.0f * c)));
|
||||
m_pSquareColors[13] = (GLubyte) (E.g + (S.g - E.g) * ((c - u.x - u.y) / (2.0f * c)));
|
||||
m_pSquareColors[14] = (GLubyte) (E.b + (S.b - E.b) * ((c - u.x - u.y) / (2.0f * c)));
|
||||
m_pSquareColors[15] = (GLubyte) (E.a + (S.a - E.a) * ((c - u.x - u.y) / (2.0f * c)));
|
||||
}
|
||||
|
||||
ccColor3B CCLayerGradient::getStartColor()
|
||||
{
|
||||
return m_tColor;
|
||||
}
|
||||
|
||||
void CCLayerGradient::setStartColor(ccColor3B colors)
|
||||
{
|
||||
setColor(colors);
|
||||
}
|
||||
|
||||
void CCLayerGradient::setEndColor(ccColor3B colors)
|
||||
{
|
||||
m_endColor = colors;
|
||||
updateColor();
|
||||
}
|
||||
|
||||
ccColor3B CCLayerGradient::getEndColor()
|
||||
{
|
||||
return m_endColor;
|
||||
}
|
||||
|
||||
void CCLayerGradient::setStartOpacity(GLubyte o)
|
||||
{
|
||||
m_cStartOpacity = o;
|
||||
updateColor();
|
||||
}
|
||||
|
||||
GLubyte CCLayerGradient::getStartOpacity()
|
||||
{
|
||||
return m_cStartOpacity;
|
||||
}
|
||||
|
||||
void CCLayerGradient::setEndOpacity(GLubyte o)
|
||||
{
|
||||
m_cEndOpacity = o;
|
||||
updateColor();
|
||||
}
|
||||
|
||||
GLubyte CCLayerGradient::getEndOpacity()
|
||||
{
|
||||
return m_cEndOpacity;
|
||||
}
|
||||
|
||||
void CCLayerGradient::setAlongVector(CGPoint var)
|
||||
{
|
||||
m_AlongVector = var;
|
||||
updateColor();
|
||||
}
|
||||
|
||||
CGPoint CCLayerGradient::getAlongVector()
|
||||
{
|
||||
return m_AlongVector;
|
||||
}
|
||||
|
||||
/// MultiplexLayer
|
||||
|
||||
CCMultiplexLayer::CCMultiplexLayer()
|
||||
{
|
||||
}
|
||||
CCMultiplexLayer::~CCMultiplexLayer()
|
||||
{
|
||||
m_pLayers->release();
|
||||
}
|
||||
|
||||
CCMultiplexLayer * CCMultiplexLayer::layerWithLayers(CCLayer * layer, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args,layer);
|
||||
|
||||
CCMultiplexLayer * pMultiplexLayer = new CCMultiplexLayer();
|
||||
if(pMultiplexLayer && pMultiplexLayer->initWithLayers(layer, args))
|
||||
{
|
||||
pMultiplexLayer->autorelease();
|
||||
va_end(args);
|
||||
return pMultiplexLayer;
|
||||
}
|
||||
va_end(args);
|
||||
CCX_SAFE_DELETE(pMultiplexLayer);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool CCMultiplexLayer::initWithLayers(CCLayer *layer, va_list params)
|
||||
{
|
||||
m_pLayers = new NSMutableArray<CCLayer*>(5);
|
||||
//m_pLayers->retain();
|
||||
|
||||
m_pLayers->addObject(layer);
|
||||
|
||||
CCLayer *l = va_arg(params,CCLayer*);
|
||||
while( l ) {
|
||||
m_pLayers->addObject(l);
|
||||
l = va_arg(params,CCLayer*);
|
||||
}
|
||||
|
||||
m_nEnabledLayer = 0;
|
||||
this->addChild(m_pLayers->getObjectAtIndex(m_nEnabledLayer));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void CCMultiplexLayer::switchTo(unsigned int n)
|
||||
{
|
||||
NSAssert( n < m_pLayers->count(), "Invalid index in MultiplexLayer switchTo message" );
|
||||
|
||||
this->removeChild(m_pLayers->getObjectAtIndex(m_nEnabledLayer), true);
|
||||
|
||||
m_nEnabledLayer = n;
|
||||
|
||||
this->addChild(m_pLayers->getObjectAtIndex(n));
|
||||
}
|
||||
|
||||
void CCMultiplexLayer::switchToAndReleaseMe(unsigned int n)
|
||||
{
|
||||
NSAssert( n < m_pLayers->count(), "Invalid index in MultiplexLayer switchTo message" );
|
||||
|
||||
this->removeChild(m_pLayers->getObjectAtIndex(m_nEnabledLayer), true);
|
||||
|
||||
//[layers replaceObjectAtIndex:enabledLayer withObject:[NSNull null]];
|
||||
m_pLayers->replaceObjectAtIndex(m_nEnabledLayer, NULL);
|
||||
|
||||
m_nEnabledLayer = n;
|
||||
|
||||
this->addChild(m_pLayers->getObjectAtIndex(n));
|
||||
}
|
||||
}//namespace cocos2d
|
|
@ -1,627 +0,0 @@
|
|||
/****************************************************************************
|
||||
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 "CCMenu.h"
|
||||
#include "CCDirector.h"
|
||||
#include "CCXApplication.h"
|
||||
#include "CGPointExtension.h"
|
||||
#include "CCTouchDispatcher.h"
|
||||
#include "CCTouch.h"
|
||||
#include "platform/CCXMath.h"
|
||||
|
||||
#include <vector>
|
||||
#include <float.h>
|
||||
using namespace std;
|
||||
|
||||
namespace cocos2d{
|
||||
|
||||
enum
|
||||
{
|
||||
kDefaultPadding = 5,
|
||||
};
|
||||
|
||||
//
|
||||
//CCMenu
|
||||
//
|
||||
CCMenu * CCMenu::menuWithItems(CCMenuItem* item, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args,item);
|
||||
CCMenu *pRet = new CCMenu();
|
||||
if (pRet && pRet->initWithItems(item, args))
|
||||
{
|
||||
pRet->autorelease();
|
||||
va_end(args);
|
||||
return pRet;
|
||||
}
|
||||
va_end(args);
|
||||
CCX_SAFE_DELETE(pRet)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool CCMenu::initWithItems(CCMenuItem* item, va_list args)
|
||||
{
|
||||
if (CCLayer::init())
|
||||
{
|
||||
this->m_bIsMouseEnabled = true;
|
||||
|
||||
// menu in the center of the screen
|
||||
CGSize s = CCDirector::sharedDirector()->getWinSize();
|
||||
|
||||
this->m_bIsRelativeAnchorPoint = false;
|
||||
m_tAnchorPoint = ccp(0.5f, 0.5f);
|
||||
this->setContentSize(s);
|
||||
|
||||
// XXX: in v0.7, winSize should return the visible size
|
||||
// XXX: so the bar calculation should be done there
|
||||
setPosition(ccp(s.width/2, s.height/2));
|
||||
|
||||
int z=0;
|
||||
|
||||
if (item)
|
||||
{
|
||||
this->addChild(item, z);
|
||||
CCMenuItem *i = va_arg(args, CCMenuItem*);
|
||||
while (i)
|
||||
{
|
||||
z++;
|
||||
this->addChild(i, z);
|
||||
i = va_arg(args, CCMenuItem*);
|
||||
}
|
||||
}
|
||||
// [self alignItemsVertically];
|
||||
|
||||
m_pSelectedItem = NULL;
|
||||
m_eState = kCCMenuStateWaiting;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* override add:
|
||||
*/
|
||||
CCNode * CCMenu::addChild(CCNode * child, int zOrder)
|
||||
{
|
||||
return CCLayer::addChild(child, zOrder);
|
||||
}
|
||||
|
||||
CCNode * CCMenu::addChild(CCNode * child, int zOrder, int tag)
|
||||
{
|
||||
// we can not use RTTI, so we do not known the type of object
|
||||
/*NSAssert( dynamic_cast<CCMenuItem*>(child) != NULL, L"Menu only supports MenuItem objects as children");*/
|
||||
return CCLayer::addChild(child, zOrder, tag);
|
||||
}
|
||||
|
||||
void CCMenu::onExit()
|
||||
{
|
||||
if (m_eState == kCCMenuStateTrackingTouch)
|
||||
{
|
||||
m_pSelectedItem->unselected();
|
||||
m_eState = kCCMenuStateWaiting;
|
||||
m_pSelectedItem = NULL;
|
||||
}
|
||||
|
||||
CCLayer::onExit();
|
||||
}
|
||||
|
||||
void CCMenu::registerWithTouchDispatcher()
|
||||
{
|
||||
CCLOG("cocos2d: CCMenu: unsupported");
|
||||
}
|
||||
|
||||
CCMenuItem* CCMenu::itemForTouch(CCTouch * touch)
|
||||
{
|
||||
CCLOG("cocos2d: CCMenu: unsupported");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool CCMenu::ccTouchBegan(CCTouch* touch, UIEvent* event)
|
||||
{
|
||||
CCLOG("cocos2d: CCMenu: unsupported");
|
||||
return false;
|
||||
}
|
||||
|
||||
void CCMenu::ccTouchEnded(CCTouch* touch, UIEvent* event)
|
||||
{
|
||||
CCLOG("cocos2d: CCMenu: unsupported");
|
||||
}
|
||||
|
||||
void CCMenu::ccTouchCancelled(CCTouch *touch, UIEvent* event)
|
||||
{
|
||||
CCLOG("cocos2d: CCMenu: unsupported");
|
||||
}
|
||||
|
||||
void CCMenu::ccTouchMoved(CCTouch* touch, UIEvent* event)
|
||||
{
|
||||
CCLOG("cocos2d: CCMenu: unsupported");
|
||||
}
|
||||
|
||||
//Menu - Events
|
||||
int CCMenu::mouseDelegatePriority()
|
||||
{
|
||||
return -1;/** @todo upto-0.99.5 use NSIntegerMin+1 instead*/
|
||||
}
|
||||
|
||||
CCMenuItem* CCMenu::itemForMouseEvent(NSEvent * pEvent)
|
||||
{
|
||||
CGPoint touchLocation = CCDirector::sharedDirector()->convertEventToGL(pEvent);
|
||||
|
||||
if (m_pChildren && m_pChildren->count() > 0)
|
||||
{
|
||||
NSMutableArray<CCNode*>::NSMutableArrayIterator it;
|
||||
for (it = m_pChildren->begin(); it != m_pChildren->end(); ++it)
|
||||
{
|
||||
if (! *it)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if ((*it)->getIsVisible() && ((CCMenuItem*)(*it))->getIsEnabled())
|
||||
{
|
||||
CGPoint local = (*it)->convertToNodeSpace(touchLocation);
|
||||
|
||||
CGRect r = ((CCMenuItem*)(*it))->rect();
|
||||
r.origin = CGPointZero;
|
||||
|
||||
if (CGRect::CGRectContainsPoint(r, local))
|
||||
{
|
||||
return (CCMenuItem*)(*it);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool CCMenu::ccMouseUp(NSEvent * pEvent)
|
||||
{
|
||||
if (m_pSelectedItem)
|
||||
{
|
||||
m_pSelectedItem->unselected();
|
||||
m_pSelectedItem->activate();
|
||||
|
||||
m_eState = kCCMenuStateWaiting;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CCMenu::ccMouseDown(NSEvent * pEvent)
|
||||
{
|
||||
if (! getIsVisible())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
m_pSelectedItem = itemForMouseEvent(pEvent);
|
||||
m_pSelectedItem->selected();
|
||||
|
||||
if (m_pSelectedItem)
|
||||
{
|
||||
m_eState = kCCMenuStateTrackingTouch;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CCMenu::ccMouseDragged(NSEvent * pEvent)
|
||||
{
|
||||
CCMenuItem* currentItem = itemForMouseEvent(pEvent);
|
||||
|
||||
if (currentItem && currentItem != m_pSelectedItem)
|
||||
{
|
||||
if (m_pSelectedItem)
|
||||
{
|
||||
m_pSelectedItem->unselected();
|
||||
}
|
||||
|
||||
m_pSelectedItem = currentItem;
|
||||
m_pSelectedItem->selected();
|
||||
}
|
||||
|
||||
if (currentItem && m_eState == kCCMenuStateTrackingTouch)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void CCMenu::destroy(void)
|
||||
{
|
||||
release();
|
||||
}
|
||||
|
||||
void CCMenu::keep(void)
|
||||
{
|
||||
retain();
|
||||
}
|
||||
|
||||
//Menu - Alignment
|
||||
void CCMenu::alignItemsVertically()
|
||||
{
|
||||
return this->alignItemsVerticallyWithPadding(kDefaultPadding);
|
||||
}
|
||||
|
||||
void CCMenu::alignItemsVerticallyWithPadding(float padding)
|
||||
{
|
||||
float height = -padding;
|
||||
if (m_pChildren && m_pChildren->count() > 0)
|
||||
{
|
||||
NSMutableArray<CCNode*>::NSMutableArrayIterator it;
|
||||
for (it = m_pChildren->begin(); it != m_pChildren->end(); ++it)
|
||||
{
|
||||
if (!(*it))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
height += (*it)->getContentSize().height * (*it)->getScaleY() + padding;
|
||||
}
|
||||
}
|
||||
|
||||
float y = height / 2.0f;
|
||||
if (m_pChildren && m_pChildren->count() > 0)
|
||||
{
|
||||
NSMutableArray<CCNode*>::NSMutableArrayIterator it;
|
||||
for (it = m_pChildren->begin(); it != m_pChildren->end(); ++it)
|
||||
{
|
||||
if (!(*it))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
(*it)->setPosition(ccp(0, y - (*it)->getContentSize().height * (*it)->getScaleY() / 2.0f));
|
||||
y -= (*it)->getContentSize().height * (*it)->getScaleY() + padding;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CCMenu::alignItemsHorizontally(void)
|
||||
{
|
||||
return this->alignItemsHorizontallyWithPadding(kDefaultPadding);
|
||||
}
|
||||
|
||||
void CCMenu::alignItemsHorizontallyWithPadding(float padding)
|
||||
{
|
||||
|
||||
float width = -padding;
|
||||
if (m_pChildren && m_pChildren->count() > 0)
|
||||
{
|
||||
NSMutableArray<CCNode*>::NSMutableArrayIterator it;
|
||||
for (it = m_pChildren->begin(); it != m_pChildren->end(); ++it)
|
||||
{
|
||||
if (!(*it))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
width += (*it)->getContentSize().width * (*it)->getScaleX() + padding;
|
||||
}
|
||||
}
|
||||
|
||||
float x = -width / 2.0f;
|
||||
if (m_pChildren && m_pChildren->count() > 0)
|
||||
{
|
||||
NSMutableArray<CCNode*>::NSMutableArrayIterator it;
|
||||
for (it = m_pChildren->begin(); it != m_pChildren->end(); ++it)
|
||||
{
|
||||
if (!(*it))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
(*it)->setPosition(ccp(x + (*it)->getContentSize().width * (*it)->getScaleX() / 2.0f, 0));
|
||||
x += (*it)->getContentSize().width * (*it)->getScaleX() + padding;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CCMenu::alignItemsInColumns(unsigned int columns, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, columns);
|
||||
|
||||
this->alignItemsInColumns(columns, args);
|
||||
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void CCMenu::alignItemsInColumns(unsigned int columns, va_list args)
|
||||
{
|
||||
vector<unsigned int> rows;
|
||||
while (columns)
|
||||
{
|
||||
rows.push_back(columns);
|
||||
columns = va_arg(args, unsigned int);
|
||||
}
|
||||
|
||||
int height = -5;
|
||||
unsigned int row = 0;
|
||||
unsigned int rowHeight = 0;
|
||||
unsigned int columnsOccupied = 0;
|
||||
unsigned int rowColumns;
|
||||
|
||||
if (m_pChildren && m_pChildren->count() > 0)
|
||||
{
|
||||
NSMutableArray<CCNode*>::NSMutableArrayIterator it;
|
||||
for (it = m_pChildren->begin(); it != m_pChildren->end(); ++it)
|
||||
{
|
||||
// if it has no value, break
|
||||
if (! *it)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
assert(row < rows.size());
|
||||
|
||||
rowColumns = rows[row];
|
||||
// can not have zero columns on a row
|
||||
assert(rowColumns);
|
||||
|
||||
float tmp = (*it)->getContentSize().height;
|
||||
rowHeight = (unsigned int)((rowHeight >= tmp || CCXMath::isnanCocos2d(tmp)) ? rowHeight : tmp);
|
||||
|
||||
++columnsOccupied;
|
||||
if (columnsOccupied >= rowColumns)
|
||||
{
|
||||
height += rowHeight + 5;
|
||||
|
||||
columnsOccupied = 0;
|
||||
rowHeight = 0;
|
||||
++row;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// check if too many rows/columns for available menu items
|
||||
assert(! columnsOccupied);
|
||||
|
||||
CGSize winSize = CCDirector::sharedDirector()->getWinSize();
|
||||
|
||||
row = 0;
|
||||
rowHeight = 0;
|
||||
rowColumns = 0;
|
||||
float w;
|
||||
float x;
|
||||
float y = (float)(height / 2);
|
||||
|
||||
if (m_pChildren && m_pChildren->count() > 0)
|
||||
{
|
||||
NSMutableArray<CCNode*>::NSMutableArrayIterator it;
|
||||
for (it = m_pChildren->begin(); it != m_pChildren->end(); ++it)
|
||||
{
|
||||
if (! *it)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (rowColumns == 0)
|
||||
{
|
||||
rowColumns = rows[row];
|
||||
w = winSize.width / (1 + rowColumns);
|
||||
x = w;
|
||||
}
|
||||
|
||||
float tmp = (*it)->getContentSize().height;
|
||||
rowHeight = (unsigned int)((rowHeight >= tmp || CCXMath::isnanCocos2d(tmp)) ? rowHeight : tmp);
|
||||
|
||||
(*it)->setPosition(ccp(x - winSize.width / 2,
|
||||
y - (*it)->getContentSize().height / 2));
|
||||
|
||||
x += w + 10;
|
||||
++columnsOccupied;
|
||||
|
||||
if (columnsOccupied >= rowColumns)
|
||||
{
|
||||
y -= rowHeight + 5;
|
||||
|
||||
columnsOccupied = 0;
|
||||
rowColumns = 0;
|
||||
rowHeight = 0;
|
||||
++row;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CCMenu::alignItemsInRows(unsigned int rows, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, rows);
|
||||
|
||||
this->alignItemsInColumns(rows, args);
|
||||
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void CCMenu::alignItemsInRows(unsigned int rows, va_list args)
|
||||
{
|
||||
vector<unsigned int> columns;
|
||||
while (rows)
|
||||
{
|
||||
columns.push_back(rows);
|
||||
rows = va_arg(args, unsigned int);
|
||||
}
|
||||
|
||||
vector<unsigned int> columnWidths;
|
||||
vector<unsigned int> columnHeights;
|
||||
|
||||
int width = -10;
|
||||
int columnHeight = -5;
|
||||
unsigned int column = 0;
|
||||
unsigned int columnWidth = 0;
|
||||
unsigned int rowsOccupied = 0;
|
||||
unsigned int columnRows;
|
||||
|
||||
if (m_pChildren && m_pChildren->count() > 0)
|
||||
{
|
||||
NSMutableArray<CCNode*>::NSMutableArrayIterator it;
|
||||
for (it = m_pChildren->begin(); it != m_pChildren->end(); ++it)
|
||||
{
|
||||
if (! *it)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
// check if too many menu items for the amount of rows/columns
|
||||
assert(column < columns.size());
|
||||
|
||||
columnRows = columns[column];
|
||||
// can't have zero rows on a column
|
||||
assert(columnRows);
|
||||
|
||||
// columnWidth = fmaxf(columnWidth, [item contentSize].width);
|
||||
float tmp = (*it)->getContentSize().width;
|
||||
columnWidth = (unsigned int)((columnWidth >= tmp || CCXMath::isnanCocos2d(tmp)) ? columnWidth : tmp);
|
||||
|
||||
columnHeight += (int)((*it)->getContentSize().height + 5);
|
||||
++rowsOccupied;
|
||||
|
||||
if (rowsOccupied >= columnRows)
|
||||
{
|
||||
columnWidths.push_back(columnWidth);
|
||||
columnHeights.push_back(columnHeight);
|
||||
width += columnWidth + 10;
|
||||
|
||||
rowsOccupied = 0;
|
||||
columnWidth = 0;
|
||||
columnHeight = -5;
|
||||
++column;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// check if too many rows/columns for available menu items.
|
||||
assert(! rowsOccupied);
|
||||
|
||||
CGSize winSize = CCDirector::sharedDirector()->getWinSize();
|
||||
|
||||
column = 0;
|
||||
columnWidth = 0;
|
||||
columnRows = 0;
|
||||
float x = (float)(-width / 2);
|
||||
float y;
|
||||
|
||||
if (m_pChildren && m_pChildren->count() > 0)
|
||||
{
|
||||
NSMutableArray<CCNode*>::NSMutableArrayIterator it;
|
||||
for (it = m_pChildren->begin(); it != m_pChildren->end(); ++it)
|
||||
{
|
||||
if (! *it)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (columnRows == 0)
|
||||
{
|
||||
columnRows = columns[column];
|
||||
y = (float) columnHeights[column];
|
||||
}
|
||||
|
||||
// columnWidth = fmaxf(columnWidth, [item contentSize].width);
|
||||
float tmp = (*it)->getContentSize().width;
|
||||
columnWidth = (unsigned int)((columnWidth >= tmp || CCXMath::isnanCocos2d(tmp)) ? columnWidth : tmp);
|
||||
|
||||
(*it)->setPosition(ccp(x + columnWidths[column] / 2,
|
||||
y - winSize.height / 2));
|
||||
|
||||
y -= (*it)->getContentSize().height + 10;
|
||||
++rowsOccupied;
|
||||
|
||||
if (rowsOccupied >= columnRows)
|
||||
{
|
||||
x += columnWidth + 5;
|
||||
rowsOccupied = 0;
|
||||
columnRows = 0;
|
||||
columnWidth = 0;
|
||||
++column;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Opacity Protocol
|
||||
|
||||
/** Override synthesized setOpacity to recurse items */
|
||||
void CCMenu::setOpacity(GLubyte var)
|
||||
{
|
||||
m_cOpacity = var;
|
||||
|
||||
if (m_pChildren && m_pChildren->count() > 0)
|
||||
{
|
||||
NSMutableArray<CCNode*>::NSMutableArrayIterator it;
|
||||
for (it = m_pChildren->begin(); it != m_pChildren->end(); ++it)
|
||||
{
|
||||
if (! *it)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
CCRGBAProtocol *pRGBAProtocol = (*it)->convertToRGBAProtocol();
|
||||
if (pRGBAProtocol)
|
||||
{
|
||||
pRGBAProtocol->setOpacity(m_cOpacity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GLubyte CCMenu::getOpacity(void)
|
||||
{
|
||||
return m_cOpacity;
|
||||
}
|
||||
|
||||
void CCMenu::setColor(cocos2d::ccColor3B var)
|
||||
{
|
||||
m_tColor = var;
|
||||
|
||||
if (m_pChildren && m_pChildren->count() > 0)
|
||||
{
|
||||
NSMutableArray<CCNode*>::NSMutableArrayIterator it;
|
||||
for (it = m_pChildren->begin(); it != m_pChildren->end(); ++it)
|
||||
{
|
||||
if (! *it)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
CCRGBAProtocol *pRGBAProtocol = (*it)->convertToRGBAProtocol();
|
||||
if (pRGBAProtocol)
|
||||
{
|
||||
pRGBAProtocol->setColor(m_tColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ccColor3B CCMenu::getColor(void)
|
||||
{
|
||||
return m_tColor;
|
||||
}
|
||||
}
|
|
@ -1,69 +0,0 @@
|
|||
/****************************************************************************
|
||||
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 "platform/CCNS.h"
|
||||
#import <Availability.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
static cocos2d::CGRect static_CCRectFromString(const char* pszContent)
|
||||
{
|
||||
CGRect rect = NSRectToCGRect(NSRectFromString([NSString stringWithUTF8String: pszContent]));
|
||||
cocos2d::CGRect ret(rect.x, rect.y, rect.width, rect.height);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static cocos2d::CGPoint static_CCPointFromString(const char* pszContent)
|
||||
{
|
||||
CGPoint point = NSPointToCGPoint(NSPointFromString([NSString stringWithUTF8String: pszContent]));
|
||||
cocos2d::CGPoint ret(point.x, point.y);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static cocos2d::CGSize static_CCSizeFromString(const char* pszContent)
|
||||
{
|
||||
CGSize size = NSSizeToCGSize(NSSizeFromString([NSString stringWithUTF8String: pszContent]));
|
||||
cocos2d::CGSize ret(size.width, size.height);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
///@todo implement the functions
|
||||
namespace cocos2d
|
||||
{
|
||||
CGRect CCRectFromString(const char* pszContent)
|
||||
{
|
||||
return static_CCRectFromString(pszContent);
|
||||
}
|
||||
|
||||
CGPoint CCPointFromString(const char* pszContent)
|
||||
{
|
||||
return static_CCPointFromString(pszContent);
|
||||
}
|
||||
|
||||
CGSize CCSizeFromString(const char* pszContent)
|
||||
{
|
||||
return static_CCSizeFromString(pszContent);
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -1,28 +0,0 @@
|
|||
/****************************************************************************
|
||||
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.
|
||||
****************************************************************************/
|
||||
|
||||
namespace cocos2d {
|
||||
|
||||
|
||||
}// namespace cocos2d
|
|
@ -1,37 +0,0 @@
|
|||
/****************************************************************************
|
||||
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 __CC_PARTICLE_SYSTEM_POINT_MAC_H__
|
||||
#define __CC_PARTICLE_SYSTEM_POINT_MAC_H__
|
||||
|
||||
#include "CCParticleSystem.h"
|
||||
|
||||
namespace cocos2d {
|
||||
|
||||
class CCX_DLL CCParticleSystemPoint : public CCParticleSystem
|
||||
{
|
||||
public:
|
||||
static CCParticleSystemPoint * particleWithFile(const char *plistFile) { retur 0; }
|
||||
};
|
||||
|
||||
#endif //__CC_PARTICLE_SYSTEM_POINT_MAC_H__
|
File diff suppressed because it is too large
Load Diff
|
@ -1,83 +0,0 @@
|
|||
/*
|
||||
* cocos2d for iPhone: http://www.cocos2d-iphone.org
|
||||
*
|
||||
* Copyright (c) 2010 Ricardo Quesada
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Only compile this code on Mac. These files should not be included on your iOS project.
|
||||
// But in case they are included, it won't be compiled.
|
||||
#import <Availability.h>
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#import "ccConfig.h"
|
||||
|
||||
//PROTOCOLS:
|
||||
|
||||
@protocol MacEventDelegate <NSObject>
|
||||
// Mouse
|
||||
- (void)mouseDown:(NSEvent *)theEvent;
|
||||
- (void)mouseUp:(NSEvent *)theEvent;
|
||||
- (void)mouseMoved:(NSEvent *)theEvent;
|
||||
- (void)mouseDragged:(NSEvent *)theEvent;
|
||||
- (void)rightMouseDown:(NSEvent*)event;
|
||||
- (void)rightMouseDragged:(NSEvent*)event;
|
||||
- (void)rightMouseUp:(NSEvent*)event;
|
||||
- (void)otherMouseDown:(NSEvent*)event;
|
||||
- (void)otherMouseDragged:(NSEvent*)event;
|
||||
- (void)otherMouseUp:(NSEvent*)event;
|
||||
- (void)scrollWheel:(NSEvent *)theEvent;
|
||||
- (void)mouseEntered:(NSEvent *)theEvent;
|
||||
- (void)mouseExited:(NSEvent *)theEvent;
|
||||
|
||||
|
||||
// Keyboard
|
||||
- (void)keyDown:(NSEvent *)theEvent;
|
||||
- (void)keyUp:(NSEvent *)theEvent;
|
||||
- (void)flagsChanged:(NSEvent *)theEvent;
|
||||
|
||||
// Touches
|
||||
- (void)touchesBeganWithEvent:(NSEvent *)event;
|
||||
- (void)touchesMovedWithEvent:(NSEvent *)event;
|
||||
- (void)touchesEndedWithEvent:(NSEvent *)event;
|
||||
- (void)touchesCancelledWithEvent:(NSEvent *)event;
|
||||
|
||||
#if CC_DIRECTOR_MAC_USE_DISPLAY_LINK_THREAD
|
||||
- (void)queueEvent:(NSEvent*)event selector:(SEL)selector;
|
||||
#endif
|
||||
|
||||
@end
|
||||
|
||||
/** MacGLView
|
||||
|
||||
Only available for Mac OS X
|
||||
*/
|
||||
@interface MacGLView : NSOpenGLView {
|
||||
id<MacEventDelegate> eventDelegate_;
|
||||
}
|
||||
|
||||
@property (nonatomic, readwrite, assign) id<MacEventDelegate> eventDelegate;
|
||||
|
||||
// initializes the MacGLView with a frame rect and an OpenGL context
|
||||
- (id) initWithFrame:(NSRect)frameRect shareContext:(NSOpenGLContext*)context;
|
||||
|
||||
// private
|
||||
+(void) load_;
|
||||
@end
|
|
@ -1,241 +0,0 @@
|
|||
/*
|
||||
* cocos2d for iPhone: http://www.cocos2d-iphone.org
|
||||
*
|
||||
* Copyright (c) 2010 Ricardo Quesada
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Idea of subclassing NSOpenGLView was taken from "TextureUpload" Apple's sample
|
||||
*/
|
||||
|
||||
// Only compile this code on Mac. These files should not be included on your iOS project.
|
||||
// But in case they are included, it won't be compiled.
|
||||
#import <Availability.h>
|
||||
#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
|
||||
#elif defined(__MAC_OS_X_VERSION_MAX_ALLOWED)
|
||||
|
||||
#import "MacGLView.h"
|
||||
#import <OpenGL/gl.h>
|
||||
|
||||
#import "CCDirectorMac.h"
|
||||
#import "ccConfig.h"
|
||||
|
||||
|
||||
@implementation MacGLView
|
||||
|
||||
@synthesize eventDelegate = eventDelegate_;
|
||||
|
||||
+(void) load_
|
||||
{
|
||||
NSLog(@"%@ loaded", self);
|
||||
}
|
||||
|
||||
- (id) initWithFrame:(NSRect)frameRect
|
||||
{
|
||||
self = [self initWithFrame:frameRect shareContext:nil];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id) initWithFrame:(NSRect)frameRect shareContext:(NSOpenGLContext*)context
|
||||
{
|
||||
NSOpenGLPixelFormatAttribute attribs[] =
|
||||
{
|
||||
NSOpenGLPFAAccelerated,
|
||||
NSOpenGLPFANoRecovery,
|
||||
NSOpenGLPFADoubleBuffer,
|
||||
NSOpenGLPFADepthSize, 24,
|
||||
|
||||
0
|
||||
};
|
||||
|
||||
NSOpenGLPixelFormat *pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attribs];
|
||||
|
||||
if (!pixelFormat)
|
||||
NSLog(@"No OpenGL pixel format");
|
||||
|
||||
if (self = [super initWithFrame:frameRect pixelFormat:[pixelFormat autorelease]]) {
|
||||
|
||||
if( context )
|
||||
[self setOpenGLContext:context];
|
||||
|
||||
// Synchronize buffer swaps with vertical refresh rate
|
||||
GLint swapInt = 1;
|
||||
[[self openGLContext] setValues:&swapInt forParameter:NSOpenGLCPSwapInterval];
|
||||
|
||||
// GLint order = -1;
|
||||
// [[self openGLContext] setValues:&order forParameter:NSOpenGLCPSurfaceOrder];
|
||||
|
||||
// event delegate
|
||||
eventDelegate_ = nil;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) reshape
|
||||
{
|
||||
// We draw on a secondary thread through the display link
|
||||
// When resizing the view, -reshape is called automatically on the main thread
|
||||
// Add a mutex around to avoid the threads accessing the context simultaneously when resizing
|
||||
CGLLockContext([[self openGLContext] CGLContextObj]);
|
||||
|
||||
NSRect rect = [self bounds];
|
||||
|
||||
CCDirector *director = cocos2d::CCDirector::sharedDirector();
|
||||
director->reshapeProjection(NSSizeToCGSize(rect.size));
|
||||
|
||||
// avoid flicker
|
||||
director->drawScene();
|
||||
// [self setNeedsDisplay:YES];
|
||||
|
||||
CGLUnlockContext([[self openGLContext] CGLContextObj]);
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
#if CC_DIRECTOR_MAC_USE_DISPLAY_LINK_THREAD
|
||||
#define DISPATCH_EVENT(__event__, __selector__) [eventDelegate_ queueEvent:__event__ selector:__selector__];
|
||||
#else
|
||||
#define DISPATCH_EVENT(__event__, __selector__) \
|
||||
id obj = eventDelegate_; \
|
||||
[obj performSelector:__selector__ \
|
||||
onThread:[[CCDirectorDisplayLinkMacWrapper sharedDisplayLinkMacWrapper] runningThread] \
|
||||
withObject:__event__ \
|
||||
waitUntilDone:NO];
|
||||
#endif
|
||||
|
||||
#pragma mark MacGLView - Mouse events
|
||||
- (void)mouseDown:(NSEvent *)theEvent
|
||||
{
|
||||
DISPATCH_EVENT(theEvent, _cmd);
|
||||
}
|
||||
|
||||
- (void)mouseMoved:(NSEvent *)theEvent
|
||||
{
|
||||
DISPATCH_EVENT(theEvent, _cmd);
|
||||
}
|
||||
|
||||
- (void)mouseDragged:(NSEvent *)theEvent
|
||||
{
|
||||
DISPATCH_EVENT(theEvent, _cmd);
|
||||
}
|
||||
|
||||
- (void)mouseUp:(NSEvent *)theEvent
|
||||
{
|
||||
DISPATCH_EVENT(theEvent, _cmd);
|
||||
}
|
||||
|
||||
- (void)rightMouseDown:(NSEvent *)theEvent {
|
||||
DISPATCH_EVENT(theEvent, _cmd);
|
||||
}
|
||||
|
||||
- (void)rightMouseDragged:(NSEvent *)theEvent {
|
||||
DISPATCH_EVENT(theEvent, _cmd);
|
||||
}
|
||||
|
||||
- (void)rightMouseUp:(NSEvent *)theEvent {
|
||||
DISPATCH_EVENT(theEvent, _cmd);
|
||||
}
|
||||
|
||||
- (void)otherMouseDown:(NSEvent *)theEvent {
|
||||
DISPATCH_EVENT(theEvent, _cmd);
|
||||
}
|
||||
|
||||
- (void)otherMouseDragged:(NSEvent *)theEvent {
|
||||
DISPATCH_EVENT(theEvent, _cmd);
|
||||
}
|
||||
|
||||
- (void)otherMouseUp:(NSEvent *)theEvent {
|
||||
DISPATCH_EVENT(theEvent, _cmd);
|
||||
}
|
||||
|
||||
- (void)mouseEntered:(NSEvent *)theEvent {
|
||||
DISPATCH_EVENT(theEvent, _cmd);
|
||||
}
|
||||
|
||||
- (void)mouseExited:(NSEvent *)theEvent {
|
||||
DISPATCH_EVENT(theEvent, _cmd);
|
||||
}
|
||||
|
||||
-(void) scrollWheel:(NSEvent *)theEvent {
|
||||
DISPATCH_EVENT(theEvent, _cmd);
|
||||
}
|
||||
|
||||
#pragma mark MacGLView - Key events
|
||||
|
||||
-(BOOL) becomeFirstResponder
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
-(BOOL) acceptsFirstResponder
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
-(BOOL) resignFirstResponder
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)keyDown:(NSEvent *)theEvent
|
||||
{
|
||||
DISPATCH_EVENT(theEvent, _cmd);
|
||||
}
|
||||
|
||||
- (void)keyUp:(NSEvent *)theEvent
|
||||
{
|
||||
DISPATCH_EVENT(theEvent, _cmd);
|
||||
}
|
||||
|
||||
- (void)flagsChanged:(NSEvent *)theEvent
|
||||
{
|
||||
DISPATCH_EVENT(theEvent, _cmd);
|
||||
}
|
||||
|
||||
#pragma mark MacGLView - Touch events
|
||||
- (void)touchesBeganWithEvent:(NSEvent *)theEvent
|
||||
{
|
||||
DISPATCH_EVENT(theEvent, _cmd);
|
||||
}
|
||||
|
||||
- (void)touchesMovedWithEvent:(NSEvent *)theEvent
|
||||
{
|
||||
DISPATCH_EVENT(theEvent, _cmd);
|
||||
}
|
||||
|
||||
- (void)touchesEndedWithEvent:(NSEvent *)theEvent
|
||||
{
|
||||
DISPATCH_EVENT(theEvent, _cmd);
|
||||
}
|
||||
|
||||
- (void)touchesCancelledWithEvent:(NSEvent *)theEvent
|
||||
{
|
||||
DISPATCH_EVENT(theEvent, _cmd);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#endif // __MAC_OS_X_VERSION_MAX_ALLOWED
|
|
@ -399,14 +399,6 @@
|
|||
RelativePath="..\include\CCEGLView.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\include\CCEvent.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\include\CCEventDispatcher.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\include\CCGeometry.h"
|
||||
>
|
||||
|
@ -415,10 +407,6 @@
|
|||
RelativePath="..\include\CCGL.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\include\CCKeyboardEventDelegate.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\include\CCKeypadDelegate.h"
|
||||
>
|
||||
|
@ -459,10 +447,6 @@
|
|||
RelativePath="..\include\CCMotionStreak.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\include\CCMouseEventDelegate.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\include\CCMutableArray.h"
|
||||
>
|
||||
|
@ -651,6 +635,10 @@
|
|||
<Filter
|
||||
Name="layers_scenes_transitions_nodes"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\layers_scenes_transitions_nodes\CCLayer.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\layers_scenes_transitions_nodes\CCScene.cpp"
|
||||
>
|
||||
|
@ -667,6 +655,10 @@
|
|||
<Filter
|
||||
Name="menu_nodes"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\menu_nodes\CCMenu.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\menu_nodes\CCMenuItem.cpp"
|
||||
>
|
||||
|
@ -703,6 +695,10 @@
|
|||
RelativePath="..\particle_nodes\CCParticleSystem.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\particle_nodes\CCParticleSystemPoint.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\particle_nodes\CCParticleSystemQuad.cpp"
|
||||
>
|
||||
|
@ -767,34 +763,14 @@
|
|||
RelativePath="..\platform\CCImage.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\platform\CCLayer_mobile.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\platform\CCLibxml2.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\platform\CCMenu_mobile.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\platform\CCNode_mobile.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\platform\CCParticleSystemPoint_mobile.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\platform\CCParticleSystemPoint_mobile.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\platform\CCParticleSystemPoint_platform.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\platform\CCPlatformConfig.h"
|
||||
>
|
||||
|
@ -1068,22 +1044,6 @@
|
|||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="event_dispatcher"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\event_dispatcher\CCEventDispatcher.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\event_dispatcher\CCKeyboardEventDelegate.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\event_dispatcher\CCMouseEventDelegate.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<File
|
||||
RelativePath="..\CCCamera.cpp"
|
||||
>
|
||||
|
|
|
@ -58,17 +58,16 @@ OBJECTS = \
|
|||
$(OBJECTS_DIR)/CCSet.o \
|
||||
$(OBJECTS_DIR)/CCZone.o \
|
||||
$(OBJECTS_DIR)/CCGrabber.o \
|
||||
$(OBJECTS_DIR)/CCEventDispatcher.o \
|
||||
$(OBJECTS_DIR)/CCKeyboardEventDelegate.o \
|
||||
$(OBJECTS_DIR)/CCMouseEventDelegate.o \
|
||||
$(OBJECTS_DIR)/CCKeypadDelegate.o \
|
||||
$(OBJECTS_DIR)/CCKeypadDispatcher.o \
|
||||
$(OBJECTS_DIR)/CCLabelAtlas.o \
|
||||
$(OBJECTS_DIR)/CCLabelBMFont.o \
|
||||
$(OBJECTS_DIR)/CCLabelTTF.o \
|
||||
$(OBJECTS_DIR)/CCLayer.o \
|
||||
$(OBJECTS_DIR)/CCScene.o \
|
||||
$(OBJECTS_DIR)/CCTransitionPageTurn.o \
|
||||
$(OBJECTS_DIR)/CCTransitionRadial.o \
|
||||
$(OBJECTS_DIR)/CCMenu.o \
|
||||
$(OBJECTS_DIR)/CCMenuItem.o \
|
||||
$(OBJECTS_DIR)/CCMotionStreak.o \
|
||||
$(OBJECTS_DIR)/CCProgressTimer.o \
|
||||
|
@ -76,6 +75,7 @@ OBJECTS = \
|
|||
$(OBJECTS_DIR)/CCRibbon.o \
|
||||
$(OBJECTS_DIR)/CCParticleExamples.o \
|
||||
$(OBJECTS_DIR)/CCParticleSystem.o \
|
||||
$(OBJECTS_DIR)/CCParticleSystemPoint.o \
|
||||
$(OBJECTS_DIR)/CCParticleSystemQuad.o \
|
||||
$(OBJECTS_DIR)/CCCommon.o \
|
||||
$(OBJECTS_DIR)/CCDirector_mobile.o \
|
||||
|
@ -83,10 +83,7 @@ OBJECTS = \
|
|||
$(OBJECTS_DIR)/CCGL.o \
|
||||
$(OBJECTS_DIR)/CCGrid_mobile.o \
|
||||
$(OBJECTS_DIR)/CCImage.o \
|
||||
$(OBJECTS_DIR)/CCLayer_mobile.o \
|
||||
$(OBJECTS_DIR)/CCMenu_mobile.o \
|
||||
$(OBJECTS_DIR)/CCNode_mobile.o \
|
||||
$(OBJECTS_DIR)/CCParticleSystemPoint_mobile.o \
|
||||
$(OBJECTS_DIR)/CCSAXParser.o \
|
||||
$(OBJECTS_DIR)/CCStdC.o \
|
||||
$(OBJECTS_DIR)/CCThread.o \
|
||||
|
@ -219,15 +216,6 @@ $(OBJECTS_DIR)/CCZone.o : ../cocoa/CCZone.cpp
|
|||
$(OBJECTS_DIR)/CCGrabber.o : ../effects/CCGrabber.cpp
|
||||
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/CCGrabber.o ../effects/CCGrabber.cpp
|
||||
|
||||
$(OBJECTS_DIR)/CCEventDispatcher.o : ../event_dispatcher/CCEventDispatcher.cpp
|
||||
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/CCEventDispatcher.o ../event_dispatcher/CCEventDispatcher.cpp
|
||||
|
||||
$(OBJECTS_DIR)/CCKeyboardEventDelegate.o : ../event_dispatcher/CCKeyboardEventDelegate.cpp
|
||||
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/CCKeyboardEventDelegate.o ../event_dispatcher/CCKeyboardEventDelegate.cpp
|
||||
|
||||
$(OBJECTS_DIR)/CCMouseEventDelegate.o : ../event_dispatcher/CCMouseEventDelegate.cpp
|
||||
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/CCMouseEventDelegate.o ../event_dispatcher/CCMouseEventDelegate.cpp
|
||||
|
||||
$(OBJECTS_DIR)/CCKeypadDelegate.o : ../keypad_dispatcher/CCKeypadDelegate.cpp
|
||||
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/CCKeypadDelegate.o ../keypad_dispatcher/CCKeypadDelegate.cpp
|
||||
|
||||
|
@ -243,6 +231,9 @@ $(OBJECTS_DIR)/CCLabelBMFont.o : ../label_nodes/CCLabelBMFont.cpp
|
|||
$(OBJECTS_DIR)/CCLabelTTF.o : ../label_nodes/CCLabelTTF.cpp
|
||||
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/CCLabelTTF.o ../label_nodes/CCLabelTTF.cpp
|
||||
|
||||
$(OBJECTS_DIR)/CCLayer.o : ../layers_scenes_transitions_nodes/CCLayer.cpp
|
||||
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/CCLayer.o ../layers_scenes_transitions_nodes/CCLayer.cpp
|
||||
|
||||
$(OBJECTS_DIR)/CCScene.o : ../layers_scenes_transitions_nodes/CCScene.cpp
|
||||
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/CCScene.o ../layers_scenes_transitions_nodes/CCScene.cpp
|
||||
|
||||
|
@ -252,6 +243,9 @@ $(OBJECTS_DIR)/CCTransitionPageTurn.o : ../layers_scenes_transitions_nodes/CCTra
|
|||
$(OBJECTS_DIR)/CCTransitionRadial.o : ../layers_scenes_transitions_nodes/CCTransitionRadial.cpp
|
||||
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/CCTransitionRadial.o ../layers_scenes_transitions_nodes/CCTransitionRadial.cpp
|
||||
|
||||
$(OBJECTS_DIR)/CCMenu.o : ../menu_nodes/CCMenu.cpp
|
||||
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/CCMenu.o ../menu_nodes/CCMenu.cpp
|
||||
|
||||
$(OBJECTS_DIR)/CCMenuItem.o : ../menu_nodes/CCMenuItem.cpp
|
||||
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/CCMenuItem.o ../menu_nodes/CCMenuItem.cpp
|
||||
|
||||
|
@ -273,6 +267,9 @@ $(OBJECTS_DIR)/CCParticleExamples.o : ../particle_nodes/CCParticleExamples.cpp
|
|||
$(OBJECTS_DIR)/CCParticleSystem.o : ../particle_nodes/CCParticleSystem.cpp
|
||||
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/CCParticleSystem.o ../particle_nodes/CCParticleSystem.cpp
|
||||
|
||||
$(OBJECTS_DIR)/CCParticleSystemPoint.o : ../particle_nodes/CCParticleSystemPoint.cpp
|
||||
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/CCParticleSystemPoint.o ../particle_nodes/CCParticleSystemPoint.cpp
|
||||
|
||||
$(OBJECTS_DIR)/CCParticleSystemQuad.o : ../particle_nodes/CCParticleSystemQuad.cpp
|
||||
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/CCParticleSystemQuad.o ../particle_nodes/CCParticleSystemQuad.cpp
|
||||
|
||||
|
@ -294,24 +291,15 @@ $(OBJECTS_DIR)/CCGrid_mobile.o : ../platform/CCGrid_mobile.cpp
|
|||
$(OBJECTS_DIR)/CCImage.o : ../platform/CCImage.cpp
|
||||
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/CCImage.o ../platform/CCImage.cpp
|
||||
|
||||
$(OBJECTS_DIR)/CCLayer_mobile.o : ../platform/CCLayer_mobile.cpp
|
||||
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/CCLayer_mobile.o ../platform/CCLayer_mobile.cpp
|
||||
|
||||
$(OBJECTS_DIR)/CCMenu_mobile.o : ../platform/CCMenu_mobile.cpp
|
||||
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/CCMenu_mobile.o ../platform/CCMenu_mobile.cpp
|
||||
|
||||
$(OBJECTS_DIR)/CCNode_mobile.o : ../platform/CCNode_mobile.cpp
|
||||
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/CCNode_mobile.o ../platform/CCNode_mobile.cpp
|
||||
|
||||
$(OBJECTS_DIR)/CCParticleSystemPoint_mobile.o : ../platform/CCParticleSystemPoint_mobile.cpp
|
||||
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/CCParticleSystemPoint_mobile.o ../platform/CCParticleSystemPoint_mobile.cpp
|
||||
$(OBJECTS_DIR)/CCSAXParser.o : ../platform/CCSAXParser.cpp
|
||||
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/CCSAXParser.o ../platform/CCSAXParser.cpp
|
||||
|
||||
$(OBJECTS_DIR)/CCStdC.o : ../platform/CCStdC.cpp
|
||||
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/CCStdC.o ../platform/CCStdC.cpp
|
||||
|
||||
$(OBJECTS_DIR)/CCSAXParser.o : ../platform/CCSAXParser.cpp
|
||||
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/CCSAXParser.o ../platform/CCSAXParser.cpp
|
||||
|
||||
$(OBJECTS_DIR)/CCThread.o : ../platform/CCThread.cpp
|
||||
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/CCThread.o ../platform/CCThread.cpp
|
||||
|
||||
|
|
|
@ -360,14 +360,6 @@
|
|||
RelativePath="..\include\CCEGLView.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\include\CCEvent.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\include\CCEventDispatcher.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\include\CCGeometry.h"
|
||||
>
|
||||
|
@ -376,10 +368,6 @@
|
|||
RelativePath="..\include\CCGL.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\include\CCKeyboardEventDelegate.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\include\CCKeypadDelegate.h"
|
||||
>
|
||||
|
@ -420,10 +408,6 @@
|
|||
RelativePath="..\include\CCMotionStreak.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\include\CCMouseEventDelegate.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\include\CCMutableArray.h"
|
||||
>
|
||||
|
@ -612,6 +596,10 @@
|
|||
<Filter
|
||||
Name="layers_scenes_transition_nodes"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\layers_scenes_transitions_nodes\CCLayer.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\layers_scenes_transitions_nodes\CCScene.cpp"
|
||||
>
|
||||
|
@ -628,6 +616,10 @@
|
|||
<Filter
|
||||
Name="menu_nodes"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\menu_nodes\CCMenu.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\menu_nodes\CCMenuItem.cpp"
|
||||
>
|
||||
|
@ -665,7 +657,7 @@
|
|||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\platform\CCParticleSystemPoint_mobile.cpp"
|
||||
RelativePath="..\particle_nodes\CCParticleSystemPoint.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
|
@ -960,30 +952,14 @@
|
|||
RelativePath="..\platform\CCImage.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\platform\CCLayer_mobile.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\platform\CCLibxml2.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\platform\CCMenu_mobile.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\platform\CCNode_mobile.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\platform\CCParticleSystemPoint_mobile.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\platform\CCParticleSystemPoint_platform.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\platform\CCPlatformConfig.h"
|
||||
>
|
||||
|
@ -1089,22 +1065,6 @@
|
|||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="event_dispatcher"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\event_dispatcher\CCEventDispatcher.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\event_dispatcher\CCKeyboardEventDelegate.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\event_dispatcher\CCMouseEventDelegate.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<File
|
||||
RelativePath="..\CCCamera.cpp"
|
||||
>
|
||||
|
|
Loading…
Reference in New Issue