Merge pull request #629 from gzito/master

Optimized ttf to bitmap, cached last loaded ttf & fixed ttf alpha. Other minor fixes. Added authors info.
This commit is contained in:
dumganhar 2011-12-19 18:46:07 -08:00
commit a8d5b6544a
10 changed files with 1024 additions and 769 deletions

View File

@ -44,7 +44,10 @@ Developers:
authors of lua binding
Max Aksenov
author and maintainer of Marmalade(Airplay) port
author and maintainer of Airplay port
Giovanni Zito
Francis Styck
maintainers of Marmalade port
Carlos Sessa
implement the accelerometer module onto Android

View File

@ -47,10 +47,6 @@ namespace CocosDenshion
static int16* g_AudioBuffer = 0;
static int32 g_AudioFileSize = 0;
// static int g_SoundChannel = 0;
// static bool g_SoundIsPlaying = false;
// static s3eBool g_MP3Support = S3E_FALSE;
typedef map<string,SoundFx> SoundFxMap ;
static SoundFxMap* g_pSoundFxMap = 0 ;
@ -101,7 +97,7 @@ namespace CocosDenshion
void SimpleAudioEngine::setResource(const char* pszZipFileName)
{
// todo
}
void SimpleAudioEngine::preloadBackgroundMusic(const char* pszFilePath)
@ -125,14 +121,7 @@ namespace CocosDenshion
if ( result == S3E_RESULT_ERROR)
{
if (bLoop)
{
result = s3eAudioPlay(pszFilePath, 0);
}
else
{
result = s3eAudioPlay(pszFilePath, 1);
}
result = s3eAudioPlay(pszFilePath, bLoop ? 0 : 1);
}
if ( result == S3E_RESULT_ERROR)
@ -164,11 +153,12 @@ namespace CocosDenshion
void SimpleAudioEngine::rewindBackgroundMusic()
{
//todo
}
bool SimpleAudioEngine::willPlayBackgroundMusic()
{
// todo
return true;
}
@ -256,26 +246,26 @@ namespace CocosDenshion
void SimpleAudioEngine::pauseEffect(unsigned int nSoundId)
{
s3eSoundChannelPause (nSoundId);
s3eSoundChannelPause(nSoundId);
}
void SimpleAudioEngine::pauseAllEffects()
{
s3eSoundPauseAllChannels ();
s3eSoundPauseAllChannels();
}
void SimpleAudioEngine::resumeEffect(unsigned int nSoundId)
{
s3eSoundChannelResume (nSoundId);
s3eSoundChannelResume(nSoundId);
}
void SimpleAudioEngine::resumeAllEffects()
{
s3eSoundResumeAllChannels ();
s3eSoundResumeAllChannels();
}
void SimpleAudioEngine::stopAllEffects()
{
s3eSoundStopAllChannels ();
s3eSoundStopAllChannels();
}
}

View File

@ -1,6 +1,7 @@
/****************************************************************************
Copyright (c) 2011 cocos2d-x.org http://cocos2d-x.org
Copyright (c) 2011 Максим Аксенов
Copyright (c) 2011 Giovanni Zito, Francis Styck
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -1,7 +1,8 @@
/****************************************************************************
Copyright (c) 2011 cocos2d-x.org http://cocos2d-x.org
Copyright (c) 2011 Максим Аксенов
Copyright (c) 2011 Giovanni Zito, Francis Styck
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

View File

@ -1,7 +1,8 @@
/****************************************************************************
Copyright (c) 2011 cocos2d-x.org http://cocos2d-x.org
Copyright (c) 2011 Максим Аксенов
Copyright (c) 2011 Giovanni Zito, Francis Styck
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
@ -81,7 +82,8 @@ int CCApplication::Run()
ccAccelerationUpdate();
if( (quitRequested = s3eDeviceCheckQuitRequest()) ) {
quitRequested = s3eDeviceCheckQuitRequest() ;
if( quitRequested && CCDirector::sharedDirector()->getOpenGLView() != NULL ) {
CCDirector::sharedDirector()->end() ;
// end status will be processed in CCDirector::sharedDirector()->mainLoop();
}

View File

@ -1,7 +1,8 @@
/****************************************************************************
Copyright (c) 2011 cocos2d-x.org http://cocos2d-x.org
Copyright (c) 2011 Максим Аксенов
Copyright (c) 2011 Giovanni Zito, Francis Styck
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

View File

@ -1,7 +1,8 @@
/****************************************************************************
Copyright (c) 2011 cocos2d-x.org http://cocos2d-x.org
Copyright (c) 2011 Максим Аксенов
Copyright (c) 2011 Giovanni Zito, Francis Styck
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
@ -44,7 +45,6 @@ CCEGLView::CCEGLView()
: m_pDelegate(NULL)
, m_fScreenScaleFactor(1.0)
, m_bNotHVGA(false)
, m_bCaptured(false)
, m_bAccelState(false)
, m_Key(s3eKeyFirst)
@ -60,12 +60,28 @@ CCEGLView::CCEGLView()
m_pSet = new CCSet;
m_pTouch = new CCTouch;
// Register pointer touch button event handler
s3ePointerRegister(S3E_POINTER_BUTTON_EVENT, &TouchEventHandler, this);
// Register pointer motion button event handler
s3ePointerRegister(S3E_POINTER_MOTION_EVENT, &MotionEventHandler, this);
// Determine if the device supports multi-touch
m_isMultiTouch = s3ePointerGetInt(S3E_POINTER_MULTI_TOUCH_AVAILABLE) ? true : false;
// For multi-touch devices we handle touch and motion events using different callbacks
if (m_isMultiTouch)
{
s3ePointerRegister(S3E_POINTER_TOUCH_EVENT, &MultiTouchEventHandler, this);
s3ePointerRegister(S3E_POINTER_TOUCH_MOTION_EVENT, &MultiMotionEventHandler, this);
for (int i = 0; i < S3E_POINTER_TOUCH_MAX; i++) {
touchSet[i] = NULL;
}
}
else
{
// Register pointer touch button event handler
s3ePointerRegister(S3E_POINTER_BUTTON_EVENT, &TouchEventHandler, this);
// Register pointer motion button event handler
s3ePointerRegister(S3E_POINTER_MOTION_EVENT, &MotionEventHandler, this);
}
// Register keyboard event handler
s3eKeyboardRegister(S3E_KEYBOARD_KEY_EVENT, &KeyEventHandler, this);
}
@ -122,6 +138,7 @@ CCSize CCEGLView::getSize()
}
}
void CCEGLView::setTouch(void* systemData)
{
s3ePointerEvent* event =(s3ePointerEvent*)systemData;
@ -146,6 +163,7 @@ void CCEGLView::setTouch(void* systemData)
break;
}
}
void CCEGLView::setMotionTouch(void* systemData)
{
s3ePointerMotionEvent* event =(s3ePointerMotionEvent*)systemData;
@ -156,6 +174,65 @@ void CCEGLView::setMotionTouch(void* systemData)
}
}
void CCEGLView::setMultiTouch(void* systemData)
{
s3ePointerTouchEvent* event =(s3ePointerTouchEvent*)systemData;
if (touchSet[event->m_TouchID] == NULL) {
m_pTouch = new CCTouch;
touchSet[event->m_TouchID] = m_pTouch;
}
else {
m_pTouch = touchSet[event->m_TouchID];
}
switch (event->m_Pressed)
{
case S3E_POINTER_STATE_DOWN :
m_pTouch->SetTouchInfo(0, (float)event->m_x, (float)event->m_y);
m_pSet->addObject(m_pTouch);
m_pDelegate->touchesBegan(m_pSet, NULL);
break;
case S3E_POINTER_STATE_UP :
{
m_pTouch->SetTouchInfo(0, (float)event->m_x, (float)event->m_y);
m_pDelegate->touchesEnded(m_pSet, NULL);
m_pSet->removeObject(m_pTouch);
touchSet[event->m_TouchID] = NULL;
}
break;
}
}
void CCEGLView::setMultiMotionTouch(void* systemData)
{
s3ePointerTouchMotionEvent* event =(s3ePointerTouchMotionEvent*)systemData;
m_pTouch = touchSet[event->m_TouchID];
if (m_pTouch)
{
m_pTouch->SetTouchInfo((int)event, (float)event->m_x, (float)event->m_y);
m_pDelegate->touchesMoved(m_pSet, NULL);
}
}
CCTouch* CCEGLView::findTouch(int id)
{
CCSetIterator iter;
for (iter = m_pSet->begin(); iter != m_pSet->end(); ++iter)
{
CCTouch *touch = (CCTouch*)*iter;
if(touch->view() == id)
return touch;
}
return NULL;
}
void CCEGLView::setKeyTouch(void* systemData)
{
s3eKeyboardEvent* event = (s3eKeyboardEvent*)systemData;
@ -184,8 +261,17 @@ void CCEGLView::release()
{
IW_CALLSTACK("CCEGLView::release");
s3ePointerUnRegister(S3E_POINTER_BUTTON_EVENT, &TouchEventHandler);
s3ePointerUnRegister(S3E_POINTER_MOTION_EVENT, &MotionEventHandler);
if (m_isMultiTouch)
{
s3ePointerUnRegister(S3E_POINTER_TOUCH_EVENT, &MultiTouchEventHandler);
s3ePointerUnRegister(S3E_POINTER_TOUCH_MOTION_EVENT, &MultiMotionEventHandler);
}
else
{
s3ePointerUnRegister(S3E_POINTER_BUTTON_EVENT, &TouchEventHandler);
s3ePointerUnRegister(S3E_POINTER_MOTION_EVENT, &MotionEventHandler);
}
s3eKeyboardUnRegister(S3E_KEYBOARD_KEY_EVENT, &KeyEventHandler);
if (IwGLIsInitialised())

View File

@ -1,7 +1,8 @@
/****************************************************************************
Copyright (c) 2011 cocos2d-x.org http://cocos2d-x.org
Copyright (c) 2011 Максим Аксенов
Copyright (c) 2011 Giovanni Zito, Francis Styck
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
@ -26,8 +27,8 @@
#include "CCGeometry.h"
#include "s3eKeyboard.h"
#include "s3ePointer.h"
#include "IwUtil.h"
#include "IwUtilInitTerm.h"
NS_CC_BEGIN;
class CCSet;
@ -42,29 +43,29 @@ public:
CCEGLView();
virtual ~CCEGLView();
CCSize getSize();
bool isOpenGLReady();
CCSize getSize();
bool isOpenGLReady();
/**
* the width and height is the real size of phone
*/
void setFrameWidthAndHeight(int width, int height);
void setFrameWidthAndHeight(int width, int height);
/**
* create a drawing rect,
* the width and heiht is the resource size match best
*/
void create(int width, int height);
void create(int width, int height);
EGLTouchDelegate* getDelegate(void);
// keep compatible
void release();
void setTouchDelegate(EGLTouchDelegate * pDelegate);
void swapBuffers();
bool canSetContentScaleFactor();
void setContentScaleFactor(float contentScaleFactor);
void setViewPortInPoints(float x, float y, float w, float h);
void setScissorInPoints(float x, float y, float w, float h);
CCRect getViewPort();
float getScreenScaleFactor();
void release();
void setTouchDelegate(EGLTouchDelegate * pDelegate);
void swapBuffers();
bool canSetContentScaleFactor();
void setContentScaleFactor(float contentScaleFactor);
void setViewPortInPoints(float x, float y, float w, float h);
void setScissorInPoints(float x, float y, float w, float h);
CCRect getViewPort();
float getScreenScaleFactor();
// static function
/**
@ -74,36 +75,57 @@ public:
private:
CCSize m_sSizeInPixel;
CCSize m_sSizeInPoint;
CCRect m_rcViewPort;
bool m_bNotHVGA;
CCSize m_sSizeInPixel;
CCSize m_sSizeInPoint;
CCRect m_rcViewPort;
bool m_bNotHVGA;
EGLTouchDelegate *m_pDelegate;
float m_fScreenScaleFactor;
EGLTouchDelegate* m_pDelegate;
float m_fScreenScaleFactor;
bool m_bAccelState;
bool m_bCaptured;
s3eKey m_Key;
CCSet * m_pSet;
CCTouch * m_pTouch;
bool m_isMultiTouch;
static CCEGLView* m_pInstance ;
void setTouch(void* systemData);
void setMotionTouch(void* systemData);
void setKeyTouch(void* systemData);
void setTouch(void* systemData);
void setMotionTouch(void* systemData);
void setMultiTouch(void* systemData);
void setMultiMotionTouch(void* systemData);
void setKeyTouch(void* systemData);
CCTouch* findTouch(int id);
CCTouch* touchSet[S3E_POINTER_TOUCH_MAX];
static int32 TouchEventHandler(void* systemData, void* userData)
{
((CCEGLView*)userData)->setTouch(systemData);
return 0;
}
static int32 MotionEventHandler(void* systemData, void* userData)
{
((CCEGLView*)userData)->setMotionTouch(systemData);
return 0;
}
static int32 MultiTouchEventHandler(void* systemData, void* userData)
{
((CCEGLView*)userData)->setMultiTouch(systemData);
return 0;
}
static int32 MultiMotionEventHandler(void* systemData, void* userData)
{
((CCEGLView*)userData)->setMultiMotionTouch(systemData);
return 0;
}
static int32 KeyEventHandler(void* systemData, void* userData)
{
((CCEGLView*)userData)->setKeyTouch(systemData);

View File

@ -1,6 +1,7 @@
/****************************************************************************
Copyright (c) 2011 cocos2d-x.org http://cocos2d-x.org
Copyright (c) 2011 Максим Аксенов
Copyright (c) 2011 Giovanni Zito, Francis Styck
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

File diff suppressed because it is too large Load Diff