mirror of https://github.com/axmolengine/axmol.git
Closed #2345 Merge branch 'develop' of https://github.com/cocos2d/cocos2d-x into 2345
This commit is contained in:
commit
304d636deb
10
AUTHORS
10
AUTHORS
|
@ -416,6 +416,7 @@ Developers:
|
|||
Refactored emscripten-build.sh, it's no longer need to be edited to make emscripten work.
|
||||
Creation of CCDeprecated-ext.h
|
||||
Use of a single emscripten HTML template file.
|
||||
Added some guards in fileutils. Fixed a bug in emscripten file utils.
|
||||
|
||||
elmiro
|
||||
Correction of passed buffer size to readlink and verification of result return by readlink.
|
||||
|
@ -539,6 +540,12 @@ Developers:
|
|||
|
||||
Rafael (rafaelx)
|
||||
A warning fix of AL_INVALID_NAME and AL_INVALID_OPERATION in SimpleAudioEngineOpenAL.cpp.
|
||||
|
||||
metalbass
|
||||
Fixing an issue that sigslot::_connection_base# (from 0 to 8) don't have virtual destructors.
|
||||
|
||||
thp
|
||||
Port Cocos2D-X to Qt 5
|
||||
|
||||
Retired Core Developers:
|
||||
WenSheng Yang
|
||||
|
@ -560,6 +567,9 @@ Retired Core Developers:
|
|||
|
||||
metadao
|
||||
make create_project.py more pythonic and fix some typoes
|
||||
|
||||
timothyqiu
|
||||
Project creator: use absolute path for json config files
|
||||
|
||||
|
||||
Cocos2d-x can not grow so fast without the active community.
|
||||
|
|
|
@ -74,7 +74,7 @@ SimpleAudioEngine::SimpleAudioEngine()
|
|||
|
||||
const char* deviceModel = methodInfo.env->GetStringUTFChars(jstr, NULL);
|
||||
|
||||
LOGD(deviceModel);
|
||||
LOGD("%s", deviceModel);
|
||||
|
||||
if (strcmp(I9100_MODEL, deviceModel) == 0)
|
||||
{
|
||||
|
|
|
@ -371,7 +371,7 @@ void OpenSLEngine::createEngine(void* pHandle)
|
|||
const char* errorInfo = dlerror();
|
||||
if (errorInfo)
|
||||
{
|
||||
LOGD(errorInfo);
|
||||
LOGD("%s", errorInfo);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ bool SimpleAudioEngineOpenSL::initEngine()
|
|||
const char* errorInfo = dlerror();
|
||||
if (errorInfo)
|
||||
{
|
||||
LOGD(errorInfo);
|
||||
LOGD("%s", errorInfo);
|
||||
bRet = false;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
|
||||
include(../../cocos2dx/proj.qt5/common.pri)
|
||||
|
||||
TEMPLATE = lib
|
||||
|
||||
SOURCES += $$files(../qt5/*.cpp)
|
||||
|
||||
INCLUDEPATH += ..
|
||||
INCLUDEPATH += ../include
|
||||
|
||||
TARGET = $${LIB_OUTPUT_DIR}/cocosdenshion
|
||||
|
||||
INSTALLS += target
|
||||
target.path = $${LIB_INSTALL_DIR}
|
||||
|
|
@ -0,0 +1,407 @@
|
|||
/**
|
||||
*
|
||||
* Cocos2D-X Qt 5 Platform
|
||||
*
|
||||
* Copyright (C) 2013 Jolla Ltd.
|
||||
* Contact: Thomas Perl <thomas.perl@jollamobile.com>
|
||||
*
|
||||
* 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 "SimpleAudioEngine.h"
|
||||
|
||||
#include "platform/CCCommon.h"
|
||||
#include "platform/CCFileUtils.h"
|
||||
|
||||
#include <QMap>
|
||||
#include <QMediaPlayer>
|
||||
|
||||
USING_NS_CC;
|
||||
|
||||
namespace CocosDenshion {
|
||||
|
||||
static QString
|
||||
fullPath(const char *filename)
|
||||
{
|
||||
return QString::fromStdString(FileUtils::getInstance()->fullPathForFilename(filename));
|
||||
}
|
||||
|
||||
class CocosQt5AudioBackend {
|
||||
public:
|
||||
static void cleanup();
|
||||
static void gcEffects();
|
||||
|
||||
static QMediaPlayer *player() {
|
||||
if (background_music == NULL) {
|
||||
background_music = new QMediaPlayer;
|
||||
}
|
||||
|
||||
return background_music;
|
||||
}
|
||||
|
||||
static void setEffectsVolume(float volume)
|
||||
{
|
||||
effects_volume = volume;
|
||||
|
||||
foreach (QMediaPlayer *effect, effects.values()) {
|
||||
effect->setVolume(volume * 100.0);
|
||||
}
|
||||
}
|
||||
|
||||
static QMap<int,QMediaPlayer*> effects;
|
||||
static QMediaPlayer *background_music;
|
||||
static int next_effect_id;
|
||||
static float effects_volume;
|
||||
};
|
||||
|
||||
QMap<int,QMediaPlayer*>
|
||||
CocosQt5AudioBackend::effects;
|
||||
|
||||
QMediaPlayer *
|
||||
CocosQt5AudioBackend::background_music = NULL;
|
||||
|
||||
int
|
||||
CocosQt5AudioBackend::next_effect_id = 0;
|
||||
|
||||
float
|
||||
CocosQt5AudioBackend::effects_volume = 1.0;
|
||||
|
||||
void
|
||||
CocosQt5AudioBackend::cleanup()
|
||||
{
|
||||
foreach (QMediaPlayer *effect, effects.values()) {
|
||||
delete effect;
|
||||
}
|
||||
|
||||
if (background_music != NULL) {
|
||||
delete background_music;
|
||||
background_music = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CocosQt5AudioBackend::gcEffects()
|
||||
{
|
||||
foreach (int id, effects.keys()) {
|
||||
QMediaPlayer *effect = effects[id];
|
||||
if (effect->state() == QMediaPlayer::StoppedState) {
|
||||
delete effect;
|
||||
effects.remove(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Singleton object */
|
||||
static SimpleAudioEngine *
|
||||
simple_audio_engine = NULL;
|
||||
|
||||
|
||||
/**
|
||||
@brief Get the shared Engine object,it will new one when first time be called
|
||||
*/
|
||||
SimpleAudioEngine *
|
||||
SimpleAudioEngine::getInstance()
|
||||
{
|
||||
if (simple_audio_engine == NULL) {
|
||||
simple_audio_engine = new SimpleAudioEngine;
|
||||
}
|
||||
|
||||
return simple_audio_engine;
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Release the shared Engine object
|
||||
@warning It must be called before the application exit, or a memroy leak will be casued.
|
||||
*/
|
||||
void
|
||||
SimpleAudioEngine::end()
|
||||
{
|
||||
if (simple_audio_engine != NULL) {
|
||||
delete simple_audio_engine;
|
||||
simple_audio_engine = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SimpleAudioEngine::SimpleAudioEngine()
|
||||
{
|
||||
}
|
||||
|
||||
SimpleAudioEngine::~SimpleAudioEngine()
|
||||
{
|
||||
// Free sound effects and stop background music
|
||||
CocosQt5AudioBackend::cleanup();
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Preload background music
|
||||
@param pszFilePath The path of the background music file,or the FileName of T_SoundResInfo
|
||||
*/
|
||||
void
|
||||
SimpleAudioEngine::preloadBackgroundMusic(const char* pszFilePath)
|
||||
{
|
||||
QString filename = fullPath(pszFilePath);
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Play background music
|
||||
@param pszFilePath The path of the background music file,or the FileName of T_SoundResInfo
|
||||
@param bLoop Whether the background music loop or not
|
||||
*/
|
||||
void
|
||||
SimpleAudioEngine::playBackgroundMusic(const char* pszFilePath, bool bLoop)
|
||||
{
|
||||
QString filename = fullPath(pszFilePath);
|
||||
|
||||
CocosQt5AudioBackend::player()->setMedia(QUrl::fromLocalFile(filename));
|
||||
if (bLoop) {
|
||||
// TODO: Set QMediaPlayer to loop infinitely
|
||||
}
|
||||
CocosQt5AudioBackend::player()->play();
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Stop playing background music
|
||||
@param bReleaseData If release the background music data or not.As default value is false
|
||||
*/
|
||||
void
|
||||
SimpleAudioEngine::stopBackgroundMusic(bool bReleaseData)
|
||||
{
|
||||
CocosQt5AudioBackend::player()->stop();
|
||||
|
||||
if (bReleaseData) {
|
||||
CocosQt5AudioBackend::player()->setMedia(QMediaContent());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Pause playing background music
|
||||
*/
|
||||
void
|
||||
SimpleAudioEngine::pauseBackgroundMusic()
|
||||
{
|
||||
CocosQt5AudioBackend::player()->pause();
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Resume playing background music
|
||||
*/
|
||||
void
|
||||
SimpleAudioEngine::resumeBackgroundMusic()
|
||||
{
|
||||
CocosQt5AudioBackend::player()->play();
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Rewind playing background music
|
||||
*/
|
||||
void
|
||||
SimpleAudioEngine::rewindBackgroundMusic()
|
||||
{
|
||||
CocosQt5AudioBackend::player()->stop();
|
||||
CocosQt5AudioBackend::player()->setPosition(0);
|
||||
CocosQt5AudioBackend::player()->play();
|
||||
}
|
||||
|
||||
bool
|
||||
SimpleAudioEngine::willPlayBackgroundMusic()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Whether the background music is playing
|
||||
@return If is playing return true,or return false
|
||||
*/
|
||||
bool
|
||||
SimpleAudioEngine::isBackgroundMusicPlaying()
|
||||
{
|
||||
return (CocosQt5AudioBackend::player()->state() == QMediaPlayer::PlayingState);
|
||||
}
|
||||
|
||||
/**
|
||||
@brief The volume of the background music max value is 1.0,the min value is 0.0
|
||||
*/
|
||||
float
|
||||
SimpleAudioEngine::getBackgroundMusicVolume()
|
||||
{
|
||||
return (float)(CocosQt5AudioBackend::player()->volume()) / 100.;
|
||||
}
|
||||
|
||||
/**
|
||||
@brief set the volume of background music
|
||||
@param volume must be in 0.0~1.0
|
||||
*/
|
||||
void
|
||||
SimpleAudioEngine::setBackgroundMusicVolume(float volume)
|
||||
{
|
||||
CocosQt5AudioBackend::player()->setVolume(100. * volume);
|
||||
}
|
||||
|
||||
/**
|
||||
@brief The volume of the effects max value is 1.0,the min value is 0.0
|
||||
*/
|
||||
float
|
||||
SimpleAudioEngine::getEffectsVolume()
|
||||
{
|
||||
return CocosQt5AudioBackend::effects_volume;
|
||||
}
|
||||
|
||||
/**
|
||||
@brief set the volume of sound effecs
|
||||
@param volume must be in 0.0~1.0
|
||||
*/
|
||||
void
|
||||
SimpleAudioEngine::setEffectsVolume(float volume)
|
||||
{
|
||||
CocosQt5AudioBackend::setEffectsVolume(volume);
|
||||
}
|
||||
|
||||
// for sound effects
|
||||
/**
|
||||
@brief Play sound effect
|
||||
@param pszFilePath The path of the effect file,or the FileName of T_SoundResInfo
|
||||
@bLoop Whether to loop the effect playing, default value is false
|
||||
*/
|
||||
unsigned int
|
||||
SimpleAudioEngine::playEffect(const char* pszFilePath, bool bLoop,
|
||||
float pitch, float pan, float gain)
|
||||
{
|
||||
// TODO: Handle pitch, pan and gain
|
||||
|
||||
CocosQt5AudioBackend::gcEffects();
|
||||
|
||||
QString filename = fullPath(pszFilePath);
|
||||
int id = CocosQt5AudioBackend::next_effect_id++;
|
||||
|
||||
QMediaPlayer *effect = new QMediaPlayer;
|
||||
effect->setMedia(QUrl::fromLocalFile(filename));
|
||||
effect->setVolume(CocosQt5AudioBackend::effects_volume * 100.0);
|
||||
if (bLoop) {
|
||||
// TODO: Set QMediaPlayer to loop infinitely
|
||||
}
|
||||
effect->play();
|
||||
|
||||
CocosQt5AudioBackend::effects[id] = effect;
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Pause playing sound effect
|
||||
@param nSoundId The return value of function playEffect
|
||||
*/
|
||||
void
|
||||
SimpleAudioEngine::pauseEffect(unsigned int nSoundId)
|
||||
{
|
||||
if (CocosQt5AudioBackend::effects.contains(nSoundId)) {
|
||||
QMediaPlayer *effect = CocosQt5AudioBackend::effects[nSoundId];
|
||||
effect->pause();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Pause all playing sound effect
|
||||
@param nSoundId The return value of function playEffect
|
||||
*/
|
||||
void
|
||||
SimpleAudioEngine::pauseAllEffects()
|
||||
{
|
||||
foreach (QMediaPlayer *effect, CocosQt5AudioBackend::effects.values()) {
|
||||
effect->pause();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Resume playing sound effect
|
||||
@param nSoundId The return value of function playEffect
|
||||
*/
|
||||
void
|
||||
SimpleAudioEngine::resumeEffect(unsigned int nSoundId)
|
||||
{
|
||||
if (CocosQt5AudioBackend::effects.contains(nSoundId)) {
|
||||
QMediaPlayer *effect = CocosQt5AudioBackend::effects[nSoundId];
|
||||
effect->play();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Resume all playing sound effect
|
||||
@param nSoundId The return value of function playEffect
|
||||
*/
|
||||
void
|
||||
SimpleAudioEngine::resumeAllEffects()
|
||||
{
|
||||
foreach (QMediaPlayer *effect, CocosQt5AudioBackend::effects.values()) {
|
||||
if (effect->state() == QMediaPlayer::PausedState) {
|
||||
effect->play();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Stop playing sound effect
|
||||
@param nSoundId The return value of function playEffect
|
||||
*/
|
||||
void
|
||||
SimpleAudioEngine::stopEffect(unsigned int nSoundId)
|
||||
{
|
||||
if (CocosQt5AudioBackend::effects.contains(nSoundId)) {
|
||||
QMediaPlayer *effect = CocosQt5AudioBackend::effects[nSoundId];
|
||||
CocosQt5AudioBackend::effects.remove(nSoundId);
|
||||
delete effect;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Stop all playing sound effects
|
||||
*/
|
||||
void
|
||||
SimpleAudioEngine::stopAllEffects()
|
||||
{
|
||||
foreach (QMediaPlayer *effect, CocosQt5AudioBackend::effects.values()) {
|
||||
delete effect;
|
||||
}
|
||||
CocosQt5AudioBackend::effects.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
@brief preload a compressed audio file
|
||||
@details the compressed audio will be decode to wave, then write into an
|
||||
internal buffer in SimpleAudioEngine
|
||||
*/
|
||||
void
|
||||
SimpleAudioEngine::preloadEffect(const char* pszFilePath)
|
||||
{
|
||||
QString filename = fullPath(pszFilePath);
|
||||
}
|
||||
|
||||
/**
|
||||
@brief unload the preloaded effect from internal buffer
|
||||
@param[in] pszFilePath The path of the effect file,or the FileName of T_SoundResInfo
|
||||
*/
|
||||
void
|
||||
SimpleAudioEngine::unloadEffect(const char* pszFilePath)
|
||||
{
|
||||
QString filename = fullPath(pszFilePath);
|
||||
}
|
||||
|
||||
} /* end namespace CocosDenshion */
|
|
@ -1 +1 @@
|
|||
d6cb125483788e2a19f66deb9325a6cd6ab80a55
|
||||
284c141f06b30a68b05f7ace8caf5502105b4a1a
|
|
@ -0,0 +1,19 @@
|
|||
|
||||
TEMPLATE = subdirs
|
||||
|
||||
CONFIG += ordered
|
||||
|
||||
# Cocos2D-X Core Library
|
||||
SUBDIRS += external/chipmunk/proj.qt5/chipmunk.pro
|
||||
SUBDIRS += external/Box2D/proj.qt5/box2d.pro
|
||||
SUBDIRS += cocos2dx/proj.qt5/cocos2dx.pro
|
||||
|
||||
# Cocos2D-X Additional Libraries
|
||||
SUBDIRS += CocosDenshion/proj.qt5/cocosdenshion.pro
|
||||
SUBDIRS += extensions/proj.qt5/extensions.pro
|
||||
|
||||
# Examples
|
||||
SUBDIRS += samples/Cpp/HelloCpp/proj.qt5/HelloCpp.pro
|
||||
SUBDIRS += samples/Cpp/SimpleGame/proj.qt5/SimpleGame.pro
|
||||
SUBDIRS += samples/Cpp/TestCpp/proj.qt5/TestCpp.pro
|
||||
|
|
@ -47,21 +47,6 @@ const Color3B ccGRAY = Color3B::GRAY;
|
|||
|
||||
const BlendFunc kCCBlendFuncDisable = BlendFunc::DISABLE;
|
||||
|
||||
const int kCCVertexAttrib_Position = GLProgram::VERTEX_ATTRIB_POSITION;
|
||||
const int kCCVertexAttrib_Color = GLProgram::VERTEX_ATTRIB_COLOR;
|
||||
const int kCCVertexAttrib_TexCoords = GLProgram::VERTEX_ATTRIB_TEX_COORDS;
|
||||
const int kCCVertexAttrib_MAX = GLProgram::VERTEX_ATTRIB_MAX;
|
||||
|
||||
const int kCCUniformPMatrix = GLProgram::UNIFORM_P_MATRIX;
|
||||
const int kCCUniformMVMatrix = GLProgram::UNIFORM_MV_MATRIX;
|
||||
const int kCCUniformMVPMatrix = GLProgram::UNIFORM_MVP_MATRIX;
|
||||
const int kCCUniformTime = GLProgram::UNIFORM_TIME;
|
||||
const int kCCUniformSinTime = GLProgram::UNIFORM_SIN_TIME;
|
||||
const int kCCUniformCosTime = GLProgram::UNIFORM_COS_TIME;
|
||||
const int kCCUniformRandom01 = GLProgram::UNIFORM_RANDOM01;
|
||||
const int kCCUniformSampler = GLProgram::UNIFORM_SAMPLER;
|
||||
const int kCCUniform_MAX = GLProgram::UNIFORM_MAX;
|
||||
|
||||
const char* kCCShader_PositionTextureColor = GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR;
|
||||
const char* kCCShader_PositionTextureColorAlphaTest = GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST;
|
||||
const char* kCCShader_PositionColor = GLProgram::SHADER_NAME_POSITION_COLOR;
|
||||
|
@ -87,81 +72,6 @@ const char* kCCAttributeNameColor = GLProgram::ATTRIBUTE_NAME_COLOR;
|
|||
const char* kCCAttributeNamePosition = GLProgram::ATTRIBUTE_NAME_POSITION;
|
||||
const char* kCCAttributeNameTexCoord = GLProgram::ATTRIBUTE_NAME_TEX_COORD;
|
||||
|
||||
const int kCCVertexAttribFlag_None = GL::VERTEX_ATTRIB_FLAT_NONE;
|
||||
const int kCCVertexAttribFlag_Position = GL::VERTEX_ATTRIB_FLAG_POSITION;
|
||||
const int kCCVertexAttribFlag_Color = GL::VERTEX_ATTRIB_FLAG_COLOR;
|
||||
const int kCCVertexAttribFlag_TexCoords = GL::VERTEX_ATTRIB_FLAG_TEX_COORDS;
|
||||
const int kCCVertexAttribFlag_PosColorTex = GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX;
|
||||
|
||||
const int kCCProgressTimerTypeRadial = ProgressTimer::RADIAL;
|
||||
const int kCCProgressTimerTypeBar = ProgressTimer::BAR;
|
||||
|
||||
const Director::Projection kCCDirectorProjection2D = Director::Projection::_2D;
|
||||
const Director::Projection kCCDirectorProjection3D = Director::Projection::_3D;
|
||||
const Director::Projection kCCDirectorProjectionCustom = Director::Projection::CUSTOM;
|
||||
const Director::Projection kCCDirectorProjectionDefault = Director::Projection::DEFAULT;
|
||||
|
||||
const int kCCParticleDurationInfinity = ParticleSystem::DURATION_INFINITY;
|
||||
const int kCCParticleStartSizeEqualToEndSize = ParticleSystem::START_SIZE_EQUAL_TO_END_SIZE;
|
||||
const int kCCParticleStartRadiusEqualToEndRadius = ParticleSystem::START_RADIUS_EQUAL_TO_END_RADIUS;
|
||||
|
||||
const ParticleSystem::Mode kCCParticleModeGravity = ParticleSystem::Mode::GRAVITY;
|
||||
const ParticleSystem::Mode kCCParticleModeRadius = ParticleSystem::Mode::RADIUS;
|
||||
const int kCCParticleDefaultCapacity = kParticleDefaultCapacity;
|
||||
|
||||
const ParticleSystem::PositionType kCCPositionTypeFree = ParticleSystem::PositionType::FREE;
|
||||
const ParticleSystem::PositionType kCCPositionTypeRelative = ParticleSystem::PositionType::RELATIVE;
|
||||
const ParticleSystem::PositionType kCCPositionTypeGrouped = ParticleSystem::PositionType::GROUPED;
|
||||
|
||||
const Label::VAlignment kCCVerticalTextAlignmentTop = Label::VAlignment::TOP;
|
||||
const Label::VAlignment kCCVerticalTextAlignmentCenter = Label::VAlignment::CENTER;
|
||||
const Label::VAlignment kCCVerticalTextAlignmentBottom = Label::VAlignment::BOTTOM;
|
||||
|
||||
const Label::HAlignment kCCTextAlignmentLeft = Label::HAlignment::LEFT;
|
||||
const Label::HAlignment kCCTextAlignmentCenter = Label::HAlignment::CENTER;
|
||||
const Label::HAlignment kCCTextAlignmentRight = Label::HAlignment::RIGHT;
|
||||
|
||||
const Texture2D::PixelFormat kCCTexture2DPixelFormat_RGBA8888 = Texture2D::PixelFormat::RGBA8888;
|
||||
const Texture2D::PixelFormat kCCTexture2DPixelFormat_RGB888 = Texture2D::PixelFormat::RGB888;
|
||||
const Texture2D::PixelFormat kCCTexture2DPixelFormat_RGB565 = Texture2D::PixelFormat::RGB565;
|
||||
const Texture2D::PixelFormat kCCTexture2DPixelFormat_A8 = Texture2D::PixelFormat::A8;
|
||||
const Texture2D::PixelFormat kCCTexture2DPixelFormat_I8 = Texture2D::PixelFormat::I8;
|
||||
const Texture2D::PixelFormat kCCTexture2DPixelFormat_AI88 = Texture2D::PixelFormat::AI88;
|
||||
const Texture2D::PixelFormat kCCTexture2DPixelFormat_RGBA4444 = Texture2D::PixelFormat::RGBA4444;
|
||||
const Texture2D::PixelFormat kCCTexture2DPixelFormat_RGB5A1 = Texture2D::PixelFormat::RGB5A1;
|
||||
const Texture2D::PixelFormat kCCTexture2DPixelFormat_PVRTC4 = Texture2D::PixelFormat::PVRTC4;
|
||||
const Texture2D::PixelFormat kCCTexture2DPixelFormat_PVRTC2 = Texture2D::PixelFormat::PVRTC2;
|
||||
const Texture2D::PixelFormat kCCTexture2DPixelFormat_Default = Texture2D::PixelFormat::DEFAULT;
|
||||
|
||||
const int kCCMenuHandlerPriority = Menu::HANDLER_PRIORITY;
|
||||
const Menu::State kCCMenuStateWaiting = Menu::State::WAITING;
|
||||
const Menu::State kCCMenuStateTrackingTouch = Menu::State::TRACKING_TOUCH;
|
||||
|
||||
const Touch::DispatchMode kCCTouchesOneByOne = Touch::DispatchMode::ONE_BY_ONE;
|
||||
const Touch::DispatchMode kCCTouchesAllAtOnce = Touch::DispatchMode::ALL_AT_ONCE;
|
||||
|
||||
const Image::Format kCCImageFormatPNG = Image::Format::PNG;
|
||||
const Image::Format kCCImageFormatJPEG = Image::Format::JPG;
|
||||
|
||||
const TransitionScene::Orientation kCCTransitionOrientationLeftOver = TransitionScene::Orientation::LEFT_OVER;
|
||||
const TransitionScene::Orientation kCCTransitionOrientationRightOver = TransitionScene::Orientation::RIGHT_OVER;
|
||||
const TransitionScene::Orientation kCCTransitionOrientationUpOver = TransitionScene::Orientation::UP_OVER;
|
||||
const TransitionScene::Orientation kCCTransitionOrientationDownOver = TransitionScene::Orientation::DOWN_OVER;
|
||||
|
||||
const int kCCPrioritySystem = Scheduler::PRIORITY_SYSTEM;
|
||||
const int kCCPriorityNonSystemMin = Scheduler::PRIORITY_NON_SYSTEM_MIN;
|
||||
|
||||
const int kCCActionTagInvalid = kActionTagInvalid;
|
||||
|
||||
const int kCCNodeTagInvalid = kNodeTagInvalid;
|
||||
|
||||
const int kCCNodeOnEnter = kNodeOnEnter;
|
||||
const int kCCNodeOnExit = kNodeOnExit;
|
||||
const int kCCNodeOnEnterTransitionDidFinish = kNodeOnEnterTransitionDidFinish;
|
||||
const int kCCNodeOnExitTransitionDidStart = kNodeOnExitTransitionDidStart;
|
||||
const int kCCNodeOnCleanup = kNodeOnCleanup;
|
||||
|
||||
|
||||
void ccDrawInit()
|
||||
{
|
||||
DrawPrimitives::init();
|
||||
|
@ -262,4 +172,4 @@ void ccPointSize( GLfloat pointSize )
|
|||
DrawPrimitives::setPointSize(pointSize);
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
NS_CC_END
|
||||
|
|
|
@ -224,9 +224,9 @@ public:
|
|||
*
|
||||
* The deafult value is 1.0 if you haven't changed it before
|
||||
*
|
||||
* @param fScaleX The scale factor on X axis.
|
||||
* @param scaleX The scale factor on X axis.
|
||||
*/
|
||||
virtual void setScaleX(float fScaleX);
|
||||
virtual void setScaleX(float scaleX);
|
||||
/**
|
||||
* Returns the scale factor on X axis of this node
|
||||
*
|
||||
|
@ -242,9 +242,9 @@ public:
|
|||
*
|
||||
* The Default value is 1.0 if you haven't changed it before.
|
||||
*
|
||||
* @param fScaleY The scale factor on Y axis.
|
||||
* @param scaleY The scale factor on Y axis.
|
||||
*/
|
||||
virtual void setScaleY(float fScaleY);
|
||||
virtual void setScaleY(float scaleY);
|
||||
/**
|
||||
* Returns the scale factor on Y axis of this node
|
||||
*
|
||||
|
|
|
@ -810,20 +810,20 @@ CC_DEPRECATED_ATTRIBUTE typedef ProgressTimer::Type CCProgressTimerType;
|
|||
|
||||
CC_DEPRECATED_ATTRIBUTE typedef void* CCZone;
|
||||
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCVertexAttrib_Position;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCVertexAttrib_Color;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCVertexAttrib_TexCoords;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCVertexAttrib_MAX;
|
||||
CC_DEPRECATED_ATTRIBUTE const int kCCVertexAttrib_Position = GLProgram::VERTEX_ATTRIB_POSITION;
|
||||
CC_DEPRECATED_ATTRIBUTE const int kCCVertexAttrib_Color = GLProgram::VERTEX_ATTRIB_COLOR;
|
||||
CC_DEPRECATED_ATTRIBUTE const int kCCVertexAttrib_TexCoords = GLProgram::VERTEX_ATTRIB_TEX_COORDS;
|
||||
CC_DEPRECATED_ATTRIBUTE const int kCCVertexAttrib_MAX = GLProgram::VERTEX_ATTRIB_MAX;
|
||||
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCUniformPMatrix;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCUniformMVMatrix;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCUniformMVPMatrix;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCUniformTime;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCUniformSinTime;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCUniformCosTime;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCUniformRandom01;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCUniformSampler;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCUniform_MAX;
|
||||
CC_DEPRECATED_ATTRIBUTE const int kCCUniformPMatrix = GLProgram::UNIFORM_P_MATRIX;
|
||||
CC_DEPRECATED_ATTRIBUTE const int kCCUniformMVMatrix = GLProgram::UNIFORM_MV_MATRIX;
|
||||
CC_DEPRECATED_ATTRIBUTE const int kCCUniformMVPMatrix = GLProgram::UNIFORM_MVP_MATRIX;
|
||||
CC_DEPRECATED_ATTRIBUTE const int kCCUniformTime = GLProgram::UNIFORM_TIME;
|
||||
CC_DEPRECATED_ATTRIBUTE const int kCCUniformSinTime = GLProgram::UNIFORM_SIN_TIME;
|
||||
CC_DEPRECATED_ATTRIBUTE const int kCCUniformCosTime = GLProgram::UNIFORM_COS_TIME;
|
||||
CC_DEPRECATED_ATTRIBUTE const int kCCUniformRandom01 = GLProgram::UNIFORM_RANDOM01;
|
||||
CC_DEPRECATED_ATTRIBUTE const int kCCUniformSampler = GLProgram::UNIFORM_SAMPLER;
|
||||
CC_DEPRECATED_ATTRIBUTE const int kCCUniform_MAX = GLProgram::UNIFORM_MAX;
|
||||
|
||||
CC_DEPRECATED_ATTRIBUTE extern const char* kCCShader_PositionTextureColor;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const char* kCCShader_PositionTextureColorAlphaTest;
|
||||
|
@ -850,91 +850,137 @@ CC_DEPRECATED_ATTRIBUTE extern const char* kCCAttributeNameColor;
|
|||
CC_DEPRECATED_ATTRIBUTE extern const char* kCCAttributeNamePosition;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const char* kCCAttributeNameTexCoord;
|
||||
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCVertexAttribFlag_None;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCVertexAttribFlag_Position;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCVertexAttribFlag_Color;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCVertexAttribFlag_TexCoords;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCVertexAttribFlag_PosColorTex;
|
||||
CC_DEPRECATED_ATTRIBUTE const int kCCVertexAttribFlag_None = GL::VERTEX_ATTRIB_FLAT_NONE;
|
||||
CC_DEPRECATED_ATTRIBUTE const int kCCVertexAttribFlag_Position = GL::VERTEX_ATTRIB_FLAG_POSITION;
|
||||
CC_DEPRECATED_ATTRIBUTE const int kCCVertexAttribFlag_Color = GL::VERTEX_ATTRIB_FLAG_COLOR;
|
||||
CC_DEPRECATED_ATTRIBUTE const int kCCVertexAttribFlag_TexCoords = GL::VERTEX_ATTRIB_FLAG_TEX_COORDS;
|
||||
CC_DEPRECATED_ATTRIBUTE const int kCCVertexAttribFlag_PosColorTex = GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX;
|
||||
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCProgressTimerTypeRadial;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCProgressTimerTypeBar;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef enum ProgressTimer::Type ProgressTimerType;
|
||||
CC_DEPRECATED_ATTRIBUTE const ProgressTimer::Type kCCProgressTimerTypeRadial = ProgressTimer::Type::RADIAL;
|
||||
CC_DEPRECATED_ATTRIBUTE const ProgressTimer::Type kCCProgressTimerTypeBar = ProgressTimer::Type::BAR;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef ProgressTimer::Type ProgressTimerType;
|
||||
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Director::Projection kCCDirectorProjection2D;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Director::Projection kCCDirectorProjection3D;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Director::Projection kCCDirectorProjectionCustom;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Director::Projection kCCDirectorProjectionDefault;
|
||||
CC_DEPRECATED_ATTRIBUTE const Director::Projection kCCDirectorProjection2D = Director::Projection::_2D;
|
||||
CC_DEPRECATED_ATTRIBUTE const Director::Projection kCCDirectorProjection3D = Director::Projection::_3D;
|
||||
CC_DEPRECATED_ATTRIBUTE const Director::Projection kCCDirectorProjectionCustom = Director::Projection::CUSTOM;
|
||||
CC_DEPRECATED_ATTRIBUTE const Director::Projection kCCDirectorProjectionDefault = Director::Projection::DEFAULT;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef Director::Projection ccDirectorProjection;
|
||||
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Label::VAlignment kCCVerticalTextAlignmentTop;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Label::VAlignment kCCVerticalTextAlignmentCenter;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Label::VAlignment kCCVerticalTextAlignmentBottom;
|
||||
CC_DEPRECATED_ATTRIBUTE const Label::VAlignment kCCVerticalTextAlignmentTop = Label::VAlignment::TOP;
|
||||
CC_DEPRECATED_ATTRIBUTE const Label::VAlignment kCCVerticalTextAlignmentCenter = Label::VAlignment::CENTER;
|
||||
CC_DEPRECATED_ATTRIBUTE const Label::VAlignment kCCVerticalTextAlignmentBottom = Label::VAlignment::BOTTOM;
|
||||
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Label::HAlignment kCCTextAlignmentLeft;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Label::HAlignment kCCTextAlignmentCenter;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Label::HAlignment kCCTextAlignmentRight;
|
||||
CC_DEPRECATED_ATTRIBUTE const Label::HAlignment kCCTextAlignmentLeft = Label::HAlignment::LEFT;
|
||||
CC_DEPRECATED_ATTRIBUTE const Label::HAlignment kCCTextAlignmentCenter = Label::HAlignment::CENTER;
|
||||
CC_DEPRECATED_ATTRIBUTE const Label::HAlignment kCCTextAlignmentRight = Label::HAlignment::RIGHT;
|
||||
|
||||
CC_DEPRECATED_ATTRIBUTE const Texture2D::PixelFormat kCCTexture2DPixelFormat_RGBA8888 = Texture2D::PixelFormat::RGBA8888;
|
||||
CC_DEPRECATED_ATTRIBUTE const Texture2D::PixelFormat kCCTexture2DPixelFormat_RGB888 = Texture2D::PixelFormat::RGB888;
|
||||
CC_DEPRECATED_ATTRIBUTE const Texture2D::PixelFormat kCCTexture2DPixelFormat_RGB565 = Texture2D::PixelFormat::RGB565;
|
||||
CC_DEPRECATED_ATTRIBUTE const Texture2D::PixelFormat kCCTexture2DPixelFormat_A8 = Texture2D::PixelFormat::A8;
|
||||
CC_DEPRECATED_ATTRIBUTE const Texture2D::PixelFormat kCCTexture2DPixelFormat_I8 = Texture2D::PixelFormat::I8;
|
||||
CC_DEPRECATED_ATTRIBUTE const Texture2D::PixelFormat kCCTexture2DPixelFormat_AI88 = Texture2D::PixelFormat::AI88;
|
||||
CC_DEPRECATED_ATTRIBUTE const Texture2D::PixelFormat kCCTexture2DPixelFormat_RGBA4444 = Texture2D::PixelFormat::RGBA4444;
|
||||
CC_DEPRECATED_ATTRIBUTE const Texture2D::PixelFormat kCCTexture2DPixelFormat_RGB5A1 = Texture2D::PixelFormat::RGB5A1;
|
||||
CC_DEPRECATED_ATTRIBUTE const Texture2D::PixelFormat kCCTexture2DPixelFormat_PVRTC4 = Texture2D::PixelFormat::PVRTC4;
|
||||
CC_DEPRECATED_ATTRIBUTE const Texture2D::PixelFormat kCCTexture2DPixelFormat_PVRTC2 = Texture2D::PixelFormat::PVRTC2;
|
||||
CC_DEPRECATED_ATTRIBUTE const Texture2D::PixelFormat kCCTexture2DPixelFormat_Default = Texture2D::PixelFormat::DEFAULT;
|
||||
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Texture2D::PixelFormat kCCTexture2DPixelFormat_RGBA8888;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Texture2D::PixelFormat kCCTexture2DPixelFormat_RGB888;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Texture2D::PixelFormat kCCTexture2DPixelFormat_RGB565;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Texture2D::PixelFormat kCCTexture2DPixelFormat_A8;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Texture2D::PixelFormat kCCTexture2DPixelFormat_I8;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Texture2D::PixelFormat kCCTexture2DPixelFormat_AI88;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Texture2D::PixelFormat kCCTexture2DPixelFormat_RGBA4444;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Texture2D::PixelFormat kCCTexture2DPixelFormat_RGB5A1;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Texture2D::PixelFormat kCCTexture2DPixelFormat_PVRTC4;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Texture2D::PixelFormat kCCTexture2DPixelFormat_PVRTC2;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Texture2D::PixelFormat kCCTexture2DPixelFormat_Default;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef Texture2D::PixelFormat CCTexture2DPixelFormat;
|
||||
|
||||
|
||||
CC_DEPRECATED_ATTRIBUTE const int kCCParticleDurationInfinity = ParticleSystem::DURATION_INFINITY;
|
||||
CC_DEPRECATED_ATTRIBUTE const int kCCParticleStartSizeEqualToEndSize = ParticleSystem::START_SIZE_EQUAL_TO_END_SIZE;
|
||||
CC_DEPRECATED_ATTRIBUTE const int kCCParticleStartRadiusEqualToEndRadius = ParticleSystem::START_RADIUS_EQUAL_TO_END_RADIUS;
|
||||
|
||||
CC_DEPRECATED_ATTRIBUTE const int kParticleDurationInfinity = ParticleSystem::DURATION_INFINITY;
|
||||
CC_DEPRECATED_ATTRIBUTE const int kParticleStartSizeEqualToEndSize = ParticleSystem::START_SIZE_EQUAL_TO_END_SIZE;
|
||||
CC_DEPRECATED_ATTRIBUTE const int kParticleStartRadiusEqualToEndRadius = ParticleSystem::START_RADIUS_EQUAL_TO_END_RADIUS;
|
||||
|
||||
CC_DEPRECATED_ATTRIBUTE const ParticleSystem::Mode kCCParticleModeGravity = ParticleSystem::Mode::GRAVITY;
|
||||
CC_DEPRECATED_ATTRIBUTE const ParticleSystem::Mode kCCParticleModeRadius = ParticleSystem::Mode::RADIUS;
|
||||
CC_DEPRECATED_ATTRIBUTE const int kCCParticleDefaultCapacity = kParticleDefaultCapacity;
|
||||
|
||||
CC_DEPRECATED_ATTRIBUTE const ParticleSystem::PositionType kCCPositionTypeFree = ParticleSystem::PositionType::FREE;
|
||||
CC_DEPRECATED_ATTRIBUTE const ParticleSystem::PositionType kCCPositionTypeRelative = ParticleSystem::PositionType::RELATIVE;
|
||||
CC_DEPRECATED_ATTRIBUTE const ParticleSystem::PositionType kCCPositionTypeGrouped = ParticleSystem::PositionType::GROUPED;
|
||||
|
||||
CC_DEPRECATED_ATTRIBUTE typedef ParticleSystem::PositionType tPositionType;
|
||||
|
||||
#define kCCLabelAutomaticWidth kLabelAutomaticWidth
|
||||
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCParticleDurationInfinity;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCParticleStartSizeEqualToEndSize;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCParticleStartRadiusEqualToEndRadius;
|
||||
|
||||
CC_DEPRECATED_ATTRIBUTE extern const ParticleSystem::Mode kCCParticleModeGravity;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const ParticleSystem::Mode kCCParticleModeRadius;
|
||||
CC_DEPRECATED_ATTRIBUTE const int kCCMenuHandlerPriority = Menu::HANDLER_PRIORITY;
|
||||
CC_DEPRECATED_ATTRIBUTE const Menu::State kCCMenuStateWaiting = Menu::State::WAITING;
|
||||
CC_DEPRECATED_ATTRIBUTE const Menu::State kCCMenuStateTrackingTouch = Menu::State::TRACKING_TOUCH;
|
||||
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCParticleDefaultCapacity;
|
||||
|
||||
CC_DEPRECATED_ATTRIBUTE extern const ParticleSystem::PositionType kCCPositionTypeFree;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const ParticleSystem::PositionType kCCPositionTypeRelative;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const ParticleSystem::PositionType kCCPositionTypeGrouped;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef ParticleSystem::PositionType tPositionType;
|
||||
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCMenuHandlerPriority;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Menu::State kCCMenuStateWaiting;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Menu::State kCCMenuStateTrackingTouch;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef Menu::State tMenuState;
|
||||
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Touch::DispatchMode kCCTouchesOneByOne;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Touch::DispatchMode kCCTouchesAllAtOnce;
|
||||
CC_DEPRECATED_ATTRIBUTE const Touch::DispatchMode kCCTouchesOneByOne = Touch::DispatchMode::ONE_BY_ONE;
|
||||
CC_DEPRECATED_ATTRIBUTE const Touch::DispatchMode kCCTouchesAllAtOnce = Touch::DispatchMode::ALL_AT_ONCE;
|
||||
|
||||
CC_DEPRECATED_ATTRIBUTE typedef Touch::DispatchMode ccTouchesMode;
|
||||
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Image::Format kCCImageFormatPNG;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Image::Format kCCImageFormatJPEG;
|
||||
CC_DEPRECATED_ATTRIBUTE const Image::Format kCCImageFormatPNG = Image::Format::PNG;
|
||||
CC_DEPRECATED_ATTRIBUTE const Image::Format kCCImageFormatJPEG = Image::Format::JPG;
|
||||
|
||||
CC_DEPRECATED_ATTRIBUTE typedef Image::Format tImageFormat;
|
||||
|
||||
CC_DEPRECATED_ATTRIBUTE extern const TransitionScene::Orientation kCCTransitionOrientationLeftOver;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const TransitionScene::Orientation kCCTransitionOrientationRightOver;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const TransitionScene::Orientation kCCTransitionOrientationUpOver;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const TransitionScene::Orientation kCCTransitionOrientationDownOver;
|
||||
CC_DEPRECATED_ATTRIBUTE const TransitionScene::Orientation kCCTransitionOrientationLeftOver = TransitionScene::Orientation::LEFT_OVER;
|
||||
CC_DEPRECATED_ATTRIBUTE const TransitionScene::Orientation kCCTransitionOrientationRightOver = TransitionScene::Orientation::RIGHT_OVER;
|
||||
CC_DEPRECATED_ATTRIBUTE const TransitionScene::Orientation kCCTransitionOrientationUpOver = TransitionScene::Orientation::UP_OVER;
|
||||
CC_DEPRECATED_ATTRIBUTE const TransitionScene::Orientation kCCTransitionOrientationDownOver = TransitionScene::Orientation::DOWN_OVER;
|
||||
|
||||
CC_DEPRECATED_ATTRIBUTE typedef TransitionScene::Orientation tOrientation;
|
||||
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCPrioritySystem;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCPriorityNonSystemMin;
|
||||
CC_DEPRECATED_ATTRIBUTE const int kCCPrioritySystem = Scheduler::PRIORITY_SYSTEM;
|
||||
CC_DEPRECATED_ATTRIBUTE const int kCCPriorityNonSystemMin = Scheduler::PRIORITY_NON_SYSTEM_MIN;
|
||||
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCActionTagInvalid;
|
||||
CC_DEPRECATED_ATTRIBUTE const int kCCActionTagInvalid = kActionTagInvalid;
|
||||
CC_DEPRECATED_ATTRIBUTE const int kCCNodeTagInvalid = kNodeTagInvalid;
|
||||
|
||||
CC_DEPRECATED_ATTRIBUTE const int kCCNodeOnEnter = kNodeOnEnter;
|
||||
CC_DEPRECATED_ATTRIBUTE const int kCCNodeOnExit = kNodeOnExit;
|
||||
CC_DEPRECATED_ATTRIBUTE const int kCCNodeOnEnterTransitionDidFinish = kNodeOnEnterTransitionDidFinish;
|
||||
CC_DEPRECATED_ATTRIBUTE const int kCCNodeOnExitTransitionDidStart = kNodeOnExitTransitionDidStart;
|
||||
CC_DEPRECATED_ATTRIBUTE const int kCCNodeOnCleanup = kNodeOnCleanup;
|
||||
|
||||
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCNodeTagInvalid;
|
||||
CC_DEPRECATED_ATTRIBUTE const LanguageType kLanguageEnglish = LanguageType::ENGLISH;
|
||||
CC_DEPRECATED_ATTRIBUTE const LanguageType kLanguageChinese = LanguageType::CHINESE;
|
||||
CC_DEPRECATED_ATTRIBUTE const LanguageType kLanguageFrench = LanguageType::FRENCH;
|
||||
CC_DEPRECATED_ATTRIBUTE const LanguageType kLanguageItalian = LanguageType::ITALIAN;
|
||||
CC_DEPRECATED_ATTRIBUTE const LanguageType kLanguageGerman = LanguageType::GERMAN;
|
||||
CC_DEPRECATED_ATTRIBUTE const LanguageType kLanguageSpanish = LanguageType::SPANISH;
|
||||
CC_DEPRECATED_ATTRIBUTE const LanguageType kLanguageRussian = LanguageType::RUSSIAN;
|
||||
CC_DEPRECATED_ATTRIBUTE const LanguageType kLanguageKorean = LanguageType::KOREAN;
|
||||
CC_DEPRECATED_ATTRIBUTE const LanguageType kLanguageJapanese = LanguageType::JAPANESE;
|
||||
CC_DEPRECATED_ATTRIBUTE const LanguageType kLanguageHungarian = LanguageType::HUNGARIAN;
|
||||
CC_DEPRECATED_ATTRIBUTE const LanguageType kLanguagePortuguese = LanguageType::PORTUGUESE;
|
||||
CC_DEPRECATED_ATTRIBUTE const LanguageType kLanguageArabic = LanguageType::ARABIC;
|
||||
CC_DEPRECATED_ATTRIBUTE const LanguageType kLanguageNorwegian = LanguageType::NORWEGIAN;
|
||||
CC_DEPRECATED_ATTRIBUTE const LanguageType kLanguagePolish = LanguageType::POLISH;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef LanguageType ccLanguageType;
|
||||
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCNodeOnEnter;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCNodeOnExit;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCNodeOnEnterTransitionDidFinish;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCNodeOnExitTransitionDidStart;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCNodeOnCleanup;
|
||||
|
||||
CC_DEPRECATED_ATTRIBUTE const Application::Platform kTargetWindows = Application::Platform::OS_WINDOWS;
|
||||
CC_DEPRECATED_ATTRIBUTE const Application::Platform kTargetLinux = Application::Platform::OS_LINUX;
|
||||
CC_DEPRECATED_ATTRIBUTE const Application::Platform kTargetMacOS = Application::Platform::OS_MAC;
|
||||
CC_DEPRECATED_ATTRIBUTE const Application::Platform kTargetAndroid = Application::Platform::OS_ANDROID;
|
||||
CC_DEPRECATED_ATTRIBUTE const Application::Platform kTargetIphone = Application::Platform::OS_IPHONE;
|
||||
CC_DEPRECATED_ATTRIBUTE const Application::Platform kTargetIpad = Application::Platform::OS_IPAD;
|
||||
CC_DEPRECATED_ATTRIBUTE const Application::Platform kTargetBlackBerry = Application::Platform::OS_BLACKBERRY;
|
||||
CC_DEPRECATED_ATTRIBUTE const Application::Platform kTargetNaCl = Application::Platform::OS_NACL;
|
||||
CC_DEPRECATED_ATTRIBUTE const Application::Platform kTargetEmscripten = Application::Platform::OS_EMSCRIPTEN;
|
||||
CC_DEPRECATED_ATTRIBUTE const Application::Platform kTargetTizen = Application::Platform::OS_TIZEN;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef Application::Platform TargetPlatform;
|
||||
|
||||
CC_DEPRECATED_ATTRIBUTE const ResolutionPolicy kResolutionExactFit = ResolutionPolicy::EXACT_FIT;
|
||||
CC_DEPRECATED_ATTRIBUTE const ResolutionPolicy kResolutionNoBorder = ResolutionPolicy::NO_BORDER;
|
||||
CC_DEPRECATED_ATTRIBUTE const ResolutionPolicy kResolutionShowAll = ResolutionPolicy::SHOW_ALL;
|
||||
CC_DEPRECATED_ATTRIBUTE const ResolutionPolicy kResolutionFixedHeight = ResolutionPolicy::FIXED_HEIGHT;
|
||||
CC_DEPRECATED_ATTRIBUTE const ResolutionPolicy kResolutionFixedWidth = ResolutionPolicy::FIXED_WIDTH;
|
||||
CC_DEPRECATED_ATTRIBUTE const ResolutionPolicy kResolutionUnKnown = ResolutionPolicy::UNKNOWN;
|
||||
|
||||
|
||||
#define kCCTMXTileHorizontalFlag kTMXTileHorizontalFlag
|
||||
|
|
|
@ -215,6 +215,14 @@ THE SOFTWARE.
|
|||
#include "platform/tizen/CCStdC.h"
|
||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_TIZEN
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_QT5)
|
||||
#include "platform/qt5/CCAccelerometer.h"
|
||||
#include "platform/qt5/CCApplication.h"
|
||||
#include "platform/qt5/CCEGLView.h"
|
||||
#include "platform/qt5/CCGL.h"
|
||||
#include "platform/qt5/CCStdC.h"
|
||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_QT5
|
||||
|
||||
// script_support
|
||||
#include "script_support/CCScriptSupport.h"
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#define __NEON_MATRIX_IMPL_H__
|
||||
|
||||
#ifdef __arm__
|
||||
#if defined(__QNX__) || defined(ANDROID) || defined(I3D_ARCH_ARM) || defined(__native_client__) || defined(TIZEN) // MARMALADE CHANGE: Added for Marmalade support
|
||||
#if defined(__QNX__) || defined(CC_TARGET_QT5)|| defined(ANDROID) || defined(I3D_ARCH_ARM) || defined(__native_client__) || defined(TIZEN) // MARMALADE CHANGE: Added for Marmalade support
|
||||
// blackberry and android don't have arm/arch.h but it defines __arm__
|
||||
#else
|
||||
#include "arm/arch.h"
|
||||
|
|
|
@ -49,6 +49,7 @@ Layer::Layer()
|
|||
, _keypadEnabled(false)
|
||||
, _touchPriority(0)
|
||||
, _touchMode(Touch::DispatchMode::ALL_AT_ONCE)
|
||||
, _swallowsTouches(true)
|
||||
{
|
||||
_ignoreAnchorPointForPosition = true;
|
||||
setAnchorPoint(Point(0.5f, 0.5f));
|
||||
|
@ -99,7 +100,7 @@ void Layer::registerWithTouchDispatcher()
|
|||
if( _touchMode == Touch::DispatchMode::ALL_AT_ONCE ) {
|
||||
pDispatcher->addStandardDelegate(this, 0);
|
||||
} else {
|
||||
pDispatcher->addTargetedDelegate(this, _touchPriority, true);
|
||||
pDispatcher->addTargetedDelegate(this, _touchPriority, _swallowsTouches);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -183,6 +184,21 @@ void Layer::setTouchPriority(int priority)
|
|||
}
|
||||
}
|
||||
|
||||
void Layer::setSwallowsTouches(bool swallowsTouches)
|
||||
{
|
||||
if (_swallowsTouches != swallowsTouches)
|
||||
{
|
||||
_swallowsTouches = swallowsTouches;
|
||||
|
||||
if( _touchEnabled)
|
||||
{
|
||||
setTouchEnabled(false);
|
||||
setTouchEnabled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int Layer::getTouchPriority() const
|
||||
{
|
||||
return _touchPriority;
|
||||
|
@ -193,6 +209,13 @@ Touch::DispatchMode Layer::getTouchMode() const
|
|||
return _touchMode;
|
||||
}
|
||||
|
||||
bool Layer::isSwallowsTouches() const
|
||||
{
|
||||
return _swallowsTouches;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// isAccelerometerEnabled getter
|
||||
bool Layer::isAccelerometerEnabled() const
|
||||
{
|
||||
|
|
|
@ -105,6 +105,10 @@ public:
|
|||
virtual void setTouchPriority(int priority);
|
||||
virtual int getTouchPriority() const;
|
||||
|
||||
/** swallowsTouches of the touch events. Default is true */
|
||||
virtual void setSwallowsTouches(bool swallowsTouches);
|
||||
virtual bool isSwallowsTouches() const;
|
||||
|
||||
/** whether or not it will receive Accelerometer events
|
||||
You can enable / disable accelerometer events with this property.
|
||||
@since v0.8.1
|
||||
|
@ -144,6 +148,7 @@ protected:
|
|||
private:
|
||||
int _touchPriority;
|
||||
Touch::DispatchMode _touchMode;
|
||||
bool _swallowsTouches;
|
||||
|
||||
int executeScriptTouchHandler(int eventType, Touch* touch);
|
||||
int executeScriptTouchesHandler(int eventType, Set* touches);
|
||||
|
|
|
@ -140,7 +140,7 @@ ProgressTimer* TransitionProgressRadialCCW::progressTimerNodeWithRenderTexture(R
|
|||
|
||||
// but it is flipped upside down so we flip the sprite
|
||||
pNode->getSprite()->setFlipY(true);
|
||||
pNode->setType(ProgressTimer::RADIAL);
|
||||
pNode->setType(ProgressTimer::Type::RADIAL);
|
||||
|
||||
// Return the radial type that we want to use
|
||||
pNode->setReverseDirection(false);
|
||||
|
@ -184,7 +184,7 @@ ProgressTimer* TransitionProgressRadialCW::progressTimerNodeWithRenderTexture(Re
|
|||
|
||||
// but it is flipped upside down so we flip the sprite
|
||||
pNode->getSprite()->setFlipY(true);
|
||||
pNode->setType( ProgressTimer::RADIAL );
|
||||
pNode->setType( ProgressTimer::Type::RADIAL );
|
||||
|
||||
// Return the radial type that we want to use
|
||||
pNode->setReverseDirection(true);
|
||||
|
@ -216,7 +216,7 @@ ProgressTimer* TransitionProgressHorizontal::progressTimerNodeWithRenderTexture(
|
|||
|
||||
// but it is flipped upside down so we flip the sprite
|
||||
pNode->getSprite()->setFlipY(true);
|
||||
pNode->setType( ProgressTimer::BAR);
|
||||
pNode->setType( ProgressTimer::Type::BAR);
|
||||
|
||||
pNode->setMidpoint(Point(1, 0));
|
||||
pNode->setBarChangeRate(Point(1,0));
|
||||
|
@ -249,7 +249,7 @@ ProgressTimer* TransitionProgressVertical::progressTimerNodeWithRenderTexture(Re
|
|||
|
||||
// but it is flipped upside down so we flip the sprite
|
||||
pNode->getSprite()->setFlipY(true);
|
||||
pNode->setType(ProgressTimer::BAR);
|
||||
pNode->setType(ProgressTimer::Type::BAR);
|
||||
|
||||
pNode->setMidpoint(Point(0, 0));
|
||||
pNode->setBarChangeRate(Point(0,1));
|
||||
|
@ -295,7 +295,7 @@ ProgressTimer* TransitionProgressInOut::progressTimerNodeWithRenderTexture(Rende
|
|||
|
||||
// but it is flipped upside down so we flip the sprite
|
||||
pNode->getSprite()->setFlipY(true);
|
||||
pNode->setType( ProgressTimer::BAR);
|
||||
pNode->setType( ProgressTimer::Type::BAR);
|
||||
|
||||
pNode->setMidpoint(Point(0.5f, 0.5f));
|
||||
pNode->setBarChangeRate(Point(1, 1));
|
||||
|
@ -329,7 +329,7 @@ ProgressTimer* TransitionProgressOutIn::progressTimerNodeWithRenderTexture(Rende
|
|||
|
||||
// but it is flipped upside down so we flip the sprite
|
||||
pNode->getSprite()->setFlipY(true);
|
||||
pNode->setType( ProgressTimer::BAR );
|
||||
pNode->setType( ProgressTimer::Type::BAR );
|
||||
|
||||
pNode->setMidpoint(Point(0.5f, 0.5f));
|
||||
pNode->setBarChangeRate(Point(1, 1));
|
||||
|
|
|
@ -45,7 +45,7 @@ const char kProgressTextureCoords = 0x4b;
|
|||
|
||||
|
||||
ProgressTimer::ProgressTimer()
|
||||
:_type(RADIAL)
|
||||
:_type(Type::RADIAL)
|
||||
,_percentage(0.0f)
|
||||
,_sprite(NULL)
|
||||
,_vertexDataCount(0)
|
||||
|
@ -78,7 +78,7 @@ bool ProgressTimer::initWithSprite(Sprite* sp)
|
|||
_vertexDataCount = 0;
|
||||
|
||||
setAnchorPoint(Point(0.5f,0.5f));
|
||||
_type = RADIAL;
|
||||
_type = Type::RADIAL;
|
||||
_reverseDirection = false;
|
||||
setMidpoint(Point(0.5f, 0.5f));
|
||||
setBarChangeRate(Point(1,1));
|
||||
|
@ -225,10 +225,10 @@ void ProgressTimer::updateProgress(void)
|
|||
{
|
||||
switch (_type)
|
||||
{
|
||||
case RADIAL:
|
||||
case Type::RADIAL:
|
||||
updateRadial();
|
||||
break;
|
||||
case BAR:
|
||||
case Type::BAR:
|
||||
updateBar();
|
||||
break;
|
||||
default:
|
||||
|
@ -527,11 +527,11 @@ void ProgressTimer::draw(void)
|
|||
glVertexAttribPointer( GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(_vertexData[0]), &_vertexData[0].colors);
|
||||
#endif // EMSCRIPTEN
|
||||
|
||||
if(_type == RADIAL)
|
||||
if(_type == Type::RADIAL)
|
||||
{
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 0, _vertexDataCount);
|
||||
}
|
||||
else if (_type == BAR)
|
||||
else if (_type == Type::BAR)
|
||||
{
|
||||
if (!_reverseDirection)
|
||||
{
|
||||
|
|
|
@ -52,7 +52,7 @@ public:
|
|||
/** Types of progress
|
||||
@since v0.99.1
|
||||
*/
|
||||
enum Type
|
||||
enum class Type
|
||||
{
|
||||
/// Radial Counter-Clockwise
|
||||
RADIAL,
|
||||
|
|
|
@ -3,20 +3,6 @@
|
|||
|
||||
NS_CC_BEGIN
|
||||
|
||||
enum TargetPlatform
|
||||
{
|
||||
kTargetWindows,
|
||||
kTargetLinux,
|
||||
kTargetMacOS,
|
||||
kTargetAndroid,
|
||||
kTargetIphone,
|
||||
kTargetIpad,
|
||||
kTargetBlackBerry,
|
||||
kTargetNaCl,
|
||||
kTargetEmscripten,
|
||||
kTargetTizen
|
||||
};
|
||||
|
||||
/**
|
||||
* @addtogroup platform
|
||||
* @{
|
||||
|
@ -26,6 +12,23 @@ class CC_DLL ApplicationProtocol
|
|||
{
|
||||
public:
|
||||
|
||||
// Since WINDOWS and ANDROID are defined as macros, we could not just use these keywords in enumeration(Platform).
|
||||
// Therefore, 'OS_' prefix is added to avoid conflicts with the definitions of system macros.
|
||||
enum class Platform
|
||||
{
|
||||
OS_WINDOWS,
|
||||
OS_LINUX,
|
||||
OS_MAC,
|
||||
OS_ANDROID,
|
||||
OS_IPHONE,
|
||||
OS_IPAD,
|
||||
OS_BLACKBERRY,
|
||||
OS_NACL,
|
||||
OS_EMSCRIPTEN,
|
||||
OS_TIZEN
|
||||
};
|
||||
|
||||
|
||||
virtual ~ApplicationProtocol() {}
|
||||
|
||||
/**
|
||||
|
@ -57,12 +60,12 @@ public:
|
|||
@brief Get current language config
|
||||
@return Current language config
|
||||
*/
|
||||
virtual ccLanguageType getCurrentLanguage() = 0;
|
||||
virtual LanguageType getCurrentLanguage() = 0;
|
||||
|
||||
/**
|
||||
@brief Get target platform
|
||||
*/
|
||||
virtual TargetPlatform getTargetPlatform() = 0;
|
||||
virtual Platform getTargetPlatform() = 0;
|
||||
};
|
||||
|
||||
// end of platform group
|
||||
|
|
|
@ -55,25 +55,25 @@ void CC_DLL MessageBox(const char * pszMsg, const char * pszTitle);
|
|||
/**
|
||||
@brief Enum the language type supported now
|
||||
*/
|
||||
typedef enum LanguageType
|
||||
enum class LanguageType
|
||||
{
|
||||
kLanguageEnglish = 0,
|
||||
kLanguageChinese,
|
||||
kLanguageFrench,
|
||||
kLanguageItalian,
|
||||
kLanguageGerman,
|
||||
kLanguageSpanish,
|
||||
kLanguageRussian,
|
||||
kLanguageKorean,
|
||||
kLanguageJapanese,
|
||||
kLanguageHungarian,
|
||||
kLanguagePortuguese,
|
||||
kLanguageArabic,
|
||||
kLanguageNorwegian,
|
||||
kLanguagePolish
|
||||
} ccLanguageType;
|
||||
ENGLISH = 0,
|
||||
CHINESE,
|
||||
FRENCH,
|
||||
ITALIAN,
|
||||
GERMAN,
|
||||
SPANISH,
|
||||
RUSSIAN,
|
||||
KOREAN,
|
||||
JAPANESE,
|
||||
HUNGARIAN,
|
||||
PORTUGUESE,
|
||||
ARABIC,
|
||||
NORWEGIAN,
|
||||
POLISH
|
||||
};
|
||||
|
||||
// end of platform group
|
||||
// END of platform group
|
||||
/// @}
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -46,7 +46,7 @@ EGLViewProtocol::EGLViewProtocol()
|
|||
: _delegate(NULL)
|
||||
, _scaleX(1.0f)
|
||||
, _scaleY(1.0f)
|
||||
, _resolutionPolicy(kResolutionUnKnown)
|
||||
, _resolutionPolicy(ResolutionPolicy::UNKNOWN)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ EGLViewProtocol::~EGLViewProtocol()
|
|||
|
||||
void EGLViewProtocol::setDesignResolutionSize(float width, float height, ResolutionPolicy resolutionPolicy)
|
||||
{
|
||||
CCASSERT(resolutionPolicy != kResolutionUnKnown, "should set resolutionPolicy");
|
||||
CCASSERT(resolutionPolicy != ResolutionPolicy::UNKNOWN, "should set resolutionPolicy");
|
||||
|
||||
if (width == 0.0f || height == 0.0f)
|
||||
{
|
||||
|
@ -69,22 +69,22 @@ void EGLViewProtocol::setDesignResolutionSize(float width, float height, Resolut
|
|||
_scaleX = (float)_screenSize.width / _designResolutionSize.width;
|
||||
_scaleY = (float)_screenSize.height / _designResolutionSize.height;
|
||||
|
||||
if (resolutionPolicy == kResolutionNoBorder)
|
||||
if (resolutionPolicy == ResolutionPolicy::NO_BORDER)
|
||||
{
|
||||
_scaleX = _scaleY = MAX(_scaleX, _scaleY);
|
||||
}
|
||||
|
||||
if (resolutionPolicy == kResolutionShowAll)
|
||||
if (resolutionPolicy == ResolutionPolicy::SHOW_ALL)
|
||||
{
|
||||
_scaleX = _scaleY = MIN(_scaleX, _scaleY);
|
||||
}
|
||||
|
||||
if ( resolutionPolicy == kResolutionFixedHeight) {
|
||||
if ( resolutionPolicy == ResolutionPolicy::FIXED_HEIGHT) {
|
||||
_scaleX = _scaleY;
|
||||
_designResolutionSize.width = ceilf(_screenSize.width/_scaleX);
|
||||
}
|
||||
|
||||
if ( resolutionPolicy == kResolutionFixedWidth) {
|
||||
if ( resolutionPolicy == ResolutionPolicy::FIXED_WIDTH) {
|
||||
_scaleY = _scaleX;
|
||||
_designResolutionSize.height = ceilf(_screenSize.height/_scaleY);
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ void EGLViewProtocol::setFrameSize(float width, float height)
|
|||
|
||||
Size EGLViewProtocol::getVisibleSize() const
|
||||
{
|
||||
if (_resolutionPolicy == kResolutionNoBorder)
|
||||
if (_resolutionPolicy == ResolutionPolicy::NO_BORDER)
|
||||
{
|
||||
return Size(_screenSize.width/_scaleX, _screenSize.height/_scaleY);
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ Size EGLViewProtocol::getVisibleSize() const
|
|||
|
||||
Point EGLViewProtocol::getVisibleOrigin() const
|
||||
{
|
||||
if (_resolutionPolicy == kResolutionNoBorder)
|
||||
if (_resolutionPolicy == ResolutionPolicy::NO_BORDER)
|
||||
{
|
||||
return Point((_designResolutionSize.width - _screenSize.width/_scaleX)/2,
|
||||
(_designResolutionSize.height - _screenSize.height/_scaleY)/2);
|
||||
|
|
|
@ -3,29 +3,29 @@
|
|||
|
||||
#include "ccTypes.h"
|
||||
|
||||
enum ResolutionPolicy
|
||||
enum class ResolutionPolicy
|
||||
{
|
||||
// The entire application is visible in the specified area without trying to preserve the original aspect ratio.
|
||||
// Distortion can occur, and the application may appear stretched or compressed.
|
||||
kResolutionExactFit,
|
||||
EXACT_FIT,
|
||||
// The entire application fills the specified area, without distortion but possibly with some cropping,
|
||||
// while maintaining the original aspect ratio of the application.
|
||||
kResolutionNoBorder,
|
||||
NO_BORDER,
|
||||
// The entire application is visible in the specified area without distortion while maintaining the original
|
||||
// aspect ratio of the application. Borders can appear on two sides of the application.
|
||||
kResolutionShowAll,
|
||||
SHOW_ALL,
|
||||
// The application takes the height of the design resolution size and modifies the width of the internal
|
||||
// canvas so that it fits the aspect ratio of the device
|
||||
// no distortion will occur however you must make sure your application works on different
|
||||
// aspect ratios
|
||||
kResolutionFixedHeight,
|
||||
FIXED_HEIGHT,
|
||||
// The application takes the width of the design resolution size and modifies the height of the internal
|
||||
// canvas so that it fits the aspect ratio of the device
|
||||
// no distortion will occur however you must make sure your application works on different
|
||||
// aspect ratios
|
||||
kResolutionFixedWidth,
|
||||
FIXED_WIDTH,
|
||||
|
||||
kResolutionUnKnown,
|
||||
UNKNOWN,
|
||||
};
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
@ -84,9 +84,9 @@ public:
|
|||
* @param width Design resolution width.
|
||||
* @param height Design resolution height.
|
||||
* @param resolutionPolicy The resolution policy desired, you may choose:
|
||||
* [1] kResolutionExactFit Fill screen by stretch-to-fit: if the design resolution ratio of width to height is different from the screen resolution ratio, your game view will be stretched.
|
||||
* [2] kResolutionNoBorder Full screen without black border: if the design resolution ratio of width to height is different from the screen resolution ratio, two areas of your game view will be cut.
|
||||
* [3] kResolutionShowAll Full screen with black border: if the design resolution ratio of width to height is different from the screen resolution ratio, two black borders will be shown.
|
||||
* [1] EXACT_FIT Fill screen by stretch-to-fit: if the design resolution ratio of width to height is different from the screen resolution ratio, your game view will be stretched.
|
||||
* [2] NO_BORDER Full screen without black border: if the design resolution ratio of width to height is different from the screen resolution ratio, two areas of your game view will be cut.
|
||||
* [3] SHOW_ALL Full screen with black border: if the design resolution ratio of width to height is different from the screen resolution ratio, two black borders will be shown.
|
||||
*/
|
||||
virtual void setDesignResolutionSize(float width, float height, ResolutionPolicy resolutionPolicy);
|
||||
|
||||
|
|
|
@ -88,19 +88,19 @@ public:
|
|||
UNKOWN
|
||||
};
|
||||
|
||||
typedef enum
|
||||
enum class TextAlign
|
||||
{
|
||||
kAlignCenter = 0x33, ///< Horizontal center and vertical center.
|
||||
kAlignTop = 0x13, ///< Horizontal center and vertical top.
|
||||
kAlignTopRight = 0x12, ///< Horizontal right and vertical top.
|
||||
kAlignRight = 0x32, ///< Horizontal right and vertical center.
|
||||
kAlignBottomRight = 0x22, ///< Horizontal right and vertical bottom.
|
||||
kAlignBottom = 0x23, ///< Horizontal center and vertical bottom.
|
||||
kAlignBottomLeft = 0x21, ///< Horizontal left and vertical bottom.
|
||||
kAlignLeft = 0x31, ///< Horizontal left and vertical center.
|
||||
kAlignTopLeft = 0x11, ///< Horizontal left and vertical top.
|
||||
}TextAlign;
|
||||
|
||||
CENTER = 0x33, ///< Horizontal center and vertical center.
|
||||
TOP = 0x13, ///< Horizontal center and vertical top.
|
||||
TOP_RIGHT = 0x12, ///< Horizontal right and vertical top.
|
||||
RIGHT = 0x32, ///< Horizontal right and vertical center.
|
||||
BOTTOM_RIGHT = 0x22, ///< Horizontal right and vertical bottom.
|
||||
BOTTOM = 0x23, ///< Horizontal center and vertical bottom.
|
||||
BOTTOM_LEFT = 0x21, ///< Horizontal left and vertical bottom.
|
||||
LEFT = 0x31, ///< Horizontal left and vertical center.
|
||||
TOP_LEFT = 0x11, ///< Horizontal left and vertical top.
|
||||
};
|
||||
|
||||
/**
|
||||
@brief Load the image from the specified path.
|
||||
@param strPath the absolute file path.
|
||||
|
@ -133,7 +133,7 @@ public:
|
|||
const char * pText,
|
||||
int nWidth = 0,
|
||||
int nHeight = 0,
|
||||
TextAlign eAlignMask = kAlignCenter,
|
||||
TextAlign eAlignMask = TextAlign::CENTER,
|
||||
const char * pFontName = 0,
|
||||
int nSize = 0);
|
||||
|
||||
|
@ -143,7 +143,7 @@ public:
|
|||
const char * pText,
|
||||
int nWidth = 0,
|
||||
int nHeight = 0,
|
||||
TextAlign eAlignMask = kAlignCenter,
|
||||
TextAlign eAlignMask = TextAlign::CENTER,
|
||||
const char * pFontName = 0,
|
||||
int nSize = 0,
|
||||
float textTintR = 1,
|
||||
|
|
|
@ -247,13 +247,14 @@ Image::~Image()
|
|||
bool Image::initWithImageFile(const char * strPath)
|
||||
{
|
||||
bool bRet = false;
|
||||
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(strPath);
|
||||
|
||||
#ifdef EMSCRIPTEN
|
||||
// Emscripten includes a re-implementation of SDL that uses HTML5 canvas
|
||||
// operations underneath. Consequently, loading images via IMG_Load (an SDL
|
||||
// API) will be a lot faster than running libpng et al as compiled with
|
||||
// Emscripten.
|
||||
SDL_Surface *iSurf = IMG_Load(strPath);
|
||||
SDL_Surface *iSurf = IMG_Load(fullPath.c_str());
|
||||
|
||||
int size = 4 * (iSurf->w * iSurf->h);
|
||||
bRet = initWithRawData((void*)iSurf->pixels, size, iSurf->w, iSurf->h, 8, true);
|
||||
|
@ -269,7 +270,6 @@ bool Image::initWithImageFile(const char * strPath)
|
|||
SDL_FreeSurface(iSurf);
|
||||
#else
|
||||
unsigned long bufferLen = 0;
|
||||
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(strPath);
|
||||
unsigned char* buffer = nullptr;
|
||||
|
||||
//detecgt and unzip the compress file
|
||||
|
@ -541,7 +541,9 @@ bool Image::_initWithJpgData(void * data, int dataLen)
|
|||
/* setup decompression process and source, then read JPEG header */
|
||||
jpeg_create_decompress( &cinfo );
|
||||
|
||||
#ifndef CC_TARGET_QT5
|
||||
jpeg_mem_src( &cinfo, (unsigned char *) data, dataLen );
|
||||
#endif /* CC_TARGET_QT5 */
|
||||
|
||||
/* reading the image header which contains image information */
|
||||
#if (JPEG_LIB_VERSION >= 90)
|
||||
|
@ -923,9 +925,9 @@ bool Image::_initWithPVRv2Data(void *data, int dataLen)
|
|||
{
|
||||
ccPVRv2TexHeader *header = NULL;
|
||||
unsigned int flags, pvrTag;
|
||||
unsigned int dataLength = 0, dataOffset = 0, dataSize = 0;
|
||||
unsigned int blockSize = 0, widthBlocks = 0, heightBlocks = 0;
|
||||
unsigned int width = 0, height = 0;
|
||||
int dataLength = 0, dataOffset = 0, dataSize = 0;
|
||||
int blockSize = 0, widthBlocks = 0, heightBlocks = 0;
|
||||
int width = 0, height = 0;
|
||||
int formatFlags;
|
||||
|
||||
//Cast first sizeof(PVRTexHeader) bytes of data stream as PVRTexHeader
|
||||
|
@ -1034,7 +1036,7 @@ bool Image::_initWithPVRv2Data(void *data, int dataLen)
|
|||
}
|
||||
|
||||
dataSize = widthBlocks * heightBlocks * ((blockSize * it->second.bpp) / 8);
|
||||
unsigned int packetLength = (dataLength - dataOffset);
|
||||
int packetLength = (dataLength - dataOffset);
|
||||
packetLength = packetLength > dataSize ? dataSize : packetLength;
|
||||
|
||||
//Make record to the mipmaps array and increment counter
|
||||
|
@ -1095,7 +1097,7 @@ bool Image::_initWithPVRv3Data(void *data, int dataLen)
|
|||
_renderFormat = it->first;
|
||||
|
||||
// flags
|
||||
uint32_t flags = CC_SWAP_INT32_LITTLE_TO_HOST(header->flags);
|
||||
int flags = CC_SWAP_INT32_LITTLE_TO_HOST(header->flags);
|
||||
|
||||
// PVRv3 specifies premultiply alpha in a flag -- should always respect this in PVRv3 files
|
||||
if (flags & kPVR3TextureFlagPremultipliedAlpha)
|
||||
|
@ -1104,12 +1106,12 @@ bool Image::_initWithPVRv3Data(void *data, int dataLen)
|
|||
}
|
||||
|
||||
// sizing
|
||||
uint32_t width = CC_SWAP_INT32_LITTLE_TO_HOST(header->width);
|
||||
uint32_t height = CC_SWAP_INT32_LITTLE_TO_HOST(header->height);
|
||||
int width = CC_SWAP_INT32_LITTLE_TO_HOST(header->width);
|
||||
int height = CC_SWAP_INT32_LITTLE_TO_HOST(header->height);
|
||||
_width = width;
|
||||
_height = height;
|
||||
uint32_t dataOffset = 0, dataSize = 0;
|
||||
uint32_t blockSize = 0, widthBlocks = 0, heightBlocks = 0;
|
||||
int dataOffset = 0, dataSize = 0;
|
||||
int blockSize = 0, widthBlocks = 0, heightBlocks = 0;
|
||||
|
||||
_dataLen = dataLen - (sizeof(ccPVRv3TexHeader) + header->metadataLength);
|
||||
_data = new unsigned char[_dataLen];
|
||||
|
@ -1118,7 +1120,7 @@ bool Image::_initWithPVRv3Data(void *data, int dataLen)
|
|||
_numberOfMipmaps = header->numberOfMipmaps;
|
||||
CCAssert(_numberOfMipmaps < CC_MIPMAP_MAX, "Image: Maximum number of mimpaps reached. Increate the CC_MIPMAP_MAX value");
|
||||
|
||||
for (unsigned int i = 0; i < _numberOfMipmaps; i++)
|
||||
for (int i = 0; i < _numberOfMipmaps; i++)
|
||||
{
|
||||
switch (pixelFormat)
|
||||
{
|
||||
|
|
|
@ -46,6 +46,7 @@ Config of cocos2d-x project, per target platform.
|
|||
#define CC_PLATFORM_NACL 9
|
||||
#define CC_PLATFORM_EMSCRIPTEN 10
|
||||
#define CC_PLATFORM_TIZEN 11
|
||||
#define CC_PLATFORM_QT5 12
|
||||
|
||||
// Determine target platform by compile environment macro.
|
||||
#define CC_TARGET_PLATFORM CC_PLATFORM_UNKNOWN
|
||||
|
@ -116,6 +117,12 @@ Config of cocos2d-x project, per target platform.
|
|||
#define CC_TARGET_PLATFORM CC_PLATFORM_TIZEN
|
||||
#endif
|
||||
|
||||
// qt5
|
||||
#if defined(CC_TARGET_QT5)
|
||||
#undef CC_TARGET_PLATFORM
|
||||
#define CC_TARGET_PLATFORM CC_PLATFORM_QT5
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// post configure
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -67,74 +67,74 @@ Application* Application::sharedApplication()
|
|||
return Application::getInstance();
|
||||
}
|
||||
|
||||
ccLanguageType Application::getCurrentLanguage()
|
||||
LanguageType Application::getCurrentLanguage()
|
||||
{
|
||||
std::string languageName = getCurrentLanguageJNI();
|
||||
const char* pLanguageName = languageName.c_str();
|
||||
ccLanguageType ret = kLanguageEnglish;
|
||||
LanguageType ret = LanguageType::ENGLISH;
|
||||
|
||||
if (0 == strcmp("zh", pLanguageName))
|
||||
{
|
||||
ret = kLanguageChinese;
|
||||
ret = LanguageType::CHINESE;
|
||||
}
|
||||
else if (0 == strcmp("en", pLanguageName))
|
||||
{
|
||||
ret = kLanguageEnglish;
|
||||
ret = LanguageType::ENGLISH;
|
||||
}
|
||||
else if (0 == strcmp("fr", pLanguageName))
|
||||
{
|
||||
ret = kLanguageFrench;
|
||||
ret = LanguageType::FRENCH;
|
||||
}
|
||||
else if (0 == strcmp("it", pLanguageName))
|
||||
{
|
||||
ret = kLanguageItalian;
|
||||
ret = LanguageType::ITALIAN;
|
||||
}
|
||||
else if (0 == strcmp("de", pLanguageName))
|
||||
{
|
||||
ret = kLanguageGerman;
|
||||
ret = LanguageType::GERMAN;
|
||||
}
|
||||
else if (0 == strcmp("es", pLanguageName))
|
||||
{
|
||||
ret = kLanguageSpanish;
|
||||
ret = LanguageType::SPANISH;
|
||||
}
|
||||
else if (0 == strcmp("ru", pLanguageName))
|
||||
{
|
||||
ret = kLanguageRussian;
|
||||
ret = LanguageType::RUSSIAN;
|
||||
}
|
||||
else if (0 == strcmp("ko", pLanguageName))
|
||||
{
|
||||
ret = kLanguageKorean;
|
||||
ret = LanguageType::KOREAN;
|
||||
}
|
||||
else if (0 == strcmp("ja", pLanguageName))
|
||||
{
|
||||
ret = kLanguageJapanese;
|
||||
ret = LanguageType::JAPANESE;
|
||||
}
|
||||
else if (0 == strcmp("hu", pLanguageName))
|
||||
{
|
||||
ret = kLanguageHungarian;
|
||||
ret = LanguageType::HUNGARIAN;
|
||||
}
|
||||
else if (0 == strcmp("pt", pLanguageName))
|
||||
{
|
||||
ret = kLanguagePortuguese;
|
||||
ret = LanguageType::PORTUGUESE;
|
||||
}
|
||||
else if (0 == strcmp("ar", pLanguageName))
|
||||
{
|
||||
ret = kLanguageArabic;
|
||||
ret = LanguageType::ARABIC;
|
||||
}
|
||||
else if (0 == strcmp("nb", pLanguageName))
|
||||
else if (0 == strcmp("nb", pLanguageName))
|
||||
{
|
||||
ret = kLanguageNorwegian;
|
||||
ret = LanguageType::NORWEGIAN;
|
||||
}
|
||||
else if (0 == strcmp("pl", pLanguageName))
|
||||
{
|
||||
ret = kLanguagePolish;
|
||||
ret = LanguageType::POLISH;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
TargetPlatform Application::getTargetPlatform()
|
||||
Application::Platform Application::getTargetPlatform()
|
||||
{
|
||||
return kTargetAndroid;
|
||||
return Platform::OS_ANDROID;
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -38,12 +38,12 @@ public:
|
|||
@brief Get current language config
|
||||
@return Current language config
|
||||
*/
|
||||
virtual ccLanguageType getCurrentLanguage();
|
||||
virtual LanguageType getCurrentLanguage();
|
||||
|
||||
/**
|
||||
@brief Get target platform
|
||||
*/
|
||||
virtual TargetPlatform getTargetPlatform();
|
||||
virtual Platform getTargetPlatform();
|
||||
|
||||
protected:
|
||||
static Application * sm_pSharedApplication;
|
||||
|
|
|
@ -35,14 +35,11 @@ NS_CC_BEGIN
|
|||
// XXX deprecated
|
||||
void CCLog(const char * pszFormat, ...)
|
||||
{
|
||||
char buf[MAX_LEN];
|
||||
|
||||
va_list args;
|
||||
va_start(args, pszFormat);
|
||||
vsnprintf(buf, MAX_LEN, pszFormat, args);
|
||||
__android_log_vprint(ANDROID_LOG_DEBUG, "cocos2d-x debug info", pszFormat, args);
|
||||
va_end(args);
|
||||
|
||||
__android_log_print(ANDROID_LOG_DEBUG, "cocos2d-x debug info", buf);
|
||||
}
|
||||
|
||||
void log(const char * pszFormat, ...)
|
||||
|
@ -64,7 +61,7 @@ void MessageBox(const char * pszMsg, const char * pszTitle)
|
|||
|
||||
void LuaLog(const char * pszFormat)
|
||||
{
|
||||
__android_log_print(ANDROID_LOG_DEBUG, "cocos2d-x debug info", pszFormat);
|
||||
__android_log_write(ANDROID_LOG_DEBUG, "cocos2d-x debug info", pszFormat);
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -59,7 +59,12 @@ FileUtils* FileUtils::getInstance()
|
|||
if (s_sharedFileUtils == NULL)
|
||||
{
|
||||
s_sharedFileUtils = new FileUtilsAndroid();
|
||||
s_sharedFileUtils->init();
|
||||
if(!s_sharedFileUtils->init())
|
||||
{
|
||||
delete s_sharedFileUtils;
|
||||
s_sharedFileUtils = NULL;
|
||||
CCLOG("ERROR: Could not init CCFileUtilsAndroid");
|
||||
}
|
||||
}
|
||||
return s_sharedFileUtils;
|
||||
}
|
||||
|
@ -223,7 +228,7 @@ unsigned char* FileUtilsAndroid::doGetFileData(const char* filename, const char*
|
|||
{
|
||||
std::string msg = "Get data from file(";
|
||||
msg.append(filename).append(") failed!");
|
||||
CCLOG(msg.c_str());
|
||||
CCLOG("%s", msg.c_str());
|
||||
}
|
||||
|
||||
return pData;
|
||||
|
|
|
@ -85,9 +85,9 @@ const std::string& Application::getResourceRootPath(void)
|
|||
return _resourceRootPath;
|
||||
}
|
||||
|
||||
TargetPlatform Application::getTargetPlatform()
|
||||
Application::Platform Application::getTargetPlatform()
|
||||
{
|
||||
return kTargetEmscripten;
|
||||
return Platform::OS_EMSCRIPTEN;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
@ -105,9 +105,9 @@ Application* Application::sharedApplication()
|
|||
return Application::getInstance();
|
||||
}
|
||||
|
||||
ccLanguageType Application::getCurrentLanguage()
|
||||
LanguageType Application::getCurrentLanguage()
|
||||
{
|
||||
return kLanguageEnglish;
|
||||
return LanguageType::ENGLISH;
|
||||
}
|
||||
|
||||
NS_CC_END;
|
||||
|
|
|
@ -38,12 +38,12 @@ public:
|
|||
@brief Get current language config
|
||||
@return Current language config
|
||||
*/
|
||||
virtual ccLanguageType getCurrentLanguage();
|
||||
virtual LanguageType getCurrentLanguage();
|
||||
|
||||
/**
|
||||
@brief Get target platform
|
||||
*/
|
||||
virtual TargetPlatform getTargetPlatform();
|
||||
virtual Platform getTargetPlatform();
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,7 +14,12 @@ FileUtils* FileUtils::getInstance()
|
|||
if (s_sharedFileUtils == NULL)
|
||||
{
|
||||
s_sharedFileUtils = new FileUtilsEmscripten();
|
||||
s_sharedFileUtils->init();
|
||||
if(!s_sharedFileUtils->init())
|
||||
{
|
||||
delete s_sharedFileUtils;
|
||||
s_sharedFileUtils = NULL;
|
||||
CCLOG("ERROR: Could not init CCFileUtilsEmscripten");
|
||||
}
|
||||
}
|
||||
return s_sharedFileUtils;
|
||||
}
|
||||
|
@ -24,7 +29,7 @@ FileUtilsEmscripten::FileUtilsEmscripten()
|
|||
|
||||
bool FileUtilsEmscripten::init()
|
||||
{
|
||||
_defaultResRootPath = "app/native/Resources/";
|
||||
_defaultResRootPath = "/";
|
||||
return FileUtils::init();
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ public:
|
|||
*/
|
||||
static Application* getInstance();
|
||||
|
||||
/** @deprecated Use getInstance() instead */
|
||||
/** @deprecated Use getInstance() instead */
|
||||
CC_DEPRECATED_ATTRIBUTE static Application* sharedApplication();
|
||||
|
||||
/**
|
||||
|
@ -62,12 +62,12 @@ public:
|
|||
@brief Get current language config
|
||||
@return Current language config
|
||||
*/
|
||||
virtual ccLanguageType getCurrentLanguage();
|
||||
virtual LanguageType getCurrentLanguage();
|
||||
|
||||
/**
|
||||
@brief Get target platform
|
||||
*/
|
||||
virtual TargetPlatform getTargetPlatform();
|
||||
virtual Platform getTargetPlatform();
|
||||
|
||||
protected:
|
||||
static Application * sm_pSharedApplication;
|
||||
|
|
|
@ -75,7 +75,7 @@ Application* Application::sharedApplication()
|
|||
return Application::getInstance();
|
||||
}
|
||||
|
||||
ccLanguageType Application::getCurrentLanguage()
|
||||
LanguageType Application::getCurrentLanguage()
|
||||
{
|
||||
// get the current language and country config
|
||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||
|
@ -86,63 +86,63 @@ ccLanguageType Application::getCurrentLanguage()
|
|||
NSDictionary* temp = [NSLocale componentsFromLocaleIdentifier:currentLanguage];
|
||||
NSString * languageCode = [temp objectForKey:NSLocaleLanguageCode];
|
||||
|
||||
ccLanguageType ret = kLanguageEnglish;
|
||||
LanguageType ret = LanguageType::ENGLISH;
|
||||
if ([languageCode isEqualToString:@"zh"])
|
||||
{
|
||||
ret = kLanguageChinese;
|
||||
ret = LanguageType::CHINESE;
|
||||
}
|
||||
else if ([languageCode isEqualToString:@"en"])
|
||||
{
|
||||
ret = kLanguageEnglish;
|
||||
ret = LanguageType::ENGLISH;
|
||||
}
|
||||
else if ([languageCode isEqualToString:@"fr"]){
|
||||
ret = kLanguageFrench;
|
||||
ret = LanguageType::FRENCH;
|
||||
}
|
||||
else if ([languageCode isEqualToString:@"it"]){
|
||||
ret = kLanguageItalian;
|
||||
ret = LanguageType::ITALIAN;
|
||||
}
|
||||
else if ([languageCode isEqualToString:@"de"]){
|
||||
ret = kLanguageGerman;
|
||||
ret = LanguageType::GERMAN;
|
||||
}
|
||||
else if ([languageCode isEqualToString:@"es"]){
|
||||
ret = kLanguageSpanish;
|
||||
ret = LanguageType::SPANISH;
|
||||
}
|
||||
else if ([languageCode isEqualToString:@"ru"]){
|
||||
ret = kLanguageRussian;
|
||||
ret = LanguageType::RUSSIAN;
|
||||
}
|
||||
else if ([languageCode isEqualToString:@"ko"]){
|
||||
ret = kLanguageKorean;
|
||||
ret = LanguageType::KOREAN;
|
||||
}
|
||||
else if ([languageCode isEqualToString:@"ja"]){
|
||||
ret = kLanguageJapanese;
|
||||
ret = LanguageType::JAPANESE;
|
||||
}
|
||||
else if ([languageCode isEqualToString:@"hu"]){
|
||||
ret = kLanguageHungarian;
|
||||
ret = LanguageType::HUNGARIAN;
|
||||
}
|
||||
else if ([languageCode isEqualToString:@"pt"]){
|
||||
ret = kLanguagePortuguese;
|
||||
ret = LanguageType::PORTUGUESE;
|
||||
}
|
||||
else if ([languageCode isEqualToString:@"ar"]){
|
||||
ret = kLanguageArabic;
|
||||
ret = LanguageType::ARABIC;
|
||||
}
|
||||
else if ([languageCode isEqualToString:@"nb"]){
|
||||
ret = kLanguageNorwegian;
|
||||
ret = LanguageType::NORWEGIAN;
|
||||
}
|
||||
else if ([languageCode isEqualToString:@"pl"]){
|
||||
ret = kLanguagePolish;
|
||||
ret = LanguageType::POLISH;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
TargetPlatform Application::getTargetPlatform()
|
||||
Application::Platform Application::getTargetPlatform()
|
||||
{
|
||||
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) // idiom for iOS <= 3.2, otherwise: [UIDevice userInterfaceIdiom] is faster.
|
||||
{
|
||||
return kTargetIpad;
|
||||
return Platform::OS_IPAD;
|
||||
}
|
||||
else
|
||||
{
|
||||
return kTargetIphone;
|
||||
return Platform::OS_IPHONE;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ bool EGLView::isOpenGLReady()
|
|||
|
||||
bool EGLView::setContentScaleFactor(float contentScaleFactor)
|
||||
{
|
||||
assert(_resolutionPolicy == kResolutionUnKnown); // cannot enable retina mode
|
||||
assert(_resolutionPolicy == ResolutionPolicy::UNKNOWN); // cannot enable retina mode
|
||||
|
||||
_scaleX = _scaleY = contentScaleFactor;
|
||||
[[CCEAGLView sharedEGLView] setNeedsLayout];
|
||||
|
|
|
@ -213,7 +213,12 @@ FileUtils* FileUtils::getInstance()
|
|||
if (s_sharedFileUtils == NULL)
|
||||
{
|
||||
s_sharedFileUtils = new FileUtilsIOS();
|
||||
s_sharedFileUtils->init();
|
||||
if(!s_sharedFileUtils->init())
|
||||
{
|
||||
delete s_sharedFileUtils;
|
||||
s_sharedFileUtils = NULL;
|
||||
CCLOG("ERROR: Could not init CCFileUtilsIOS");
|
||||
}
|
||||
}
|
||||
return s_sharedFileUtils;
|
||||
}
|
||||
|
|
|
@ -136,7 +136,7 @@ static bool _initWithString(const char * pText, cocos2d::Image::TextAlign eAlign
|
|||
if (constrainSize.height > dim.height)
|
||||
{
|
||||
// vertical alignment
|
||||
unsigned int vAlignment = (eAlign >> 4) & 0x0F;
|
||||
unsigned int vAlignment = ((int)eAlign >> 4) & 0x0F;
|
||||
if (vAlignment == ALIGN_TOP)
|
||||
{
|
||||
startH = 0;
|
||||
|
@ -212,7 +212,7 @@ static bool _initWithString(const char * pText, cocos2d::Image::TextAlign eAlign
|
|||
UIGraphicsPushContext(context);
|
||||
|
||||
// measure text size with specified font and determine the rectangle to draw text in
|
||||
unsigned uHoriFlag = eAlign & 0x0f;
|
||||
unsigned uHoriFlag = (int)eAlign & 0x0f;
|
||||
UITextAlignment align = (UITextAlignment)((2 == uHoriFlag) ? UITextAlignmentRight
|
||||
: (3 == uHoriFlag) ? UITextAlignmentCenter
|
||||
: UITextAlignmentLeft);
|
||||
|
@ -314,36 +314,36 @@ static bool _initWithString(const char * pText, cocos2d::Image::TextAlign eAlign
|
|||
NS_CC_BEGIN
|
||||
|
||||
bool Image::initWithString(
|
||||
const char * pText,
|
||||
int nWidth /* = 0 */,
|
||||
int nHeight /* = 0 */,
|
||||
TextAlign eAlignMask /* = kAlignCenter */,
|
||||
const char * pFontName /* = nil */,
|
||||
int nSize /* = 0 */)
|
||||
const char * pText,
|
||||
int nWidth /* = 0 */,
|
||||
int nHeight /* = 0 */,
|
||||
TextAlign eAlignMask /* = kAlignCenter */,
|
||||
const char * pFontName /* = nil */,
|
||||
int nSize /* = 0 */)
|
||||
{
|
||||
return initWithStringShadowStroke(pText, nWidth, nHeight, eAlignMask , pFontName, nSize);
|
||||
}
|
||||
|
||||
bool Image::initWithStringShadowStroke(
|
||||
const char * pText,
|
||||
int nWidth ,
|
||||
int nHeight ,
|
||||
TextAlign eAlignMask ,
|
||||
const char * pFontName ,
|
||||
int nSize ,
|
||||
float textTintR,
|
||||
float textTintG,
|
||||
float textTintB,
|
||||
bool shadow,
|
||||
float shadowOffsetX,
|
||||
float shadowOffsetY,
|
||||
float shadowOpacity,
|
||||
float shadowBlur,
|
||||
bool stroke,
|
||||
float strokeR,
|
||||
float strokeG,
|
||||
float strokeB,
|
||||
float strokeSize)
|
||||
const char * pText,
|
||||
int nWidth ,
|
||||
int nHeight ,
|
||||
TextAlign eAlignMask ,
|
||||
const char * pFontName ,
|
||||
int nSize ,
|
||||
float textTintR,
|
||||
float textTintG,
|
||||
float textTintB,
|
||||
bool shadow,
|
||||
float shadowOffsetX,
|
||||
float shadowOffsetY,
|
||||
float shadowOpacity,
|
||||
float shadowBlur,
|
||||
bool stroke,
|
||||
float strokeR,
|
||||
float strokeG,
|
||||
float strokeB,
|
||||
float strokeSize)
|
||||
{
|
||||
|
||||
|
||||
|
|
|
@ -84,9 +84,9 @@ const std::string& Application::getResourceRootPath(void)
|
|||
return _resourceRootPath;
|
||||
}
|
||||
|
||||
TargetPlatform Application::getTargetPlatform()
|
||||
Application::Platform Application::getTargetPlatform()
|
||||
{
|
||||
return kTargetLinux;
|
||||
return Platform::OS_LINUX;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
@ -104,75 +104,75 @@ Application* Application::sharedApplication()
|
|||
return Application::getInstance();
|
||||
}
|
||||
|
||||
ccLanguageType Application::getCurrentLanguage()
|
||||
LanguageType Application::getCurrentLanguage()
|
||||
{
|
||||
char *pLanguageName = getenv("LANG");
|
||||
ccLanguageType ret = kLanguageEnglish;
|
||||
LanguageType ret = LanguageType::ENGLISH;
|
||||
if (!pLanguageName)
|
||||
{
|
||||
return kLanguageEnglish;
|
||||
return LanguageType::ENGLISH;
|
||||
}
|
||||
strtok(pLanguageName, "_");
|
||||
if (!pLanguageName)
|
||||
{
|
||||
return kLanguageEnglish;
|
||||
return LanguageType::ENGLISH;
|
||||
}
|
||||
|
||||
if (0 == strcmp("zh", pLanguageName))
|
||||
{
|
||||
ret = kLanguageChinese;
|
||||
ret = LanguageType::CHINESE;
|
||||
}
|
||||
else if (0 == strcmp("en", pLanguageName))
|
||||
{
|
||||
ret = kLanguageEnglish;
|
||||
ret = LanguageType::ENGLISH;
|
||||
}
|
||||
else if (0 == strcmp("fr", pLanguageName))
|
||||
{
|
||||
ret = kLanguageFrench;
|
||||
ret = LanguageType::FRENCH;
|
||||
}
|
||||
else if (0 == strcmp("it", pLanguageName))
|
||||
{
|
||||
ret = kLanguageItalian;
|
||||
ret = LanguageType::ITALIAN;
|
||||
}
|
||||
else if (0 == strcmp("de", pLanguageName))
|
||||
{
|
||||
ret = kLanguageGerman;
|
||||
ret = LanguageType::GERMAN;
|
||||
}
|
||||
else if (0 == strcmp("es", pLanguageName))
|
||||
{
|
||||
ret = kLanguageSpanish;
|
||||
ret = LanguageType::SPANISH;
|
||||
}
|
||||
else if (0 == strcmp("ru", pLanguageName))
|
||||
{
|
||||
ret = kLanguageRussian;
|
||||
ret = LanguageType::RUSSIAN;
|
||||
}
|
||||
else if (0 == strcmp("ko", pLanguageName))
|
||||
{
|
||||
ret = kLanguageKorean;
|
||||
ret = LanguageType::KOREAN;
|
||||
}
|
||||
else if (0 == strcmp("ja", pLanguageName))
|
||||
{
|
||||
ret = kLanguageJapanese;
|
||||
ret = LanguageType::JAPANESE;
|
||||
}
|
||||
else if (0 == strcmp("hu", pLanguageName))
|
||||
{
|
||||
ret = kLanguageHungarian;
|
||||
ret = LanguageType::HUNGARIAN;
|
||||
}
|
||||
else if (0 == strcmp("pt", pLanguageName))
|
||||
{
|
||||
ret = kLanguagePortuguese;
|
||||
ret = LanguageType::PORTUGUESE;
|
||||
}
|
||||
else if (0 == strcmp("ar", pLanguageName))
|
||||
{
|
||||
ret = kLanguageArabic;
|
||||
ret = LanguageType::ARABIC;
|
||||
}
|
||||
else if (0 == strcmp("nb", pLanguageName))
|
||||
{
|
||||
ret = kLanguageNorwegian;
|
||||
ret = LanguageType::NORWEGIAN;
|
||||
}
|
||||
else if (0 == strcmp("pl", pLanguageName))
|
||||
{
|
||||
ret = kLanguagePolish;
|
||||
ret = LanguageType::POLISH;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -42,7 +42,7 @@ public:
|
|||
CC_DEPRECATED_ATTRIBUTE static Application* sharedApplication();
|
||||
|
||||
/* override functions */
|
||||
virtual ccLanguageType getCurrentLanguage();
|
||||
virtual LanguageType getCurrentLanguage();
|
||||
|
||||
/**
|
||||
* Sets the Resource root path.
|
||||
|
@ -59,7 +59,7 @@ public:
|
|||
/**
|
||||
@brief Get target platform
|
||||
*/
|
||||
virtual TargetPlatform getTargetPlatform();
|
||||
virtual Platform getTargetPlatform();
|
||||
protected:
|
||||
long _animationInterval; //micro second
|
||||
std::string _resourceRootPath;
|
||||
|
|
|
@ -23,7 +23,12 @@ FileUtils* FileUtils::getInstance()
|
|||
if (s_sharedFileUtils == NULL)
|
||||
{
|
||||
s_sharedFileUtils = new FileUtilsLinux();
|
||||
s_sharedFileUtils->init();
|
||||
if(!s_sharedFileUtils->init())
|
||||
{
|
||||
delete s_sharedFileUtils;
|
||||
s_sharedFileUtils = NULL;
|
||||
CCLOG("ERROR: Could not init CCFileUtilsLinux");
|
||||
}
|
||||
}
|
||||
return s_sharedFileUtils;
|
||||
}
|
||||
|
|
|
@ -242,9 +242,9 @@ public:
|
|||
*/
|
||||
int computeLineStart(FT_Face face, Image::TextAlign eAlignMask, int line) {
|
||||
int lineWidth = textLines.at(line).lineWidth;
|
||||
if (eAlignMask == Image::kAlignCenter || eAlignMask == Image::kAlignTop || eAlignMask == Image::kAlignBottom) {
|
||||
if (eAlignMask == Image::TextAlign::CENTER || eAlignMask == Image::TextAlign::TOP || eAlignMask == Image::TextAlign::BOTTOM) {
|
||||
return (iMaxLineWidth - lineWidth) / 2;
|
||||
} else if (eAlignMask == Image::kAlignRight || eAlignMask == Image::kAlignTopRight || eAlignMask == Image::kAlignBottomRight) {
|
||||
} else if (eAlignMask == Image::TextAlign::RIGHT || eAlignMask == Image::TextAlign::TOP_RIGHT || eAlignMask == Image::TextAlign::BOTTOM_RIGHT) {
|
||||
return (iMaxLineWidth - lineWidth);
|
||||
}
|
||||
|
||||
|
@ -254,10 +254,10 @@ public:
|
|||
|
||||
int computeLineStartY( FT_Face face, Image::TextAlign eAlignMask, int txtHeight, int borderHeight ){
|
||||
int baseLinePos = ceilf(FT_MulFix( face->bbox.yMax, face->size->metrics.y_scale )/64.0f);
|
||||
if (eAlignMask == Image::kAlignCenter || eAlignMask == Image::kAlignLeft || eAlignMask == Image::kAlignRight) {
|
||||
if (eAlignMask == Image::TextAlign::CENTER || eAlignMask == Image::TextAlign::LEFT || eAlignMask == Image::TextAlign::RIGHT) {
|
||||
//vertical center
|
||||
return (borderHeight - txtHeight) / 2 + baseLinePos;
|
||||
} else if (eAlignMask == Image::kAlignBottomRight || eAlignMask == Image::kAlignBottom || eAlignMask == Image::kAlignBottomLeft) {
|
||||
} else if (eAlignMask == Image::TextAlign::BOTTOM_RIGHT || eAlignMask == Image::TextAlign::BOTTOM || eAlignMask == Image::TextAlign::BOTTOM_LEFT) {
|
||||
//vertical bottom
|
||||
return borderHeight - txtHeight + baseLinePos;
|
||||
}
|
||||
|
|
|
@ -65,12 +65,12 @@ public:
|
|||
@brief Get current language config
|
||||
@return Current language config
|
||||
*/
|
||||
virtual ccLanguageType getCurrentLanguage();
|
||||
virtual LanguageType getCurrentLanguage();
|
||||
|
||||
/**
|
||||
@brief Get target platform
|
||||
*/
|
||||
virtual TargetPlatform getTargetPlatform();
|
||||
virtual Platform getTargetPlatform();
|
||||
|
||||
/**
|
||||
* Sets the Resource root path.
|
||||
|
|
|
@ -60,9 +60,9 @@ void Application::setAnimationInterval(double interval)
|
|||
[[CCDirectorCaller sharedDirectorCaller] setAnimationInterval: interval ];
|
||||
}
|
||||
|
||||
TargetPlatform Application::getTargetPlatform()
|
||||
Application::Platform Application::getTargetPlatform()
|
||||
{
|
||||
return kTargetMacOS;
|
||||
return Platform::OS_MAC;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -81,7 +81,7 @@ Application* Application::sharedApplication()
|
|||
return Application::getInstance();
|
||||
}
|
||||
|
||||
ccLanguageType Application::getCurrentLanguage()
|
||||
LanguageType Application::getCurrentLanguage()
|
||||
{
|
||||
// get the current language and country config
|
||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||
|
@ -92,52 +92,52 @@ ccLanguageType Application::getCurrentLanguage()
|
|||
NSDictionary* temp = [NSLocale componentsFromLocaleIdentifier:currentLanguage];
|
||||
NSString * languageCode = [temp objectForKey:NSLocaleLanguageCode];
|
||||
|
||||
ccLanguageType ret = kLanguageEnglish;
|
||||
LanguageType ret = LanguageType::ENGLISH;
|
||||
if ([languageCode isEqualToString:@"zh"])
|
||||
{
|
||||
ret = kLanguageChinese;
|
||||
ret = LanguageType::CHINESE;
|
||||
}
|
||||
else if ([languageCode isEqualToString:@"en"])
|
||||
{
|
||||
ret = kLanguageEnglish;
|
||||
ret = LanguageType::ENGLISH;;
|
||||
}
|
||||
else if ([languageCode isEqualToString:@"fr"]){
|
||||
ret = kLanguageFrench;
|
||||
ret = LanguageType::FRENCH;
|
||||
}
|
||||
else if ([languageCode isEqualToString:@"it"]){
|
||||
ret = kLanguageItalian;
|
||||
ret = LanguageType::ITALIAN;
|
||||
}
|
||||
else if ([languageCode isEqualToString:@"de"]){
|
||||
ret = kLanguageGerman;
|
||||
ret = LanguageType::GERMAN;
|
||||
}
|
||||
else if ([languageCode isEqualToString:@"es"]){
|
||||
ret = kLanguageSpanish;
|
||||
ret = LanguageType::SPANISH;
|
||||
}
|
||||
else if ([languageCode isEqualToString:@"ru"]){
|
||||
ret = kLanguageRussian;
|
||||
ret = LanguageType::RUSSIAN;
|
||||
}
|
||||
else if ([languageCode isEqualToString:@"ko"]){
|
||||
ret = kLanguageKorean;
|
||||
ret = LanguageType::KOREAN;
|
||||
}
|
||||
else if ([languageCode isEqualToString:@"ja"]){
|
||||
ret = kLanguageJapanese;
|
||||
ret = LanguageType::JAPANESE;
|
||||
}
|
||||
else if ([languageCode isEqualToString:@"hu"]){
|
||||
ret = kLanguageHungarian;
|
||||
ret = LanguageType::HUNGARIAN;
|
||||
}
|
||||
else if ([languageCode isEqualToString:@"pt"])
|
||||
{
|
||||
ret = kLanguagePortuguese;
|
||||
ret = LanguageType::PORTUGUESE;
|
||||
}
|
||||
else if ([languageCode isEqualToString:@"ar"])
|
||||
{
|
||||
ret = kLanguageArabic;
|
||||
ret = LanguageType::ARABIC;
|
||||
}
|
||||
else if ([languageCode isEqualToString:@"nb"]){
|
||||
ret = kLanguageNorwegian;
|
||||
ret = LanguageType::NORWEGIAN;
|
||||
}
|
||||
else if ([languageCode isEqualToString:@"pl"]){
|
||||
ret = kLanguagePolish;
|
||||
ret = LanguageType::POLISH;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -210,7 +210,12 @@ FileUtils* FileUtils::getInstance()
|
|||
if (s_sharedFileUtils == NULL)
|
||||
{
|
||||
s_sharedFileUtils = new FileUtilsMac();
|
||||
s_sharedFileUtils->init();
|
||||
if(!s_sharedFileUtils->init())
|
||||
{
|
||||
delete s_sharedFileUtils;
|
||||
s_sharedFileUtils = NULL;
|
||||
CCLOG("ERROR: Could not init CCFileUtilsMac");
|
||||
}
|
||||
}
|
||||
return s_sharedFileUtils;
|
||||
}
|
||||
|
|
|
@ -82,8 +82,8 @@ static bool _initWithString(const char * pText, cocos2d::Image::TextAlign eAlign
|
|||
|
||||
|
||||
// alignment, linebreak
|
||||
unsigned uHoriFlag = eAlign & 0x0f;
|
||||
unsigned uVertFlag = (eAlign >> 4) & 0x0f;
|
||||
unsigned uHoriFlag = (int)eAlign & 0x0f;
|
||||
unsigned uVertFlag = ((int)eAlign >> 4) & 0x0f;
|
||||
NSTextAlignment align = (2 == uHoriFlag) ? NSRightTextAlignment
|
||||
: (3 == uHoriFlag) ? NSCenterTextAlignment
|
||||
: NSLeftTextAlignment;
|
||||
|
|
|
@ -90,9 +90,9 @@ void Application::setAnimationInterval(double interval)
|
|||
_animationInterval = interval * 1000.0f;
|
||||
}
|
||||
|
||||
TargetPlatform Application::getTargetPlatform()
|
||||
Application::Platform Application::getTargetPlatform()
|
||||
{
|
||||
return kTargetNaCl;
|
||||
return Platform::OS_NACL;
|
||||
}
|
||||
|
||||
Application* Application::getInstance()
|
||||
|
@ -107,9 +107,9 @@ Application* Application::sharedApplication()
|
|||
return Application::getInstance();
|
||||
}
|
||||
|
||||
ccLanguageType Application::getCurrentLanguage()
|
||||
LanguageType Application::getCurrentLanguage()
|
||||
{
|
||||
ccLanguageType ret = kLanguageEnglish;
|
||||
LanguageType ret = LanguageType::ENGLISH;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -58,12 +58,12 @@ public:
|
|||
CC_DEPRECATED_ATTRIBUTE static Application* sharedApplication();
|
||||
|
||||
/* override functions */
|
||||
virtual ccLanguageType getCurrentLanguage();
|
||||
virtual LanguageType getCurrentLanguage();
|
||||
|
||||
/**
|
||||
@brief Get target platform
|
||||
*/
|
||||
virtual TargetPlatform getTargetPlatform();
|
||||
virtual Platform getTargetPlatform();
|
||||
|
||||
static bool isRunning() { return s_running; }
|
||||
protected:
|
||||
|
|
|
@ -35,7 +35,12 @@ FileUtils* FileUtils::getInstance()
|
|||
if (s_sharedFileUtils == NULL)
|
||||
{
|
||||
s_sharedFileUtils = new FileUtilsNaCl();
|
||||
s_sharedFileUtils->init();
|
||||
if(!s_sharedFileUtils->init())
|
||||
{
|
||||
delete s_sharedFileUtils;
|
||||
s_sharedFileUtils = NULL;
|
||||
CCLOG("ERROR: Could not init CCFileUtilsNacl");
|
||||
}
|
||||
}
|
||||
return s_sharedFileUtils;
|
||||
}
|
||||
|
|
|
@ -214,7 +214,7 @@ public:
|
|||
* while -1 means fail
|
||||
*
|
||||
*/
|
||||
int computeLineStart(FT_Face face, Image::ETextAlign eAlignMask, FT_UInt unicode,
|
||||
int computeLineStart(FT_Face face, Image::TextAlign eAlignMask, FT_UInt unicode,
|
||||
int iLineIndex)
|
||||
{
|
||||
int iRet;
|
||||
|
@ -223,11 +223,11 @@ public:
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (eAlignMask == Image::kAlignCenter) {
|
||||
if (eAlignMask == Image::TextAlign::CENTER) {
|
||||
iRet = (iMaxLineWidth - vLines[iLineIndex].iLineWidth) / 2
|
||||
- SHIFT6(face->glyph->metrics.horiBearingX );
|
||||
|
||||
} else if (eAlignMask == Image::kAlignRight) {
|
||||
} else if (eAlignMask == Image::TextAlign::RIGHT) {
|
||||
iRet = (iMaxLineWidth - vLines[iLineIndex].iLineWidth)
|
||||
- SHIFT6(face->glyph->metrics.horiBearingX );
|
||||
} else {
|
||||
|
@ -237,17 +237,17 @@ public:
|
|||
return iRet;
|
||||
}
|
||||
|
||||
int computeLineStartY(FT_Face face, Image::ETextAlign eAlignMask, int txtHeight, int borderHeight)
|
||||
int computeLineStartY(FT_Face face, Image::TextAlign eAlignMask, int txtHeight, int borderHeight)
|
||||
{
|
||||
int iRet = 0;
|
||||
if (eAlignMask == Image::kAlignCenter || eAlignMask == Image::kAlignLeft ||
|
||||
eAlignMask == Image::kAlignRight ) {
|
||||
if (eAlignMask == Image::TextAlign::CENTER || eAlignMask == Image::TextAlign::LEFT ||
|
||||
eAlignMask == Image::TextAlign::RIGHT ) {
|
||||
//vertical center
|
||||
iRet = (borderHeight - txtHeight)/2;
|
||||
|
||||
} else if (eAlignMask == Image::kAlignBottomRight ||
|
||||
eAlignMask == Image::kAlignBottom ||
|
||||
eAlignMask == Image::kAlignBottomLeft ) {
|
||||
} else if (eAlignMask == Image::TextAlign::BOTTOM_RIGHT ||
|
||||
eAlignMask == Image::TextAlign::BOTTOM ||
|
||||
eAlignMask == Image::TextAlign::BOTTOM_LEFT ) {
|
||||
//vertical bottom
|
||||
iRet = borderHeight - txtHeight;
|
||||
}
|
||||
|
@ -310,7 +310,7 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
bool renderLines(FT_Face face, Image::ETextAlign eAlignMask, int iCurYCursor)
|
||||
bool renderLines(FT_Face face, Image::TextAlign eAlignMask, int iCurYCursor)
|
||||
{
|
||||
size_t lines = vLines.size();
|
||||
for (size_t i = 0; i < lines; i++)
|
||||
|
@ -328,7 +328,7 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
bool getBitmap(const char *text, int nWidth, int nHeight, Image::ETextAlign eAlignMask, const char * pFontName, float fontSize)
|
||||
bool getBitmap(const char *text, int nWidth, int nHeight, Image::TextAlign eAlignMask, const char * pFontName, float fontSize)
|
||||
{
|
||||
FT_Error iError;
|
||||
if (libError)
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
/**
|
||||
*
|
||||
* Cocos2D-X Qt 5 Platform
|
||||
*
|
||||
* Copyright (C) 2013 Jolla Ltd.
|
||||
* Contact: Thomas Perl <thomas.perl@jollamobile.com>
|
||||
*
|
||||
* 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 "AccelerometerListener.h"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
AccelerometerListener::AccelerometerListener(Accelerometer *accelerometer)
|
||||
: QObject()
|
||||
, m_accelerometer(accelerometer)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
AccelerometerListener::onReadingChanged()
|
||||
{
|
||||
m_accelerometer->readingChanged();
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
/**
|
||||
*
|
||||
* Cocos2D-X Qt 5 Platform
|
||||
*
|
||||
* Copyright (C) 2013 Jolla Ltd.
|
||||
* Contact: Thomas Perl <thomas.perl@jollamobile.com>
|
||||
*
|
||||
* 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 COCOS2DX_ACCELEROMETER_LISTENER_QT5_H
|
||||
#define COCOS2DX_ACCELEROMETER_LISTENER_QT5_H
|
||||
|
||||
#include "CCAccelerometer.h"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
USING_NS_CC;
|
||||
|
||||
class AccelerometerListener : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AccelerometerListener(Accelerometer *accelerometer);
|
||||
|
||||
public slots:
|
||||
void onReadingChanged();
|
||||
|
||||
private:
|
||||
Accelerometer *m_accelerometer;
|
||||
};
|
||||
|
||||
#endif /* COCOS2DX_ACCELEROMETER_LISTENER_QT5_H */
|
|
@ -0,0 +1,100 @@
|
|||
/**
|
||||
*
|
||||
* Cocos2D-X Qt 5 Platform
|
||||
*
|
||||
* Copyright (C) 2013 Jolla Ltd.
|
||||
* Contact: Thomas Perl <thomas.perl@jollamobile.com>
|
||||
*
|
||||
* 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 "CCAccelerometer.h"
|
||||
#include "AccelerometerListener.h"
|
||||
|
||||
#include <QAccelerometer>
|
||||
#include <QAccelerometerReading>
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
static Accelerometer *
|
||||
shared_accelerometer = NULL;
|
||||
|
||||
Accelerometer::Accelerometer()
|
||||
: m_accelerometer(new QAccelerometer)
|
||||
, m_listener(new AccelerometerListener(this))
|
||||
, m_function(nullptr)
|
||||
{
|
||||
QObject::connect(m_accelerometer, SIGNAL(readingChanged()),
|
||||
m_listener, SLOT(onReadingChanged()));
|
||||
}
|
||||
|
||||
Accelerometer::~Accelerometer()
|
||||
{
|
||||
delete m_listener;
|
||||
delete m_accelerometer;
|
||||
}
|
||||
|
||||
Accelerometer *
|
||||
Accelerometer::sharedAccelerometer()
|
||||
{
|
||||
if (shared_accelerometer == NULL) {
|
||||
shared_accelerometer = new Accelerometer;
|
||||
}
|
||||
|
||||
return shared_accelerometer;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Accelerometer::setDelegate(std::function<void(Acceleration*)> function)
|
||||
{
|
||||
m_function = function;
|
||||
}
|
||||
|
||||
void
|
||||
Accelerometer::setAccelerometerInterval(float interval)
|
||||
{
|
||||
if (interval == 0.0) {
|
||||
m_accelerometer->setDataRate(0.0);
|
||||
} else {
|
||||
// Interval is specified in seconds
|
||||
m_accelerometer->setDataRate(1.0 / interval);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Accelerometer::readingChanged()
|
||||
{
|
||||
if (m_function == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
QAccelerometerReading *reading = m_accelerometer->reading();
|
||||
|
||||
Acceleration accel;
|
||||
accel.x = reading->x();
|
||||
accel.y = reading->y();
|
||||
accel.z = reading->z();
|
||||
accel.timestamp = reading->timestamp();
|
||||
|
||||
m_function(&accel);
|
||||
}
|
||||
|
||||
NS_CC_END
|
|
@ -0,0 +1,62 @@
|
|||
/**
|
||||
*
|
||||
* Cocos2D-X Qt 5 Platform
|
||||
*
|
||||
* Copyright (C) 2013 Jolla Ltd.
|
||||
* Contact: Thomas Perl <thomas.perl@jollamobile.com>
|
||||
*
|
||||
* 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 CCACCELEROMETER_QT5_H
|
||||
#define CCACCELEROMETER_QT5_H
|
||||
|
||||
#include "platform/CCCommon.h"
|
||||
#include "platform/CCAccelerometerDelegate.h"
|
||||
#include <functional>
|
||||
|
||||
class QAccelerometer;
|
||||
class AccelerometerListener;
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
class Accelerometer {
|
||||
public:
|
||||
Accelerometer();
|
||||
~Accelerometer();
|
||||
|
||||
static Accelerometer *sharedAccelerometer();
|
||||
|
||||
void setDelegate(std::function<void(Acceleration*)> function);
|
||||
void setAccelerometerInterval(float interval);
|
||||
|
||||
/* Functions to be called from AccelerometerListener */
|
||||
void readingChanged();
|
||||
|
||||
private:
|
||||
QAccelerometer *m_accelerometer;
|
||||
AccelerometerListener *m_listener;
|
||||
std::function<void(Acceleration*)> m_function;
|
||||
};
|
||||
|
||||
NS_CC_END
|
||||
|
||||
#endif /* CCACCELEROMETER_QT5_H */
|
|
@ -0,0 +1,204 @@
|
|||
/**
|
||||
*
|
||||
* Cocos2D-X Qt 5 Platform
|
||||
*
|
||||
* Copyright (C) 2013 Jolla Ltd.
|
||||
* Contact: Thomas Perl <thomas.perl@jollamobile.com>
|
||||
*
|
||||
* 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 "CCApplication.h"
|
||||
#include <unistd.h>
|
||||
#include <sys/time.h>
|
||||
#include <string>
|
||||
#include "CCDirector.h"
|
||||
#include "platform/CCFileUtils.h"
|
||||
|
||||
#include <QGuiApplication>
|
||||
#include <QLocale>
|
||||
#include <QObject>
|
||||
#include <QDir>
|
||||
|
||||
class Cocos2DQt5MainloopIntegration : public QObject {
|
||||
public:
|
||||
Cocos2DQt5MainloopIntegration()
|
||||
: QObject()
|
||||
, m_timer(0)
|
||||
{
|
||||
}
|
||||
|
||||
void setInterval(int interval_ms)
|
||||
{
|
||||
if (m_timer != 0) {
|
||||
killTimer(m_timer);
|
||||
}
|
||||
|
||||
m_timer = startTimer(interval_ms);
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void timerEvent(QTimerEvent *event)
|
||||
{
|
||||
cocos2d::Director::getInstance()->mainLoop();
|
||||
}
|
||||
|
||||
private:
|
||||
int m_timer;
|
||||
};
|
||||
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
// Application singleton
|
||||
static Application *
|
||||
application = NULL;
|
||||
|
||||
static int
|
||||
global_fake_argc = 1;
|
||||
|
||||
static char *
|
||||
global_fake_argv[1];
|
||||
|
||||
// @deprecated Use getInstance() instead
|
||||
Application *
|
||||
Application::sharedApplication()
|
||||
{
|
||||
return getInstance();
|
||||
}
|
||||
|
||||
Application *
|
||||
Application::getInstance()
|
||||
{
|
||||
CC_ASSERT(application != NULL);
|
||||
return application;
|
||||
}
|
||||
|
||||
Application::Application()
|
||||
: m_application(NULL)
|
||||
, m_animationInterval(1000 / 60)
|
||||
, m_resourceRootPath("")
|
||||
, m_mainloop(new Cocos2DQt5MainloopIntegration)
|
||||
{
|
||||
// Inject argv[0] by resolving /proc/self/exe
|
||||
QString filename = QDir("/proc/self/exe").canonicalPath();
|
||||
QByteArray utf8 = filename.toUtf8();
|
||||
global_fake_argv[0] = strdup(utf8.data());
|
||||
|
||||
m_application = new QGuiApplication(global_fake_argc, global_fake_argv);
|
||||
|
||||
CC_ASSERT(application == NULL);
|
||||
application = this;
|
||||
}
|
||||
|
||||
Application::~Application()
|
||||
{
|
||||
delete m_mainloop;
|
||||
delete m_application;
|
||||
|
||||
CC_ASSERT(application == this);
|
||||
application = NULL;
|
||||
}
|
||||
|
||||
int
|
||||
Application::run()
|
||||
{
|
||||
// Initialize instance and cocos2d.
|
||||
if (!applicationDidFinishLaunching()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
m_mainloop->setInterval(m_animationInterval);
|
||||
|
||||
return m_application->exec();
|
||||
}
|
||||
|
||||
void
|
||||
Application::setAnimationInterval(double interval)
|
||||
{
|
||||
// Interval is expressed in seconds
|
||||
m_animationInterval = interval * 1000;
|
||||
|
||||
m_mainloop->setInterval(m_animationInterval);
|
||||
}
|
||||
|
||||
void
|
||||
Application::setResourceRootPath(const std::string &rootResDir)
|
||||
{
|
||||
m_resourceRootPath = rootResDir;
|
||||
if (m_resourceRootPath[m_resourceRootPath.length() - 1] != '/') {
|
||||
m_resourceRootPath += '/';
|
||||
}
|
||||
FileUtils* pFileUtils = FileUtils::getInstance();
|
||||
std::vector<std::string> searchPaths = pFileUtils->getSearchPaths();
|
||||
searchPaths.insert(searchPaths.begin(), m_resourceRootPath);
|
||||
pFileUtils->setSearchPaths(searchPaths);
|
||||
}
|
||||
|
||||
const std::string &
|
||||
Application::getResourceRootPath()
|
||||
{
|
||||
return m_resourceRootPath;
|
||||
}
|
||||
|
||||
TargetPlatform
|
||||
Application::getTargetPlatform()
|
||||
{
|
||||
return kTargetLinux;
|
||||
}
|
||||
|
||||
ccLanguageType
|
||||
Application::getCurrentLanguage()
|
||||
{
|
||||
QLocale locale;
|
||||
|
||||
switch (locale.language()) {
|
||||
case QLocale::English:
|
||||
return kLanguageEnglish;
|
||||
case QLocale::Chinese:
|
||||
return kLanguageChinese;
|
||||
case QLocale::French:
|
||||
return kLanguageFrench;
|
||||
case QLocale::Italian:
|
||||
return kLanguageItalian;
|
||||
case QLocale::German:
|
||||
return kLanguageGerman;
|
||||
case QLocale::Spanish:
|
||||
return kLanguageSpanish;
|
||||
case QLocale::Russian:
|
||||
return kLanguageRussian;
|
||||
case QLocale::Korean:
|
||||
return kLanguageKorean;
|
||||
case QLocale::Japanese:
|
||||
return kLanguageJapanese;
|
||||
case QLocale::Hungarian:
|
||||
return kLanguageHungarian;
|
||||
case QLocale::Portuguese:
|
||||
return kLanguagePortuguese;
|
||||
case QLocale::Arabic:
|
||||
return kLanguageArabic;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return kLanguageEnglish;
|
||||
}
|
||||
|
||||
NS_CC_END
|
|
@ -0,0 +1,95 @@
|
|||
/**
|
||||
*
|
||||
* Cocos2D-X Qt 5 Platform
|
||||
*
|
||||
* Copyright (C) 2013 Jolla Ltd.
|
||||
* Contact: Thomas Perl <thomas.perl@jollamobile.com>
|
||||
*
|
||||
* 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 CCAPPLICATION_QT5_H
|
||||
#define CCAPPLICATION_QT5_H
|
||||
|
||||
#include "platform/CCCommon.h"
|
||||
#include "platform/CCApplicationProtocol.h"
|
||||
#include <string>
|
||||
|
||||
class QGuiApplication;
|
||||
class Cocos2DQt5MainloopIntegration;
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
class Application : public ApplicationProtocol {
|
||||
public:
|
||||
Application();
|
||||
virtual ~Application();
|
||||
|
||||
/**
|
||||
@brief Callback by Director for limit FPS.
|
||||
@interval The time, which expressed in second in second, between current frame and next.
|
||||
*/
|
||||
void setAnimationInterval(double interval);
|
||||
|
||||
/**
|
||||
@brief Run the message loop.
|
||||
*/
|
||||
int run();
|
||||
|
||||
/**
|
||||
@brief Get current application instance.
|
||||
@return Current application instance pointer.
|
||||
*/
|
||||
static Application* getInstance();
|
||||
|
||||
/** @deprecated Use getInstance() instead */
|
||||
CC_DEPRECATED_ATTRIBUTE static Application* sharedApplication();
|
||||
|
||||
/* override functions */
|
||||
virtual ccLanguageType getCurrentLanguage();
|
||||
|
||||
/**
|
||||
* Sets the Resource root path.
|
||||
* @deprecated Please use CCFileUtils::sharedFileUtils()->setSearchPaths() instead.
|
||||
*/
|
||||
CC_DEPRECATED_ATTRIBUTE void setResourceRootPath(const std::string &rootResDir);
|
||||
|
||||
/**
|
||||
* Gets the Resource root path.
|
||||
* @deprecated Please use CCFileUtils::sharedFileUtils()->getSearchPaths() instead.
|
||||
*/
|
||||
CC_DEPRECATED_ATTRIBUTE const std::string &getResourceRootPath();
|
||||
|
||||
/**
|
||||
@brief Get target platform
|
||||
*/
|
||||
virtual TargetPlatform getTargetPlatform();
|
||||
|
||||
protected:
|
||||
QGuiApplication *m_application;
|
||||
long m_animationInterval;
|
||||
std::string m_resourceRootPath;
|
||||
Cocos2DQt5MainloopIntegration *m_mainloop;
|
||||
};
|
||||
|
||||
NS_CC_END
|
||||
|
||||
#endif /* CCAPPLICATION_QT5_H */
|
|
@ -0,0 +1,87 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2010 cocos2d-x.org
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Cocos2D-X Qt 5 Platform
|
||||
Copyright (C) 2013 Jolla Ltd.
|
||||
Contact: Thomas Perl <thomas.perl@jollamobile.com>
|
||||
|
||||
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/CCCommon.h"
|
||||
#include "CCStdC.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
#define MAX_LEN (cocos2d::kMaxLogLen + 1)
|
||||
|
||||
/* @deprecated, use cocos2d::log() instead (see below) */
|
||||
void CCLog(const char * pszFormat, ...)
|
||||
{
|
||||
char szBuf[MAX_LEN];
|
||||
|
||||
va_list ap;
|
||||
va_start(ap, pszFormat);
|
||||
vsnprintf(szBuf, MAX_LEN, pszFormat, ap);
|
||||
va_end(ap);
|
||||
|
||||
// Strip any trailing newlines from log message.
|
||||
size_t len = strlen(szBuf);
|
||||
while (len && szBuf[len-1] == '\n')
|
||||
{
|
||||
szBuf[len-1] = '\0';
|
||||
len--;
|
||||
}
|
||||
|
||||
fprintf(stderr, "cocos2d-x debug info [%s]\n", szBuf);
|
||||
}
|
||||
|
||||
void log(const char * pszFormat, ...)
|
||||
{
|
||||
char szBuf[MAX_LEN];
|
||||
|
||||
va_list ap;
|
||||
va_start(ap, pszFormat);
|
||||
vsnprintf(szBuf, MAX_LEN, pszFormat, ap);
|
||||
va_end(ap);
|
||||
|
||||
// Strip any trailing newlines from log message.
|
||||
size_t len = strlen(szBuf);
|
||||
while (len && szBuf[len-1] == '\n')
|
||||
{
|
||||
szBuf[len-1] = '\0';
|
||||
len--;
|
||||
}
|
||||
|
||||
fprintf(stderr, "cocos2d-x debug info [%s]\n", szBuf);
|
||||
}
|
||||
|
||||
void MessageBox(const char * pszMsg, const char * pszTitle)
|
||||
{
|
||||
log("%s: %s", pszTitle, pszMsg);
|
||||
}
|
||||
|
||||
void LuaLog(const char * pszFormat)
|
||||
{
|
||||
puts(pszFormat);
|
||||
}
|
||||
|
||||
NS_CC_END
|
|
@ -0,0 +1,43 @@
|
|||
/**
|
||||
*
|
||||
* Cocos2D-X Qt 5 Platform
|
||||
*
|
||||
* Copyright (C) 2013 Jolla Ltd.
|
||||
* Contact: Thomas Perl <thomas.perl@jollamobile.com>
|
||||
*
|
||||
* 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/CCDevice.h"
|
||||
|
||||
#include <QGuiApplication>
|
||||
#include <QScreen>
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
int Device::getDPI()
|
||||
{
|
||||
QGuiApplication *app = static_cast<QGuiApplication*>(QGuiApplication::instance());
|
||||
QScreen *screen = app->primaryScreen();
|
||||
return screen->physicalDotsPerInch();
|
||||
}
|
||||
|
||||
NS_CC_END
|
|
@ -0,0 +1,200 @@
|
|||
/**
|
||||
*
|
||||
* Cocos2D-X Qt 5 Platform
|
||||
*
|
||||
* Copyright (C) 2013 Jolla Ltd.
|
||||
* Contact: Thomas Perl <thomas.perl@jollamobile.com>
|
||||
*
|
||||
* 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 "CCEGLView.h"
|
||||
#include "CCGL.h"
|
||||
|
||||
#include "ccMacros.h"
|
||||
#include "CCDirector.h"
|
||||
|
||||
#include "touch_dispatcher/CCTouch.h"
|
||||
#include "touch_dispatcher/CCTouchDispatcher.h"
|
||||
#include "text_input_node/CCIMEDispatcher.h"
|
||||
|
||||
#include <QGuiApplication>
|
||||
#include <QWindow>
|
||||
|
||||
#include <QOpenGLContext>
|
||||
#include <QEvent>
|
||||
#include <QTouchEvent>
|
||||
|
||||
#include <QInputMethod>
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
class Cocos2DQt5OpenGLIntegration : public QWindow {
|
||||
public:
|
||||
Cocos2DQt5OpenGLIntegration(EGLView *view, int width, int height);
|
||||
~Cocos2DQt5OpenGLIntegration();
|
||||
|
||||
virtual void touchEvent(QTouchEvent *event);
|
||||
virtual bool event(QEvent *event);
|
||||
|
||||
void swapBuffers();
|
||||
|
||||
private:
|
||||
EGLView *m_egl_view;
|
||||
QOpenGLContext *m_context;
|
||||
};
|
||||
|
||||
Cocos2DQt5OpenGLIntegration::Cocos2DQt5OpenGLIntegration(EGLView *view, int width, int height)
|
||||
: m_egl_view(view)
|
||||
, m_context(NULL)
|
||||
{
|
||||
setSurfaceType(QSurface::OpenGLSurface);
|
||||
resize(width, height);
|
||||
showFullScreen();
|
||||
|
||||
m_context = new QOpenGLContext(this);
|
||||
m_context->create();
|
||||
m_context->makeCurrent(this);
|
||||
}
|
||||
|
||||
Cocos2DQt5OpenGLIntegration::~Cocos2DQt5OpenGLIntegration()
|
||||
{
|
||||
delete m_context;
|
||||
}
|
||||
|
||||
void
|
||||
Cocos2DQt5OpenGLIntegration::touchEvent(QTouchEvent *event)
|
||||
{
|
||||
foreach (QTouchEvent::TouchPoint point, event->touchPoints()) {
|
||||
int id = point.id();
|
||||
QPointF pos = point.pos();
|
||||
float x = pos.x();
|
||||
float y = pos.y();
|
||||
Qt::TouchPointState state = point.state();
|
||||
|
||||
switch (state) {
|
||||
case Qt::TouchPointPressed:
|
||||
m_egl_view->handleTouchesBegin(1, &id, &x, &y);
|
||||
break;
|
||||
case Qt::TouchPointMoved:
|
||||
m_egl_view->handleTouchesMove(1, &id, &x, &y);
|
||||
break;
|
||||
case Qt::TouchPointStationary:
|
||||
// Do nothing
|
||||
break;
|
||||
case Qt::TouchPointReleased:
|
||||
m_egl_view->handleTouchesEnd(1, &id, &x, &y);
|
||||
break;
|
||||
default:
|
||||
// Do nothing
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
Cocos2DQt5OpenGLIntegration::event(QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::Close) {
|
||||
Director::getInstance()->end();
|
||||
}
|
||||
|
||||
return QWindow::event(event);
|
||||
}
|
||||
|
||||
void
|
||||
Cocos2DQt5OpenGLIntegration::swapBuffers()
|
||||
{
|
||||
m_context->swapBuffers(this);
|
||||
m_context->makeCurrent(this);
|
||||
}
|
||||
|
||||
|
||||
/* Global EGLView singleton for this module */
|
||||
static EGLView *
|
||||
egl_view = NULL;
|
||||
|
||||
|
||||
/** @deprecated Use getInstance() instead */
|
||||
EGLView *
|
||||
EGLView::sharedOpenGLView()
|
||||
{
|
||||
return getInstance();
|
||||
}
|
||||
|
||||
EGLView *
|
||||
EGLView::getInstance()
|
||||
{
|
||||
if (egl_view == NULL) {
|
||||
egl_view = new EGLView;
|
||||
}
|
||||
|
||||
return egl_view;
|
||||
}
|
||||
|
||||
|
||||
EGLView::EGLView()
|
||||
: m_integration(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
EGLView::~EGLView()
|
||||
{
|
||||
if (m_integration) {
|
||||
delete m_integration;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
EGLView::setFrameSize(float width, float height)
|
||||
{
|
||||
if (m_integration == NULL) {
|
||||
m_integration = new Cocos2DQt5OpenGLIntegration(this,
|
||||
(int)width, (int)height);
|
||||
} else {
|
||||
m_integration->resize(width, height);
|
||||
}
|
||||
|
||||
EGLViewProtocol::setFrameSize(width, height);
|
||||
}
|
||||
|
||||
void
|
||||
EGLView::swapBuffers()
|
||||
{
|
||||
if (m_integration != NULL) {
|
||||
m_integration->swapBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
EGLView::setIMEKeyboardState(bool bOpen)
|
||||
{
|
||||
QGuiApplication *app = static_cast<QGuiApplication*>(QGuiApplication::instance());
|
||||
app->inputMethod()->setVisible(bOpen);
|
||||
}
|
||||
|
||||
void
|
||||
EGLView::end()
|
||||
{
|
||||
QGuiApplication::exit(0);
|
||||
}
|
||||
|
||||
NS_CC_END
|
|
@ -0,0 +1,63 @@
|
|||
/**
|
||||
*
|
||||
* Cocos2D-X Qt 5 Platform
|
||||
*
|
||||
* Copyright (C) 2013 Jolla Ltd.
|
||||
* Contact: Thomas Perl <thomas.perl@jollamobile.com>
|
||||
*
|
||||
* 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 CCEGLVIEW_QT5_H
|
||||
#define CCEGLVIEW_QT5_H
|
||||
|
||||
#include "platform/CCCommon.h"
|
||||
#include "cocoa/CCGeometry.h"
|
||||
#include "platform/CCEGLViewProtocol.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
class Cocos2DQt5OpenGLIntegration;
|
||||
|
||||
class EGLView : public EGLViewProtocol {
|
||||
public:
|
||||
EGLView();
|
||||
virtual ~EGLView();
|
||||
|
||||
static EGLView *getInstance();
|
||||
|
||||
/** @deprecated Use getInstance() instead */
|
||||
CC_DEPRECATED_ATTRIBUTE static EGLView *sharedOpenGLView();
|
||||
|
||||
virtual bool isOpenGLReady() { return (m_integration != NULL); }
|
||||
|
||||
virtual void setFrameSize(float width, float height);
|
||||
virtual void swapBuffers();
|
||||
virtual void setIMEKeyboardState(bool bOpen);
|
||||
virtual void end();
|
||||
|
||||
private:
|
||||
Cocos2DQt5OpenGLIntegration *m_integration;
|
||||
};
|
||||
|
||||
NS_CC_END
|
||||
|
||||
#endif /* CCEGLVIEW_QT5_H */
|
|
@ -0,0 +1,114 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2010 cocos2d-x.org
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Cocos2D-X Qt 5 Platform
|
||||
Copyright (C) 2013 Jolla Ltd.
|
||||
Contact: Thomas Perl <thomas.perl@jollamobile.com>
|
||||
|
||||
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/CCFileUtils.h"
|
||||
#include "platform/CCPlatformMacros.h"
|
||||
#include "platform/CCCommon.h"
|
||||
#include "ccTypes.h"
|
||||
#include "ccTypeInfo.h"
|
||||
#include "ccMacros.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <QFile>
|
||||
#include <QDir>
|
||||
#include <QStandardPaths>
|
||||
#include <QDebug>
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
class CC_DLL FileUtilsQt5 : public FileUtils
|
||||
{
|
||||
public:
|
||||
FileUtilsQt5();
|
||||
|
||||
/* override funtions */
|
||||
virtual bool init();
|
||||
virtual std::string getWritablePath();
|
||||
virtual bool isFileExist(const std::string& strFilePath);
|
||||
};
|
||||
|
||||
FileUtils *
|
||||
FileUtils::getInstance()
|
||||
{
|
||||
if (s_sharedFileUtils == NULL)
|
||||
{
|
||||
s_sharedFileUtils = new FileUtilsQt5();
|
||||
s_sharedFileUtils->init();
|
||||
}
|
||||
return s_sharedFileUtils;
|
||||
}
|
||||
|
||||
FileUtilsQt5::FileUtilsQt5()
|
||||
{
|
||||
}
|
||||
|
||||
bool
|
||||
FileUtilsQt5::init()
|
||||
{
|
||||
// Determine directory of the application executable
|
||||
QDir app_dir = QDir("/proc/self/exe").canonicalPath();
|
||||
app_dir.cdUp();
|
||||
|
||||
// Resources should be placed alongside the binary (same directory)
|
||||
QString path = app_dir.path() + "/Resources/";
|
||||
_defaultResRootPath = path.toStdString();
|
||||
|
||||
return FileUtils::init();
|
||||
}
|
||||
|
||||
std::string
|
||||
FileUtilsQt5::getWritablePath()
|
||||
{
|
||||
QDir dir(QStandardPaths::writableLocation(QStandardPaths::DataLocation));
|
||||
|
||||
// Create directory if it does not exist yet
|
||||
if (!dir.exists()) {
|
||||
dir.mkpath(".");
|
||||
}
|
||||
|
||||
return dir.path().toStdString();
|
||||
}
|
||||
|
||||
bool FileUtilsQt5::isFileExist(const std::string& strFilePath)
|
||||
{
|
||||
QString filePath = QString::fromStdString(strFilePath);
|
||||
|
||||
// Try filename without any path first
|
||||
if (QFile(filePath).exists()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// If not found, look for file in _defaultResRootPath
|
||||
QString defaultResRootPath = QString::fromStdString(_defaultResRootPath);
|
||||
return QFile(QDir(defaultResRootPath).filePath(filePath)).exists();
|
||||
}
|
||||
|
||||
NS_CC_END
|
|
@ -0,0 +1,16 @@
|
|||
#ifndef __CCGL_H__
|
||||
#define __CCGL_H__
|
||||
|
||||
#include <GLES2/gl2.h>
|
||||
#include <GLES2/gl2ext.h>
|
||||
|
||||
#define GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_OES
|
||||
|
||||
#define glClearDepth glClearDepthf
|
||||
|
||||
// android defines GL_BGRA_EXT but not GL_BRGA
|
||||
#ifndef GL_BGRA
|
||||
#define GL_BGRA 0x80E1
|
||||
#endif
|
||||
|
||||
#endif // __CCGL_H__
|
|
@ -0,0 +1,47 @@
|
|||
/**
|
||||
*
|
||||
* Cocos2D-X Qt 5 Platform
|
||||
*
|
||||
* Copyright (C) 2013 Jolla Ltd.
|
||||
* Contact: Thomas Perl <thomas.perl@jollamobile.com>
|
||||
*
|
||||
* 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 __CCPLATFORMDEFINE_H__
|
||||
#define __CCPLATFORMDEFINE_H__
|
||||
|
||||
// Adapted from platform/linux/CCPlatformDefine.h
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#if defined(_USRDLL)
|
||||
# define CC_DLL __attribute__ ((visibility ("default")))
|
||||
#else
|
||||
# define CC_DLL __attribute__ ((visibility ("default")))
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#define CC_ASSERT(cond) assert(cond)
|
||||
#define CC_UNUSED_PARAM(unusedparam) (void)unusedparam
|
||||
|
||||
#endif /* __CCPLATFORMDEFINE_H__*/
|
|
@ -0,0 +1,58 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2010 cocos2d-x.org
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Cocos2D-X Qt 5 Platform
|
||||
Copyright (C) 2013 Jolla Ltd.
|
||||
Contact: Thomas Perl <thomas.perl@jollamobile.com>
|
||||
|
||||
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_STD_C_H__
|
||||
#define __CC_STD_C_H__
|
||||
|
||||
#include "platform/CCPlatformMacros.h"
|
||||
|
||||
#include <float.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(x,y) (((x) > (y)) ? (y) : (x))
|
||||
#endif // MIN
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(x,y) (((x) < (y)) ? (y) : (x))
|
||||
#endif // MAX
|
||||
|
||||
// some function linux do not have
|
||||
#define tanf tan
|
||||
#define sqrtf sqrt
|
||||
#define cosf cos
|
||||
#define sinf sin
|
||||
|
||||
#endif // __CC_STD_C_H__
|
|
@ -84,12 +84,12 @@ Application* Application::sharedApplication()
|
|||
return Application::getInstance();
|
||||
}
|
||||
|
||||
ccLanguageType Application::getCurrentLanguage()
|
||||
LanguageType Application::getCurrentLanguage()
|
||||
{
|
||||
result r = E_SUCCESS;
|
||||
int index = 0;
|
||||
Tizen::Base::String localelanguageCode, languageCode;
|
||||
ccLanguageType ret = kLanguageEnglish;
|
||||
LanguageType ret = LanguageType::ENGLISH;
|
||||
|
||||
r = SettingInfo::GetValue(L"http://tizen.org/setting/locale.language", localelanguageCode);
|
||||
TryLog(!IsFailed(r), "[%s] Cannot get the current language setting", GetErrorMessage(r));
|
||||
|
@ -98,66 +98,66 @@ ccLanguageType Application::getCurrentLanguage()
|
|||
|
||||
if (0 == languageCode.CompareTo(L"zho"))
|
||||
{
|
||||
ret = kLanguageChinese;
|
||||
ret = LanguageType::CHINESE;
|
||||
}
|
||||
else if (0 == languageCode.CompareTo(L"eng"))
|
||||
{
|
||||
ret = kLanguageEnglish;
|
||||
ret = LanguageType::ENGLISH;
|
||||
}
|
||||
else if (0 == languageCode.CompareTo(L"fre"))
|
||||
{
|
||||
ret = kLanguageFrench;
|
||||
ret = LanguageType::FRENCH;
|
||||
}
|
||||
else if (0 == languageCode.CompareTo(L"ita"))
|
||||
{
|
||||
ret = kLanguageItalian;
|
||||
ret = LanguageType::ITALIAN;
|
||||
}
|
||||
else if (0 == languageCode.CompareTo(L"deu"))
|
||||
{
|
||||
ret = kLanguageGerman;
|
||||
ret = LanguageType::GERMAN;
|
||||
}
|
||||
else if (0 == languageCode.CompareTo(L"spa"))
|
||||
{
|
||||
ret = kLanguageSpanish;
|
||||
ret = LanguageType::SPANISH;
|
||||
}
|
||||
else if (0 == languageCode.CompareTo(L"rus"))
|
||||
{
|
||||
ret = kLanguageRussian;
|
||||
ret = LanguageType::RUSSIAN;
|
||||
}
|
||||
else if (0 == languageCode.CompareTo(L"kor"))
|
||||
{
|
||||
ret = kLanguageKorean;
|
||||
ret = LanguageType::KOREAN;
|
||||
}
|
||||
else if (0 == languageCode.CompareTo(L"jpn"))
|
||||
{
|
||||
ret = kLanguageJapanese;
|
||||
ret = LanguageType::JAPANESE;
|
||||
}
|
||||
else if (0 == languageCode.CompareTo(L"hun"))
|
||||
{
|
||||
ret = kLanguageHungarian;
|
||||
ret = LanguageType::HUNGARIAN;
|
||||
}
|
||||
else if (0 == languageCode.CompareTo(L"por"))
|
||||
{
|
||||
ret = kLanguagePortuguese;
|
||||
ret = LanguageType::PORTUGUESE;
|
||||
}
|
||||
else if (0 == languageCode.CompareTo(L"ara"))
|
||||
{
|
||||
ret = kLanguageArabic;
|
||||
ret = LanguageType::ARABIC;
|
||||
}
|
||||
else if (0 == languageCode.CompareTo(L"nor"))
|
||||
{
|
||||
ret = kLanguageNorwegian;
|
||||
ret = LanguageType::NORWEGIAN;
|
||||
}
|
||||
else if (0 == languageCode.CompareTo(L"pol"))
|
||||
{
|
||||
ret = kLanguagePolish;
|
||||
ret = LanguageType::POLISH;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
TargetPlatform Application::getTargetPlatform()
|
||||
Application::Platform Application::getTargetPlatform()
|
||||
{
|
||||
return kTargetTizen;
|
||||
return Platform::OS_TIZEN;
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -66,12 +66,12 @@ public:
|
|||
@brief Get current language config
|
||||
@return Current language config
|
||||
*/
|
||||
virtual ccLanguageType getCurrentLanguage();
|
||||
virtual LanguageType getCurrentLanguage();
|
||||
|
||||
/**
|
||||
@brief Get target platform
|
||||
*/
|
||||
virtual TargetPlatform getTargetPlatform();
|
||||
virtual Platform getTargetPlatform();
|
||||
|
||||
protected:
|
||||
static Application * sm_pSharedApplication;
|
||||
|
|
|
@ -45,7 +45,12 @@ FileUtils* FileUtils::getInstance()
|
|||
if (s_sharedFileUtils == NULL)
|
||||
{
|
||||
s_sharedFileUtils = new FileUtilsTizen();
|
||||
s_sharedFileUtils->init();
|
||||
if(!s_sharedFileUtils->init())
|
||||
{
|
||||
delete s_sharedFileUtils;
|
||||
s_sharedFileUtils = NULL;
|
||||
CCLOG("ERROR: Could not init CCFileUtilsTizen");
|
||||
}
|
||||
}
|
||||
return s_sharedFileUtils;
|
||||
}
|
||||
|
|
|
@ -240,11 +240,11 @@ public:
|
|||
/**
|
||||
* compute the start pos of every line
|
||||
*/
|
||||
int computeLineStart(FT_Face face, Image::ETextAlign eAlignMask, int line) {
|
||||
int computeLineStart(FT_Face face, Image::TextAlign eAlignMask, int line) {
|
||||
int lineWidth = textLines.at(line).lineWidth;
|
||||
if (eAlignMask == Image::kAlignCenter || eAlignMask == Image::kAlignTop || eAlignMask == Image::kAlignBottom) {
|
||||
if (eAlignMask == Image::TextAlign::CENTER || eAlignMask == Image::TextAlign::TOP || eAlignMask == Image::TextAlign::BOTTOM) {
|
||||
return (iMaxLineWidth - lineWidth) / 2;
|
||||
} else if (eAlignMask == Image::kAlignRight || eAlignMask == Image::kAlignTopRight || eAlignMask == Image::kAlignBottomRight) {
|
||||
} else if (eAlignMask == Image::TextAlign::RIGHT || eAlignMask == Image::TextAlign::TO_RIGHT || eAlignMask == Image::TextAlign::BOTTOM_RIGHT) {
|
||||
return (iMaxLineWidth - lineWidth);
|
||||
}
|
||||
|
||||
|
@ -252,12 +252,12 @@ public:
|
|||
return 0;
|
||||
}
|
||||
|
||||
int computeLineStartY( FT_Face face, Image::ETextAlign eAlignMask, int txtHeight, int borderHeight ){
|
||||
int computeLineStartY( FT_Face face, Image::TextAlign eAlignMask, int txtHeight, int borderHeight ){
|
||||
int baseLinePos = ceilf(FT_MulFix( face->bbox.yMax, face->size->metrics.y_scale )/64.0f);
|
||||
if (eAlignMask == Image::kAlignCenter || eAlignMask == Image::kAlignLeft || eAlignMask == Image::kAlignRight) {
|
||||
if (eAlignMask == Image::TextAlign::CENTER || eAlignMask == Image::TextAlign::LEFT || eAlignMask == Image::TextAlign::RIGHT) {
|
||||
//vertical center
|
||||
return (borderHeight - txtHeight) / 2 + baseLinePos;
|
||||
} else if (eAlignMask == Image::kAlignBottomRight || eAlignMask == Image::kAlignBottom || eAlignMask == Image::kAlignBottomLeft) {
|
||||
} else if (eAlignMask == Image::TextAlign::BOTTOM_RIGHT || eAlignMask == Image::TextAlign::BOTTOM || eAlignMask == Image::TextAlign::BOTTOM_LEFT) {
|
||||
//vertical bottom
|
||||
return borderHeight - txtHeight + baseLinePos;
|
||||
}
|
||||
|
@ -313,7 +313,7 @@ public:
|
|||
return family_name;
|
||||
}
|
||||
|
||||
bool getBitmap(const char *text, int nWidth, int nHeight, Image::ETextAlign eAlignMask, const char * pFontName, float fontSize) {
|
||||
bool getBitmap(const char *text, int nWidth, int nHeight, Image::TextAlign eAlignMask, const char * pFontName, float fontSize) {
|
||||
if (libError) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -112,9 +112,9 @@ Application* Application::sharedApplication()
|
|||
return Application::getInstance();
|
||||
}
|
||||
|
||||
ccLanguageType Application::getCurrentLanguage()
|
||||
LanguageType Application::getCurrentLanguage()
|
||||
{
|
||||
ccLanguageType ret = kLanguageEnglish;
|
||||
LanguageType ret = LanguageType::ENGLISH;
|
||||
|
||||
LCID localeID = GetUserDefaultLCID();
|
||||
unsigned short primaryLanguageID = localeID & 0xFF;
|
||||
|
@ -122,55 +122,55 @@ ccLanguageType Application::getCurrentLanguage()
|
|||
switch (primaryLanguageID)
|
||||
{
|
||||
case LANG_CHINESE:
|
||||
ret = kLanguageChinese;
|
||||
ret = LanguageType::CHINESE;
|
||||
break;
|
||||
case LANG_ENGLISH:
|
||||
ret = kLanguageEnglish;
|
||||
ret = LanguageType::ENGLISH;
|
||||
break;
|
||||
case LANG_FRENCH:
|
||||
ret = kLanguageFrench;
|
||||
ret = LanguageType::FRENCH;
|
||||
break;
|
||||
case LANG_ITALIAN:
|
||||
ret = kLanguageItalian;
|
||||
ret = LanguageType::ITALIAN;
|
||||
break;
|
||||
case LANG_GERMAN:
|
||||
ret = kLanguageGerman;
|
||||
ret = LanguageType::GERMAN;
|
||||
break;
|
||||
case LANG_SPANISH:
|
||||
ret = kLanguageSpanish;
|
||||
ret = LanguageType::SPANISH;
|
||||
break;
|
||||
case LANG_RUSSIAN:
|
||||
ret = kLanguageRussian;
|
||||
ret = LanguageType::RUSSIAN;
|
||||
break;
|
||||
case LANG_KOREAN:
|
||||
ret = kLanguageKorean;
|
||||
ret = LanguageType::KOREAN;
|
||||
break;
|
||||
case LANG_JAPANESE:
|
||||
ret = kLanguageJapanese;
|
||||
ret = LanguageType::JAPANESE;
|
||||
break;
|
||||
case LANG_HUNGARIAN:
|
||||
ret = kLanguageHungarian;
|
||||
ret = LanguageType::HUNGARIAN;
|
||||
break;
|
||||
case LANG_PORTUGUESE:
|
||||
ret = kLanguagePortuguese;
|
||||
ret = LanguageType::PORTUGUESE;
|
||||
break;
|
||||
case LANG_ARABIC:
|
||||
ret = kLanguageArabic;
|
||||
ret = LanguageType::ARABIC;
|
||||
break;
|
||||
case LANG_NORWEGIAN:
|
||||
ret = kLanguageNorwegian;
|
||||
ret = LanguageType::NORWEGIAN;
|
||||
break;
|
||||
case LANG_POLISH:
|
||||
ret = kLanguagePolish;
|
||||
ret = LanguageType::POLISH;
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
TargetPlatform Application::getTargetPlatform()
|
||||
Application::Platform Application::getTargetPlatform()
|
||||
{
|
||||
return kTargetWindows;
|
||||
return Platform::OS_WINDOWS;
|
||||
}
|
||||
|
||||
void Application::setResourceRootPath(const std::string& rootResDir)
|
||||
|
|
|
@ -32,12 +32,12 @@ public:
|
|||
|
||||
/* override functions */
|
||||
virtual void setAnimationInterval(double interval);
|
||||
virtual ccLanguageType getCurrentLanguage();
|
||||
virtual LanguageType getCurrentLanguage();
|
||||
|
||||
/**
|
||||
@brief Get target platform
|
||||
*/
|
||||
virtual TargetPlatform getTargetPlatform();
|
||||
virtual Platform getTargetPlatform();
|
||||
|
||||
/**
|
||||
* Sets the Resource root path.
|
||||
|
|
|
@ -48,7 +48,12 @@ FileUtils* FileUtils::getInstance()
|
|||
if (s_sharedFileUtils == NULL)
|
||||
{
|
||||
s_sharedFileUtils = new FileUtilsWin32();
|
||||
s_sharedFileUtils->init();
|
||||
if(!s_sharedFileUtils->init())
|
||||
{
|
||||
delete s_sharedFileUtils;
|
||||
s_sharedFileUtils = NULL;
|
||||
CCLOG("ERROR: Could not init CCFileUtilsWin32");
|
||||
}
|
||||
}
|
||||
return s_sharedFileUtils;
|
||||
}
|
||||
|
|
|
@ -249,8 +249,8 @@ public:
|
|||
CC_BREAK_IF(! pszText);
|
||||
|
||||
DWORD dwFmt = DT_WORDBREAK;
|
||||
DWORD dwHoriFlag = eAlign & 0x0f;
|
||||
DWORD dwVertFlag = (eAlign & 0xf0) >> 4;
|
||||
DWORD dwHoriFlag = (int)eAlign & 0x0f;
|
||||
DWORD dwVertFlag = ((int)eAlign & 0xf0) >> 4;
|
||||
|
||||
switch (dwHoriFlag)
|
||||
{
|
||||
|
@ -370,7 +370,7 @@ bool Image::initWithString(
|
|||
const char * pText,
|
||||
int nWidth/* = 0*/,
|
||||
int nHeight/* = 0*/,
|
||||
TextAlign eAlignMask/* = kAlignCenter*/,
|
||||
TextAlign eAlignMask/* = kAlignCenter*/,
|
||||
const char * pFontName/* = nil*/,
|
||||
int nSize/* = 0*/)
|
||||
{
|
||||
|
|
|
@ -99,13 +99,25 @@ NS_CC_END
|
|||
|
||||
#endif // __MINGW32__
|
||||
|
||||
// Conflicted with cocos2d::MessageBox, so we need to undef it.
|
||||
#ifdef MessageBox
|
||||
#undef MessageBox
|
||||
#endif
|
||||
|
||||
// Conflicted with ParticleSystem::PositionType::RELATIVE, so we need to undef it.
|
||||
#ifdef RELATIVE
|
||||
#undef RELATIVE
|
||||
#endif
|
||||
|
||||
// Conflicted with CCBReader::SizeType::RELATIVE and CCBReader::ScaleType::RELATIVE, so we need to undef it.
|
||||
#ifdef ABSOLUTE
|
||||
#undef ABSOLUTE
|
||||
#endif
|
||||
|
||||
// Conflicted with HttpRequest::Type::DELETE, so we need to undef it.
|
||||
#ifdef DELETE
|
||||
#undef DELETE
|
||||
#endif
|
||||
|
||||
#endif // __CC_STD_C_H__
|
||||
|
||||
|
|
|
@ -0,0 +1,166 @@
|
|||
|
||||
include(common.pri)
|
||||
|
||||
TEMPLATE = lib
|
||||
|
||||
# Uncomment the following line to build Cocos2D-X as static library
|
||||
#CONFIG += static
|
||||
|
||||
LIBS += $${COCOS2DX_SYSTEM_LIBS}
|
||||
|
||||
#SOURCES += $$files(../Collision/*.cpp)
|
||||
|
||||
SOURCES += ../actions/CCAction.cpp \
|
||||
../actions/CCActionCamera.cpp \
|
||||
../actions/CCActionEase.cpp \
|
||||
../actions/CCActionGrid.cpp \
|
||||
../actions/CCActionGrid3D.cpp \
|
||||
../actions/CCActionInstant.cpp \
|
||||
../actions/CCActionInterval.cpp \
|
||||
../actions/CCActionManager.cpp \
|
||||
../actions/CCActionPageTurn3D.cpp \
|
||||
../actions/CCActionProgressTimer.cpp \
|
||||
../actions/CCActionTiledGrid.cpp \
|
||||
../actions/CCActionCatmullRom.cpp \
|
||||
../actions/CCActionTween.cpp \
|
||||
../base_nodes/CCAtlasNode.cpp \
|
||||
../base_nodes/CCNode.cpp \
|
||||
../cocoa/CCAffineTransform.cpp \
|
||||
../cocoa/CCAutoreleasePool.cpp \
|
||||
../cocoa/CCGeometry.cpp \
|
||||
../cocoa/CCNS.cpp \
|
||||
../cocoa/CCObject.cpp \
|
||||
../cocoa/CCSet.cpp \
|
||||
../cocoa/CCArray.cpp \
|
||||
../cocoa/CCDictionary.cpp \
|
||||
../cocoa/CCString.cpp \
|
||||
../cocoa/CCDataVisitor.cpp \
|
||||
../cocoa/CCData.cpp \
|
||||
../draw_nodes/CCDrawingPrimitives.cpp \
|
||||
../draw_nodes/CCDrawNode.cpp \
|
||||
../effects/CCGrabber.cpp \
|
||||
../effects/CCGrid.cpp \
|
||||
../keypad_dispatcher/CCKeypadDelegate.cpp \
|
||||
../keypad_dispatcher/CCKeypadDispatcher.cpp \
|
||||
../keyboard_dispatcher/CCKeyboardDispatcher.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/CCTransition.cpp \
|
||||
../layers_scenes_transitions_nodes/CCTransitionPageTurn.cpp \
|
||||
../layers_scenes_transitions_nodes/CCTransitionProgress.cpp \
|
||||
../menu_nodes/CCMenu.cpp \
|
||||
../menu_nodes/CCMenuItem.cpp \
|
||||
../misc_nodes/CCMotionStreak.cpp \
|
||||
../misc_nodes/CCProgressTimer.cpp \
|
||||
../misc_nodes/CCClippingNode.cpp \
|
||||
../misc_nodes/CCRenderTexture.cpp \
|
||||
../particle_nodes/CCParticleExamples.cpp \
|
||||
../particle_nodes/CCParticleSystem.cpp \
|
||||
../particle_nodes/CCParticleSystemQuad.cpp \
|
||||
../particle_nodes/CCParticleBatchNode.cpp \
|
||||
../platform/CCSAXParser.cpp \
|
||||
../platform/CCThread.cpp \
|
||||
../platform/CCImageCommonWebp.cpp \
|
||||
../platform/CCEGLViewProtocol.cpp \
|
||||
../platform/CCFileUtils.cpp \
|
||||
../platform/qt5/CCCommon.cpp \
|
||||
../platform/qt5/CCFileUtilsQt5.cpp \
|
||||
../platform/qt5/CCEGLView.cpp \
|
||||
../platform/qt5/CCDevice.cpp \
|
||||
../platform/qt5/CCApplication.cpp \
|
||||
../platform/qt5/CCAccelerometer.cpp \
|
||||
../platform/qt5/AccelerometerListener.cpp \
|
||||
../platform/linux/CCImage.cpp \
|
||||
../script_support/CCScriptSupport.cpp \
|
||||
../sprite_nodes/CCAnimation.cpp \
|
||||
../sprite_nodes/CCAnimationCache.cpp \
|
||||
../sprite_nodes/CCSprite.cpp \
|
||||
../sprite_nodes/CCSpriteBatchNode.cpp \
|
||||
../sprite_nodes/CCSpriteFrame.cpp \
|
||||
../sprite_nodes/CCSpriteFrameCache.cpp \
|
||||
../support/ccUTF8.cpp \
|
||||
../support/CCProfiling.cpp \
|
||||
../support/user_default/CCUserDefault.cpp \
|
||||
../support/TransformUtils.cpp \
|
||||
../support/base64.cpp \
|
||||
../support/ccUtils.cpp \
|
||||
../support/CCVertex.cpp \
|
||||
../support/CCNotificationCenter.cpp \
|
||||
../support/image_support/TGAlib.cpp \
|
||||
../support/tinyxml2/tinyxml2.cpp \
|
||||
../support/zip_support/ZipUtils.cpp \
|
||||
../support/zip_support/ioapi.cpp \
|
||||
../support/zip_support/unzip.cpp \
|
||||
../support/data_support/ccCArray.cpp \
|
||||
../support/component/CCComponent.cpp \
|
||||
../support/component/CCComponentContainer.cpp \
|
||||
../text_input_node/CCIMEDispatcher.cpp \
|
||||
../text_input_node/CCTextFieldTTF.cpp \
|
||||
../textures/CCTexture2D.cpp \
|
||||
../textures/CCTextureAtlas.cpp \
|
||||
../textures/CCTextureCache.cpp \
|
||||
../textures/CCTextureETC.cpp \
|
||||
../textures/CCTexturePVR.cpp \
|
||||
../textures/etc/etc1.cpp \
|
||||
../tilemap_parallax_nodes/CCParallaxNode.cpp \
|
||||
../tilemap_parallax_nodes/CCTMXLayer.cpp \
|
||||
../tilemap_parallax_nodes/CCTMXObjectGroup.cpp \
|
||||
../tilemap_parallax_nodes/CCTMXTiledMap.cpp \
|
||||
../tilemap_parallax_nodes/CCTMXXMLParser.cpp \
|
||||
../tilemap_parallax_nodes/CCTileMapAtlas.cpp \
|
||||
../touch_dispatcher/CCTouchDispatcher.cpp \
|
||||
../touch_dispatcher/CCTouchHandler.cpp \
|
||||
../touch_dispatcher/CCTouch.cpp \
|
||||
../shaders/CCGLProgram.cpp \
|
||||
../shaders/ccGLStateCache.cpp \
|
||||
../shaders/CCShaderCache.cpp \
|
||||
../shaders/ccShaders.cpp \
|
||||
../kazmath/src/aabb.c \
|
||||
../kazmath/src/plane.c \
|
||||
../kazmath/src/vec2.c \
|
||||
../kazmath/src/mat3.c \
|
||||
../kazmath/src/quaternion.c \
|
||||
../kazmath/src/vec3.c \
|
||||
../kazmath/src/mat4.c \
|
||||
../kazmath/src/ray2.c \
|
||||
../kazmath/src/vec4.c \
|
||||
../kazmath/src/neon_matrix_impl.c \
|
||||
../kazmath/src/utility.c \
|
||||
../kazmath/src/GL/mat4stack.c \
|
||||
../kazmath/src/GL/matrix.c \
|
||||
../CCCamera.cpp \
|
||||
../CCConfiguration.cpp \
|
||||
../CCDirector.cpp \
|
||||
../CCScheduler.cpp \
|
||||
../ccFPSImages.c \
|
||||
../ccTypes.cpp \
|
||||
../cocos2d.cpp
|
||||
|
||||
# Headers with QObject subclasses (will be processed by moc)
|
||||
HEADERS += ../platform/qt5/AccelerometerListener.h
|
||||
|
||||
# WebP
|
||||
INCLUDEPATH += ../../external/libwebp/webp
|
||||
SOURCES += $$files(../../external/libwebp/dec/*.c)
|
||||
SOURCES += $$files(../../external/libwebp/dsp/*.c)
|
||||
SOURCES += $$files(../../external/libwebp/utils/*.c)
|
||||
|
||||
# FreeType (FIXME: use pkg-config)
|
||||
INCLUDEPATH += /usr/include/freetype2
|
||||
|
||||
INCLUDEPATH += ../../extensions
|
||||
INCLUDEPATH += ../../extensions/CCBReader
|
||||
INCLUDEPATH += ../../extensions/GUI/CCControlExtension
|
||||
INCLUDEPATH += ../../extensions/GUI/CCControlExtension
|
||||
INCLUDEPATH += ../../external/chipmunk/include/chipmunk
|
||||
INCLUDEPATH += ../../extensions/network
|
||||
INCLUDEPATH += ../../extensions/Components
|
||||
|
||||
TARGET = $${LIB_OUTPUT_DIR}/cocos2d
|
||||
|
||||
INSTALLS += target
|
||||
target.path = $${LIB_INSTALL_DIR}
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
|
||||
DEFINES += CC_TARGET_QT5
|
||||
|
||||
CONFIG += silent
|
||||
|
||||
# Disable some warnings to make compiler output easier to read during development
|
||||
DISABLED_WARNINGS = -Wno-ignored-qualifiers -Wno-unused-parameter -Wno-psabi
|
||||
QMAKE_CXXFLAGS += $${DISABLED_WARNINGS} -Wno-reorder
|
||||
QMAKE_CFLAGS += $${DISABLED_WARNINGS}
|
||||
|
||||
# C++11 support (GCC 4.6; for newer versions, change to -std=c++11)
|
||||
QMAKE_CXXFLAGS += -Doverride= -std=c++0x
|
||||
|
||||
OS_TYPE = linux
|
||||
|
||||
CONFIG(debug, debug|release) {
|
||||
BUILD_TYPE = debug
|
||||
} else {
|
||||
BUILD_TYPE = release
|
||||
}
|
||||
|
||||
OBJECTS_DIR = obj/$${BUILD_TYPE}
|
||||
MOC_DIR = obj/$${BUILD_TYPE}
|
||||
LIB_OUTPUT_DIR = $${PWD}/../../lib/$${OS_TYPE}/$${BUILD_TYPE}
|
||||
|
||||
# Installation location of binaries
|
||||
LIB_INSTALL_DIR = /usr/lib
|
||||
BIN_INSTALL_DIR = /usr/bin
|
||||
DESKTOP_INSTALL_DIR = /usr/share/applications
|
||||
|
||||
INCLUDEPATH += $${PWD}/..
|
||||
INCLUDEPATH += $${PWD}/../include
|
||||
INCLUDEPATH += $${PWD}/../platform
|
||||
INCLUDEPATH += $${PWD}/../platform/qt5
|
||||
INCLUDEPATH += $${PWD}/../kazmath/include
|
||||
|
||||
COCOS2DX_SYSTEM_LIBS += -lz
|
||||
COCOS2DX_SYSTEM_LIBS += -ljpeg -ltiff -lpng
|
||||
COCOS2DX_SYSTEM_LIBS += -lfontconfig -lfreetype
|
||||
|
||||
# Sensors module needed for CCAccelerometer
|
||||
QT += sensors
|
||||
|
||||
LINK_AGAINST_COCOS2DX = -L$${LIB_OUTPUT_DIR} -lcocos2d $${COCOS2DX_SYSTEM_LIBS}
|
||||
|
||||
# CocosDenshion (audio library)
|
||||
QT += multimedia
|
||||
INCLUDEPATH += $${PWD}/../../CocosDenshion/include
|
||||
LINK_AGAINST_COCOSDENSHION = -lcocosdenshion
|
||||
|
||||
# Extensions library
|
||||
INCLUDEPATH += $${PWD}/../../extensions
|
||||
LINK_AGAINST_COCOSEXTENSION = -lextension -lbox2d -lchipmunk -lcurl
|
||||
|
||||
# Physics engines (pick one)
|
||||
DEFINES += CC_ENABLE_CHIPMUNK_INTEGRATION
|
||||
#DEFINES += CC_ENABLE_BOX2D_INTEGRATION
|
||||
INCLUDEPATH += $${PWD}/../../external/chipmunk/include/chipmunk
|
||||
INCLUDEPATH += $${PWD}/../../external
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
|
@ -197,7 +197,6 @@ xcopy /Y /Q "$(ProjectDir)..\platform\third_party\win32\libraries\*.*" "$(OutDir
|
|||
<ClCompile Include="..\platform\CCImageCommonWebp.cpp" />
|
||||
<ClCompile Include="..\platform\CCSAXParser.cpp" />
|
||||
<ClCompile Include="..\platform\CCThread.cpp" />
|
||||
<ClCompile Include="..\platform\platform.cpp" />
|
||||
<ClCompile Include="..\platform\third_party\common\etc\etc1.cpp" />
|
||||
<ClCompile Include="..\platform\win32\CCAccelerometer.cpp" />
|
||||
<ClCompile Include="..\platform\win32\CCApplication.cpp" />
|
||||
|
|
|
@ -808,15 +808,15 @@ void Sprite::setSkewY(float sy)
|
|||
SET_DIRTY_RECURSIVELY();
|
||||
}
|
||||
|
||||
void Sprite::setScaleX(float fScaleX)
|
||||
void Sprite::setScaleX(float scaleX)
|
||||
{
|
||||
Node::setScaleX(fScaleX);
|
||||
Node::setScaleX(scaleX);
|
||||
SET_DIRTY_RECURSIVELY();
|
||||
}
|
||||
|
||||
void Sprite::setScaleY(float fScaleY)
|
||||
void Sprite::setScaleY(float scaleY)
|
||||
{
|
||||
Node::setScaleY(fScaleY);
|
||||
Node::setScaleY(scaleY);
|
||||
SET_DIRTY_RECURSIVELY();
|
||||
}
|
||||
|
||||
|
|
|
@ -456,8 +456,8 @@ public:
|
|||
|
||||
/// @{
|
||||
/// @name Functions inherited from Node
|
||||
virtual void setScaleX(float fScaleX) override;
|
||||
virtual void setScaleY(float fScaleY) override;
|
||||
virtual void setScaleX(float scaleX) override;
|
||||
virtual void setScaleY(float scaleY) override;
|
||||
virtual void setPosition(const Point& pos) override;
|
||||
virtual void setRotation(float fRotation) override;
|
||||
virtual void setRotationX(float fRotationX) override;
|
||||
|
|
|
@ -960,18 +960,18 @@ bool Texture2D::initWithString(const char *text, const FontDefinition& textDefin
|
|||
|
||||
if (Label::VAlignment::TOP == textDefinition._vertAlignment)
|
||||
{
|
||||
eAlign = (Label::HAlignment::CENTER == textDefinition._alignment) ? Image::kAlignTop
|
||||
: (Label::HAlignment::LEFT == textDefinition._alignment) ? Image::kAlignTopLeft : Image::kAlignTopRight;
|
||||
eAlign = (Label::HAlignment::CENTER == textDefinition._alignment) ? Image::TextAlign::TOP
|
||||
: (Label::HAlignment::LEFT == textDefinition._alignment) ? Image::TextAlign::TOP_LEFT : Image::TextAlign::TOP_RIGHT;
|
||||
}
|
||||
else if (Label::VAlignment::CENTER == textDefinition._vertAlignment)
|
||||
{
|
||||
eAlign = (Label::HAlignment::CENTER == textDefinition._alignment) ? Image::kAlignCenter
|
||||
: (Label::HAlignment::LEFT == textDefinition._alignment) ? Image::kAlignLeft : Image::kAlignRight;
|
||||
eAlign = (Label::HAlignment::CENTER == textDefinition._alignment) ? Image::TextAlign::CENTER
|
||||
: (Label::HAlignment::LEFT == textDefinition._alignment) ? Image::TextAlign::LEFT : Image::TextAlign::RIGHT;
|
||||
}
|
||||
else if (Label::VAlignment::BOTTOM == textDefinition._vertAlignment)
|
||||
{
|
||||
eAlign = (Label::HAlignment::CENTER == textDefinition._alignment) ? Image::kAlignBottom
|
||||
: (Label::HAlignment::LEFT == textDefinition._alignment) ? Image::kAlignBottomLeft : Image::kAlignBottomRight;
|
||||
eAlign = (Label::HAlignment::CENTER == textDefinition._alignment) ? Image::TextAlign::BOTTOM
|
||||
: (Label::HAlignment::LEFT == textDefinition._alignment) ? Image::TextAlign::BOTTOM_LEFT : Image::TextAlign::BOTTOM_RIGHT;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -37,15 +37,6 @@ NS_CC_BEGIN
|
|||
* @{
|
||||
*/
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ccTouchSelectorBeganBit = 1 << 0,
|
||||
ccTouchSelectorMovedBit = 1 << 1,
|
||||
ccTouchSelectorEndedBit = 1 << 2,
|
||||
ccTouchSelectorCancelledBit = 1 << 3,
|
||||
ccTouchSelectorAllBits = ( ccTouchSelectorBeganBit | ccTouchSelectorMovedBit | ccTouchSelectorEndedBit | ccTouchSelectorCancelledBit),
|
||||
} ccTouchSelectorFlag;
|
||||
|
||||
|
||||
enum {
|
||||
CCTOUCHBEGAN,
|
||||
|
|
|
@ -102,7 +102,8 @@ spine/SlotData.cpp \
|
|||
spine/extension.cpp \
|
||||
spine/CCSkeletonAnimation.cpp \
|
||||
spine/CCSkeleton.cpp \
|
||||
spine/spine-cocos2dx.cpp
|
||||
spine/spine-cocos2dx.cpp \
|
||||
CCDeprecated-ext.cpp
|
||||
|
||||
LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static
|
||||
LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static
|
||||
|
|
|
@ -134,7 +134,7 @@ bool AssetsManager::checkUpdate()
|
|||
|
||||
if (res != 0)
|
||||
{
|
||||
sendErrorMessage(kNetwork);
|
||||
sendErrorMessage(ErrorCode::NETWORK);
|
||||
CCLOG("can not get version file content, error code is %d", res);
|
||||
curl_easy_cleanup(_curl);
|
||||
return false;
|
||||
|
@ -143,7 +143,7 @@ bool AssetsManager::checkUpdate()
|
|||
string recordedVersion = UserDefault::getInstance()->getStringForKey(KEY_OF_VERSION);
|
||||
if (recordedVersion == _version)
|
||||
{
|
||||
sendErrorMessage(kNoNewVersion);
|
||||
sendErrorMessage(ErrorCode::NO_NEW_VERSION);
|
||||
CCLOG("there is not new version");
|
||||
// Set resource search path.
|
||||
setSearchPath();
|
||||
|
@ -173,7 +173,7 @@ void AssetsManager::downloadAndUncompress()
|
|||
// Uncompress zip file.
|
||||
if (! uncompress())
|
||||
{
|
||||
sendErrorMessage(AssetsManager::kUncompress);
|
||||
sendErrorMessage(ErrorCode::UNCOMPRESS);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -205,7 +205,11 @@ void AssetsManager::update()
|
|||
}
|
||||
|
||||
// Check if there is a new version.
|
||||
if (! checkUpdate()) return;
|
||||
if (! checkUpdate())
|
||||
{
|
||||
_isDownloading = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// Is package already downloaded?
|
||||
_downloadedVersion = UserDefault::getInstance()->getStringForKey(KEY_OF_DOWNLOADED_VERSION);
|
||||
|
@ -403,7 +407,7 @@ bool AssetsManager::downLoad()
|
|||
FILE *fp = fopen(outFileName.c_str(), "wb");
|
||||
if (! fp)
|
||||
{
|
||||
sendErrorMessage(kCreateFile);
|
||||
sendErrorMessage(ErrorCode::CREATE_FILE);
|
||||
CCLOG("can not create file %s", outFileName.c_str());
|
||||
return false;
|
||||
}
|
||||
|
@ -420,7 +424,7 @@ bool AssetsManager::downLoad()
|
|||
curl_easy_cleanup(_curl);
|
||||
if (res != 0)
|
||||
{
|
||||
sendErrorMessage(kNetwork);
|
||||
sendErrorMessage(ErrorCode::NETWORK);
|
||||
CCLOG("error when download package");
|
||||
fclose(fp);
|
||||
return false;
|
||||
|
|
|
@ -44,19 +44,19 @@ class AssetsManagerDelegateProtocol;
|
|||
class AssetsManager
|
||||
{
|
||||
public:
|
||||
enum ErrorCode
|
||||
enum class ErrorCode
|
||||
{
|
||||
// Error caused by creating a file to store downloaded data
|
||||
kCreateFile,
|
||||
CREATE_FILE,
|
||||
/** Error caused by network
|
||||
-- network unavaivable
|
||||
-- timeout
|
||||
-- ...
|
||||
*/
|
||||
kNetwork,
|
||||
NETWORK,
|
||||
/** There is not a new version
|
||||
*/
|
||||
kNoNewVersion,
|
||||
NO_NEW_VERSION,
|
||||
/** Error caused in uncompressing stage
|
||||
-- can not open zip file
|
||||
-- can not read file global information
|
||||
|
@ -64,7 +64,7 @@ public:
|
|||
-- can not create a directory
|
||||
-- ...
|
||||
*/
|
||||
kUncompress,
|
||||
UNCOMPRESS,
|
||||
};
|
||||
|
||||
/* @brief Creates a AssetsManager with new package url, version code url and storage path.
|
||||
|
|
|
@ -301,6 +301,8 @@ namespace sigslot {
|
|||
class _connection_base0
|
||||
{
|
||||
public:
|
||||
virtual ~_connection_base0() { }
|
||||
|
||||
virtual has_slots<mt_policy>* getdest() const = 0;
|
||||
virtual void emit() = 0;
|
||||
virtual _connection_base0* clone() = 0;
|
||||
|
@ -386,6 +388,8 @@ namespace sigslot {
|
|||
class _connection_base7
|
||||
{
|
||||
public:
|
||||
virtual ~_connection_base7() { }
|
||||
|
||||
virtual has_slots<mt_policy>* getdest() const = 0;
|
||||
virtual void emit(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type,
|
||||
arg6_type, arg7_type) = 0;
|
||||
|
@ -400,6 +404,8 @@ namespace sigslot {
|
|||
class _connection_base8
|
||||
{
|
||||
public:
|
||||
virtual ~_connection_base8() { }
|
||||
|
||||
virtual has_slots<mt_policy>* getdest() const = 0;
|
||||
virtual void emit(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type,
|
||||
arg6_type, arg7_type, arg8_type) = 0;
|
||||
|
@ -413,6 +419,8 @@ namespace sigslot {
|
|||
class _signal_base : public mt_policy
|
||||
{
|
||||
public:
|
||||
virtual ~_signal_base() { }
|
||||
|
||||
virtual void slot_disconnect(has_slots<mt_policy>* pslot) = 0;
|
||||
virtual void slot_duplicate(const has_slots<mt_policy>* poldslot, has_slots<mt_policy>* pnewslot) = 0;
|
||||
};
|
||||
|
|
|
@ -17,35 +17,35 @@ NS_CC_EXT_BEGIN
|
|||
// Implementation of CCBAinmationManager
|
||||
|
||||
CCBAnimationManager::CCBAnimationManager()
|
||||
: mSequences(NULL)
|
||||
, mNodeSequences(NULL)
|
||||
, mBaseValues(NULL)
|
||||
, mAutoPlaySequenceId(0)
|
||||
, mRootNode(NULL)
|
||||
, mRootContainerSize(Size::ZERO)
|
||||
, mDelegate(NULL)
|
||||
, mRunningSequence(NULL)
|
||||
, jsControlled(false)
|
||||
, mOwner(NULL)
|
||||
: _sequences(NULL)
|
||||
, _nodeSequences(NULL)
|
||||
, _baseValues(NULL)
|
||||
, _autoPlaySequenceId(0)
|
||||
, _rootNode(NULL)
|
||||
, _rootContainerSize(Size::ZERO)
|
||||
, _delegate(NULL)
|
||||
, _runningSequence(NULL)
|
||||
, _jsControlled(false)
|
||||
, _owner(NULL)
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
bool CCBAnimationManager::init()
|
||||
{
|
||||
mSequences = new Array();
|
||||
mNodeSequences = new Dictionary();
|
||||
mBaseValues = new Dictionary();
|
||||
_sequences = new Array();
|
||||
_nodeSequences = new Dictionary();
|
||||
_baseValues = new Dictionary();
|
||||
|
||||
mDocumentOutletNames = new Array();
|
||||
mDocumentOutletNodes = new Array();
|
||||
mDocumentCallbackNames = new Array();
|
||||
mDocumentCallbackNodes = new Array();
|
||||
mKeyframeCallbacks = new Array();
|
||||
mKeyframeCallFuncs = new Dictionary();
|
||||
_documentOutletNames = new Array();
|
||||
_documentOutletNodes = new Array();
|
||||
_documentCallbackNames = new Array();
|
||||
_documentCallbackNodes = new Array();
|
||||
_keyframeCallbacks = new Array();
|
||||
_keyframeCallFuncs = new Dictionary();
|
||||
|
||||
mTarget = NULL;
|
||||
mAnimationCompleteCallbackFunc = NULL;
|
||||
_target = NULL;
|
||||
_animationCompleteCallbackFunc = NULL;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -53,141 +53,141 @@ bool CCBAnimationManager::init()
|
|||
CCBAnimationManager::~CCBAnimationManager()
|
||||
{
|
||||
// DictElement *pElement = NULL;
|
||||
// CCDICT_FOREACH(mNodeSequences, pElement)
|
||||
// CCDICT_FOREACH(_nodeSequences, pElement)
|
||||
// {
|
||||
// Node *node = (Node*)pElement->getIntKey();
|
||||
// node->release();
|
||||
// }
|
||||
//
|
||||
// CCDICT_FOREACH(mBaseValues, pElement)
|
||||
// CCDICT_FOREACH(_baseValues, pElement)
|
||||
// {
|
||||
// Node *node = (Node*)pElement->getIntKey();
|
||||
// node->release();
|
||||
// }
|
||||
|
||||
mNodeSequences->release();
|
||||
mBaseValues->release();
|
||||
mSequences->release();
|
||||
_nodeSequences->release();
|
||||
_baseValues->release();
|
||||
_sequences->release();
|
||||
setRootNode(NULL);
|
||||
setDelegate(NULL);
|
||||
|
||||
CC_SAFE_RELEASE(mDocumentOutletNames);
|
||||
CC_SAFE_RELEASE(mDocumentOutletNodes);
|
||||
CC_SAFE_RELEASE(mDocumentCallbackNames);
|
||||
CC_SAFE_RELEASE(mDocumentCallbackNodes);
|
||||
CC_SAFE_RELEASE(_documentOutletNames);
|
||||
CC_SAFE_RELEASE(_documentOutletNodes);
|
||||
CC_SAFE_RELEASE(_documentCallbackNames);
|
||||
CC_SAFE_RELEASE(_documentCallbackNodes);
|
||||
|
||||
CC_SAFE_RELEASE(mKeyframeCallFuncs);
|
||||
CC_SAFE_RELEASE(mKeyframeCallbacks);
|
||||
CC_SAFE_RELEASE(mTarget);
|
||||
CC_SAFE_RELEASE(_keyframeCallFuncs);
|
||||
CC_SAFE_RELEASE(_keyframeCallbacks);
|
||||
CC_SAFE_RELEASE(_target);
|
||||
}
|
||||
|
||||
Array* CCBAnimationManager::getSequences()
|
||||
{
|
||||
return mSequences;
|
||||
return _sequences;
|
||||
}
|
||||
|
||||
void CCBAnimationManager::setSequences(Array* seq)
|
||||
{
|
||||
mSequences = seq;
|
||||
_sequences = seq;
|
||||
}
|
||||
|
||||
int CCBAnimationManager::getAutoPlaySequenceId()
|
||||
{
|
||||
return mAutoPlaySequenceId;
|
||||
return _autoPlaySequenceId;
|
||||
}
|
||||
|
||||
void CCBAnimationManager::setAutoPlaySequenceId(int autoPlaySequenceId)
|
||||
{
|
||||
mAutoPlaySequenceId = autoPlaySequenceId;
|
||||
_autoPlaySequenceId = autoPlaySequenceId;
|
||||
}
|
||||
|
||||
Node* CCBAnimationManager::getRootNode()
|
||||
{
|
||||
return mRootNode;
|
||||
return _rootNode;
|
||||
}
|
||||
|
||||
void CCBAnimationManager::setRootNode(Node *pRootNode)
|
||||
{
|
||||
mRootNode = pRootNode;
|
||||
_rootNode = pRootNode;
|
||||
}
|
||||
|
||||
void CCBAnimationManager::setDocumentControllerName(const std::string &name) {
|
||||
mDocumentControllerName = name;
|
||||
_documentControllerName = name;
|
||||
}
|
||||
|
||||
|
||||
std::string CCBAnimationManager::getDocumentControllerName() {
|
||||
return mDocumentControllerName;
|
||||
return _documentControllerName;
|
||||
}
|
||||
|
||||
void CCBAnimationManager::addDocumentCallbackNode(Node *node) {
|
||||
mDocumentCallbackNodes->addObject(node);
|
||||
_documentCallbackNodes->addObject(node);
|
||||
}
|
||||
|
||||
void CCBAnimationManager::addDocumentCallbackName(std::string name) {
|
||||
String *tmpName = String::create(name);
|
||||
mDocumentCallbackNames->addObject(tmpName);
|
||||
_documentCallbackNames->addObject(tmpName);
|
||||
}
|
||||
|
||||
Array* CCBAnimationManager::getDocumentCallbackNames() {
|
||||
return mDocumentCallbackNames;
|
||||
return _documentCallbackNames;
|
||||
}
|
||||
|
||||
Array* CCBAnimationManager::getDocumentCallbackNodes() {
|
||||
return mDocumentCallbackNodes;
|
||||
return _documentCallbackNodes;
|
||||
}
|
||||
|
||||
void CCBAnimationManager::addDocumentOutletNode(Node *node) {
|
||||
mDocumentOutletNodes->addObject(node);
|
||||
_documentOutletNodes->addObject(node);
|
||||
}
|
||||
|
||||
void CCBAnimationManager::addDocumentOutletName(std::string name) {
|
||||
mDocumentOutletNames->addObject(String::create(name));
|
||||
_documentOutletNames->addObject(String::create(name));
|
||||
}
|
||||
|
||||
Array* CCBAnimationManager::getDocumentOutletNames() {
|
||||
return mDocumentOutletNames;
|
||||
return _documentOutletNames;
|
||||
}
|
||||
|
||||
Array* CCBAnimationManager::getDocumentOutletNodes() {
|
||||
return mDocumentOutletNodes;
|
||||
return _documentOutletNodes;
|
||||
}
|
||||
|
||||
std::string CCBAnimationManager::getLastCompletedSequenceName() {
|
||||
return lastCompletedSequenceName;
|
||||
return _lastCompletedSequenceName;
|
||||
}
|
||||
|
||||
Array* CCBAnimationManager::getKeyframeCallbacks() {
|
||||
return mKeyframeCallbacks;
|
||||
return _keyframeCallbacks;
|
||||
}
|
||||
|
||||
const Size& CCBAnimationManager::getRootContainerSize()
|
||||
{
|
||||
return mRootContainerSize;
|
||||
return _rootContainerSize;
|
||||
}
|
||||
|
||||
void CCBAnimationManager::setRootContainerSize(const Size &rootContainerSize)
|
||||
{
|
||||
mRootContainerSize.setSize(rootContainerSize.width, rootContainerSize.height);
|
||||
_rootContainerSize.setSize(rootContainerSize.width, rootContainerSize.height);
|
||||
}
|
||||
|
||||
CCBAnimationManagerDelegate* CCBAnimationManager::getDelegate()
|
||||
{
|
||||
return mDelegate;
|
||||
return _delegate;
|
||||
}
|
||||
|
||||
void CCBAnimationManager::setDelegate(CCBAnimationManagerDelegate *pDelegate)
|
||||
{
|
||||
CC_SAFE_RELEASE(dynamic_cast<Object*>(mDelegate));
|
||||
mDelegate = pDelegate;
|
||||
CC_SAFE_RETAIN(dynamic_cast<Object*>(mDelegate));
|
||||
CC_SAFE_RELEASE(dynamic_cast<Object*>(_delegate));
|
||||
_delegate = pDelegate;
|
||||
CC_SAFE_RETAIN(dynamic_cast<Object*>(_delegate));
|
||||
}
|
||||
|
||||
const char* CCBAnimationManager::getRunningSequenceName()
|
||||
{
|
||||
if (mRunningSequence)
|
||||
if (_runningSequence)
|
||||
{
|
||||
return mRunningSequence->getName();
|
||||
return _runningSequence->getName();
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
@ -200,7 +200,7 @@ const Size& CCBAnimationManager::getContainerSize(Node *pNode)
|
|||
}
|
||||
else
|
||||
{
|
||||
return mRootContainerSize;
|
||||
return _rootContainerSize;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -209,34 +209,34 @@ void CCBAnimationManager::addNode(Node *pNode, Dictionary *pSeq)
|
|||
{
|
||||
// pNode->retain();
|
||||
|
||||
mNodeSequences->setObject(pSeq, (intptr_t)pNode);
|
||||
_nodeSequences->setObject(pSeq, (intptr_t)pNode);
|
||||
}
|
||||
|
||||
void CCBAnimationManager::setBaseValue(Object *pValue, Node *pNode, const char *pPropName)
|
||||
void CCBAnimationManager::setBaseValue(Object *pValue, Node *pNode, const char *propName)
|
||||
{
|
||||
Dictionary *props = (Dictionary*)mBaseValues->objectForKey((intptr_t)pNode);
|
||||
Dictionary *props = (Dictionary*)_baseValues->objectForKey((intptr_t)pNode);
|
||||
if (! props)
|
||||
{
|
||||
props = Dictionary::create();
|
||||
mBaseValues->setObject(props, (intptr_t)pNode);
|
||||
_baseValues->setObject(props, (intptr_t)pNode);
|
||||
// pNode->retain();
|
||||
}
|
||||
|
||||
props->setObject(pValue, pPropName);
|
||||
props->setObject(pValue, propName);
|
||||
}
|
||||
|
||||
Object* CCBAnimationManager::getBaseValue(Node *pNode, const char* pPropName)
|
||||
Object* CCBAnimationManager::getBaseValue(Node *pNode, const char* propName)
|
||||
{
|
||||
Dictionary *props = (Dictionary*)mBaseValues->objectForKey((intptr_t)pNode);
|
||||
Dictionary *props = (Dictionary*)_baseValues->objectForKey((intptr_t)pNode);
|
||||
|
||||
return props->objectForKey(pPropName);
|
||||
return props->objectForKey(propName);
|
||||
}
|
||||
|
||||
int CCBAnimationManager::getSequenceId(const char* pSequenceName)
|
||||
{
|
||||
Object *pElement = NULL;
|
||||
string seqName(pSequenceName);
|
||||
CCARRAY_FOREACH(mSequences, pElement)
|
||||
CCARRAY_FOREACH(_sequences, pElement)
|
||||
{
|
||||
CCBSequence *seq = static_cast<CCBSequence*>(pElement);
|
||||
if (seqName.compare(seq->getName()) == 0)
|
||||
|
@ -250,7 +250,7 @@ int CCBAnimationManager::getSequenceId(const char* pSequenceName)
|
|||
CCBSequence* CCBAnimationManager::getSequence(int nSequenceId)
|
||||
{
|
||||
Object *pElement = NULL;
|
||||
CCARRAY_FOREACH(mSequences, pElement)
|
||||
CCARRAY_FOREACH(_sequences, pElement)
|
||||
{
|
||||
CCBSequence *seq = static_cast<CCBSequence*>(pElement);
|
||||
if (seq->getSequenceId() == nSequenceId)
|
||||
|
@ -265,20 +265,20 @@ CCBSequence* CCBAnimationManager::getSequence(int nSequenceId)
|
|||
void CCBAnimationManager::moveAnimationsFromNode(Node* fromNode, Node* toNode) {
|
||||
|
||||
// Move base values
|
||||
Object* baseValue = mBaseValues->objectForKey((intptr_t)fromNode);
|
||||
Object* baseValue = _baseValues->objectForKey((intptr_t)fromNode);
|
||||
if(baseValue) {
|
||||
mBaseValues->setObject(baseValue, (intptr_t)toNode);
|
||||
mBaseValues->removeObjectForKey((intptr_t)fromNode);
|
||||
_baseValues->setObject(baseValue, (intptr_t)toNode);
|
||||
_baseValues->removeObjectForKey((intptr_t)fromNode);
|
||||
|
||||
// fromNode->release();
|
||||
// toNode->retain();
|
||||
}
|
||||
|
||||
// Move seqs
|
||||
Object *seqs = mNodeSequences->objectForKey((intptr_t)fromNode);
|
||||
Object *seqs = _nodeSequences->objectForKey((intptr_t)fromNode);
|
||||
if(seqs) {
|
||||
mNodeSequences->setObject(seqs, (intptr_t)toNode);
|
||||
mNodeSequences->removeObjectForKey((intptr_t)fromNode);
|
||||
_nodeSequences->setObject(seqs, (intptr_t)toNode);
|
||||
_nodeSequences->removeObjectForKey((intptr_t)fromNode);
|
||||
|
||||
// fromNode->release();
|
||||
// toNode->retain();
|
||||
|
@ -286,38 +286,38 @@ void CCBAnimationManager::moveAnimationsFromNode(Node* fromNode, Node* toNode) {
|
|||
}
|
||||
|
||||
// Refer to CCBReader::readKeyframe() for the real type of value
|
||||
ActionInterval* CCBAnimationManager::getAction(CCBKeyframe *pKeyframe0, CCBKeyframe *pKeyframe1, const char *pPropName, Node *pNode)
|
||||
ActionInterval* CCBAnimationManager::getAction(CCBKeyframe *pKeyframe0, CCBKeyframe *pKeyframe1, const char *propName, Node *pNode)
|
||||
{
|
||||
float duration = pKeyframe1->getTime() - (pKeyframe0 ? pKeyframe0->getTime() : 0);
|
||||
|
||||
if (strcmp(pPropName, "rotationX") == 0)
|
||||
if (strcmp(propName, "rotationX") == 0)
|
||||
{
|
||||
CCBValue *value = (CCBValue*)pKeyframe1->getValue();
|
||||
return CCBRotateXTo::create(duration, value->getFloatValue());
|
||||
}
|
||||
else if(strcmp(pPropName, "rotationY") == 0)
|
||||
else if(strcmp(propName, "rotationY") == 0)
|
||||
{
|
||||
CCBValue *value = (CCBValue*)pKeyframe1->getValue();
|
||||
return CCBRotateYTo::create(duration, value->getFloatValue());
|
||||
}
|
||||
else if (strcmp(pPropName, "rotation") == 0)
|
||||
else if (strcmp(propName, "rotation") == 0)
|
||||
{
|
||||
CCBValue *value = (CCBValue*)pKeyframe1->getValue();
|
||||
return CCBRotateTo::create(duration, value->getFloatValue());
|
||||
}
|
||||
else if (strcmp(pPropName, "opacity") == 0)
|
||||
else if (strcmp(propName, "opacity") == 0)
|
||||
{
|
||||
CCBValue *value = (CCBValue*)pKeyframe1->getValue();
|
||||
return FadeTo::create(duration, value->getByteValue());
|
||||
}
|
||||
else if (strcmp(pPropName, "color") == 0)
|
||||
else if (strcmp(propName, "color") == 0)
|
||||
{
|
||||
Color3BWapper* color = (Color3BWapper*)pKeyframe1->getValue();
|
||||
Color3B c = color->getColor();
|
||||
|
||||
return TintTo::create(duration, c.r, c.g, c.b);
|
||||
}
|
||||
else if (strcmp(pPropName, "visible") == 0)
|
||||
else if (strcmp(propName, "visible") == 0)
|
||||
{
|
||||
CCBValue *value = (CCBValue*)pKeyframe1->getValue();
|
||||
if (value->getBoolValue())
|
||||
|
@ -329,40 +329,40 @@ ActionInterval* CCBAnimationManager::getAction(CCBKeyframe *pKeyframe0, CCBKeyfr
|
|||
return Sequence::createWithTwoActions(DelayTime::create(duration), Hide::create());
|
||||
}
|
||||
}
|
||||
else if (strcmp(pPropName, "displayFrame") == 0)
|
||||
else if (strcmp(propName, "displayFrame") == 0)
|
||||
{
|
||||
return Sequence::createWithTwoActions(DelayTime::create(duration),
|
||||
CCBSetSpriteFrame::create((SpriteFrame *)pKeyframe1->getValue()));
|
||||
}
|
||||
else if (strcmp(pPropName, "position") == 0)
|
||||
else if (strcmp(propName, "position") == 0)
|
||||
{
|
||||
// Get position type
|
||||
Array *array = (Array*)getBaseValue(pNode, pPropName);
|
||||
int type = ((CCBValue*)array->objectAtIndex(2))->getIntValue();
|
||||
Array *array = static_cast<Array*>(getBaseValue(pNode, propName));
|
||||
CCBReader::PositionType type = (CCBReader::PositionType)((CCBValue*)array->objectAtIndex(2))->getIntValue();
|
||||
|
||||
// Get relative position
|
||||
Array *value = (Array*)pKeyframe1->getValue();
|
||||
Array *value = static_cast<Array*>(pKeyframe1->getValue());
|
||||
float x = ((CCBValue*)value->objectAtIndex(0))->getFloatValue();
|
||||
float y = ((CCBValue*)value->objectAtIndex(1))->getFloatValue();
|
||||
|
||||
Size containerSize = getContainerSize(pNode->getParent());
|
||||
|
||||
Point absPos = getAbsolutePosition(Point(x,y), type, containerSize, pPropName);
|
||||
Point absPos = getAbsolutePosition(Point(x,y), type, containerSize, propName);
|
||||
|
||||
return MoveTo::create(duration, absPos);
|
||||
}
|
||||
else if (strcmp(pPropName, "scale") == 0)
|
||||
else if (strcmp(propName, "scale") == 0)
|
||||
{
|
||||
// Get position type
|
||||
Array *array = (Array*)getBaseValue(pNode, pPropName);
|
||||
int type = ((CCBValue*)array->objectAtIndex(2))->getIntValue();
|
||||
Array *array = (Array*)getBaseValue(pNode, propName);
|
||||
CCBReader::ScaleType type = (CCBReader::ScaleType)((CCBValue*)array->objectAtIndex(2))->getIntValue();
|
||||
|
||||
// Get relative scale
|
||||
Array *value = (Array*)pKeyframe1->getValue();
|
||||
float x = ((CCBValue*)value->objectAtIndex(0))->getFloatValue();
|
||||
float y = ((CCBValue*)value->objectAtIndex(1))->getFloatValue();
|
||||
|
||||
if (type == kCCBScaleTypeMultiplyResolution)
|
||||
if (type == CCBReader::ScaleType::MULTIPLY_RESOLUTION)
|
||||
{
|
||||
float resolutionScale = CCBReader::getResolutionScale();
|
||||
x *= resolutionScale;
|
||||
|
@ -371,7 +371,7 @@ ActionInterval* CCBAnimationManager::getAction(CCBKeyframe *pKeyframe0, CCBKeyfr
|
|||
|
||||
return ScaleTo::create(duration, x, y);
|
||||
}
|
||||
else if(strcmp(pPropName, "skew") == 0)
|
||||
else if(strcmp(propName, "skew") == 0)
|
||||
{
|
||||
// Get relative skew
|
||||
Array *value = (Array*)pKeyframe1->getValue();
|
||||
|
@ -382,13 +382,13 @@ ActionInterval* CCBAnimationManager::getAction(CCBKeyframe *pKeyframe0, CCBKeyfr
|
|||
}
|
||||
else
|
||||
{
|
||||
log("CCBReader: Failed to create animation for property: %s", pPropName);
|
||||
log("CCBReader: Failed to create animation for property: %s", propName);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void CCBAnimationManager::setAnimatedProperty(const char *pPropName, Node *pNode, Object *pValue, float fTweenDuration)
|
||||
void CCBAnimationManager::setAnimatedProperty(const char *propName, Node *pNode, Object *pValue, float fTweenDuration)
|
||||
{
|
||||
if (fTweenDuration > 0)
|
||||
{
|
||||
|
@ -397,43 +397,43 @@ void CCBAnimationManager::setAnimatedProperty(const char *pPropName, Node *pNode
|
|||
kf1->autorelease();
|
||||
kf1->setValue(pValue);
|
||||
kf1->setTime(fTweenDuration);
|
||||
kf1->setEasingType(kCCBKeyframeEasingLinear);
|
||||
kf1->setEasingType(CCBKeyframe::EasingType::LINEAR);
|
||||
|
||||
// Animate
|
||||
ActionInterval *tweenAction = getAction(NULL, kf1, pPropName, pNode);
|
||||
ActionInterval *tweenAction = getAction(NULL, kf1, propName, pNode);
|
||||
pNode->runAction(tweenAction);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Just set the value
|
||||
|
||||
if (strcmp(pPropName, "position") == 0)
|
||||
if (strcmp(propName, "position") == 0)
|
||||
{
|
||||
// Get position type
|
||||
Array *array = (Array*)getBaseValue(pNode, pPropName);
|
||||
int type = ((CCBValue*)array->objectAtIndex(2))->getIntValue();
|
||||
Array *array = (Array*)getBaseValue(pNode, propName);
|
||||
CCBReader::PositionType type = (CCBReader::PositionType)((CCBValue*)array->objectAtIndex(2))->getIntValue();
|
||||
|
||||
// Get relative position
|
||||
Array *value = (Array*)pValue;
|
||||
float x = ((CCBValue*)value->objectAtIndex(0))->getFloatValue();
|
||||
float y = ((CCBValue*)value->objectAtIndex(1))->getFloatValue();
|
||||
|
||||
pNode->setPosition(getAbsolutePosition(Point(x,y), type, getContainerSize(pNode->getParent()), pPropName));
|
||||
pNode->setPosition(getAbsolutePosition(Point(x,y), type, getContainerSize(pNode->getParent()), propName));
|
||||
}
|
||||
else if (strcmp(pPropName, "scale") == 0)
|
||||
else if (strcmp(propName, "scale") == 0)
|
||||
{
|
||||
// Get scale type
|
||||
Array *array = (Array*)getBaseValue(pNode, pPropName);
|
||||
int type = ((CCBValue*)array->objectAtIndex(2))->getIntValue();
|
||||
Array *array = (Array*)getBaseValue(pNode, propName);
|
||||
CCBReader::ScaleType type = (CCBReader::ScaleType)((CCBValue*)array->objectAtIndex(2))->getIntValue();
|
||||
|
||||
// Get relative scale
|
||||
Array *value = (Array*)pValue;
|
||||
float x = ((CCBValue*)value->objectAtIndex(0))->getFloatValue();
|
||||
float y = ((CCBValue*)value->objectAtIndex(1))->getFloatValue();
|
||||
|
||||
setRelativeScale(pNode, x, y, type, pPropName);
|
||||
setRelativeScale(pNode, x, y, type, propName);
|
||||
}
|
||||
else if(strcmp(pPropName, "skew") == 0)
|
||||
else if(strcmp(propName, "skew") == 0)
|
||||
{
|
||||
// Get relative scale
|
||||
Array *value = (Array*)pValue;
|
||||
|
@ -448,41 +448,41 @@ void CCBAnimationManager::setAnimatedProperty(const char *pPropName, Node *pNode
|
|||
// [node setValue:value forKey:name];
|
||||
|
||||
// TODO only handle rotation, opacity, displayFrame, color
|
||||
if (strcmp(pPropName, "rotation") == 0)
|
||||
if (strcmp(propName, "rotation") == 0)
|
||||
{
|
||||
float rotate = ((CCBValue*)pValue)->getFloatValue();
|
||||
pNode->setRotation(rotate);
|
||||
} else if(strcmp(pPropName, "rotationX") == 0)
|
||||
} else if(strcmp(propName, "rotationX") == 0)
|
||||
{
|
||||
float rotate = ((CCBValue*)pValue)->getFloatValue();
|
||||
pNode->setRotationX(rotate);
|
||||
}else if(strcmp(pPropName, "rotationY") == 0)
|
||||
}else if(strcmp(propName, "rotationY") == 0)
|
||||
{
|
||||
float rotate = ((CCBValue*)pValue)->getFloatValue();
|
||||
pNode->setRotationY(rotate);
|
||||
}
|
||||
else if (strcmp(pPropName, "opacity") == 0)
|
||||
else if (strcmp(propName, "opacity") == 0)
|
||||
{
|
||||
int opacity = ((CCBValue*)pValue)->getByteValue();
|
||||
(dynamic_cast<RGBAProtocol*>(pNode))->setOpacity(opacity);
|
||||
}
|
||||
else if (strcmp(pPropName, "displayFrame") == 0)
|
||||
else if (strcmp(propName, "displayFrame") == 0)
|
||||
{
|
||||
((Sprite*)pNode)->setDisplayFrame((SpriteFrame*)pValue);
|
||||
}
|
||||
else if (strcmp(pPropName, "color") == 0)
|
||||
else if (strcmp(propName, "color") == 0)
|
||||
{
|
||||
Color3BWapper *color = (Color3BWapper*)pValue;
|
||||
(dynamic_cast<RGBAProtocol*>(pNode))->setColor(color->getColor());
|
||||
}
|
||||
else if (strcmp(pPropName, "visible") == 0)
|
||||
else if (strcmp(propName, "visible") == 0)
|
||||
{
|
||||
bool visible = ((CCBValue*)pValue)->getBoolValue();
|
||||
pNode->setVisible(visible);
|
||||
}
|
||||
else
|
||||
{
|
||||
log("unsupported property name is %s", pPropName);
|
||||
log("unsupported property name is %s", propName);
|
||||
CCASSERT(false, "unsupported property now");
|
||||
}
|
||||
}
|
||||
|
@ -508,72 +508,72 @@ void CCBAnimationManager::setFirstFrame(Node *pNode, CCBSequenceProperty *pSeqPr
|
|||
}
|
||||
}
|
||||
|
||||
ActionInterval* CCBAnimationManager::getEaseAction(ActionInterval *pAction, int nEasingType, float fEasingOpt)
|
||||
ActionInterval* CCBAnimationManager::getEaseAction(ActionInterval *pAction, CCBKeyframe::EasingType easingType, float fEasingOpt)
|
||||
{
|
||||
if (dynamic_cast<Sequence*>(pAction))
|
||||
{
|
||||
return pAction;
|
||||
}
|
||||
|
||||
if (nEasingType == kCCBKeyframeEasingLinear)
|
||||
if (easingType == CCBKeyframe::EasingType::LINEAR)
|
||||
{
|
||||
return pAction;
|
||||
}
|
||||
else if (nEasingType == kCCBKeyframeEasingInstant)
|
||||
else if (easingType == CCBKeyframe::EasingType::INSTANT)
|
||||
{
|
||||
return CCBEaseInstant::create(pAction);
|
||||
}
|
||||
else if (nEasingType == kCCBKeyframeEasingCubicIn)
|
||||
else if (easingType == CCBKeyframe::EasingType::CUBIC_IN)
|
||||
{
|
||||
return EaseIn::create(pAction, fEasingOpt);
|
||||
}
|
||||
else if (nEasingType == kCCBKeyframeEasingCubicOut)
|
||||
else if (easingType == CCBKeyframe::EasingType::CUBIC_OUT)
|
||||
{
|
||||
return EaseOut::create(pAction, fEasingOpt);
|
||||
}
|
||||
else if (nEasingType == kCCBKeyframeEasingCubicInOut)
|
||||
else if (easingType == CCBKeyframe::EasingType::CUBIC_INOUT)
|
||||
{
|
||||
return EaseInOut::create(pAction, fEasingOpt);
|
||||
}
|
||||
else if (nEasingType == kCCBKeyframeEasingBackIn)
|
||||
else if (easingType == CCBKeyframe::EasingType::BACK_IN)
|
||||
{
|
||||
return EaseBackIn::create(pAction);
|
||||
}
|
||||
else if (nEasingType == kCCBKeyframeEasingBackOut)
|
||||
else if (easingType == CCBKeyframe::EasingType::BACK_OUT)
|
||||
{
|
||||
return EaseBackOut::create(pAction);
|
||||
}
|
||||
else if (nEasingType == kCCBKeyframeEasingBackInOut)
|
||||
else if (easingType == CCBKeyframe::EasingType::BACK_INOUT)
|
||||
{
|
||||
return EaseBackInOut::create(pAction);
|
||||
}
|
||||
else if (nEasingType == kCCBKeyframeEasingBounceIn)
|
||||
else if (easingType == CCBKeyframe::EasingType::BOUNCE_IN)
|
||||
{
|
||||
return EaseBounceIn::create(pAction);
|
||||
}
|
||||
else if (nEasingType == kCCBKeyframeEasingBounceOut)
|
||||
else if (easingType == CCBKeyframe::EasingType::BOUNCE_OUT)
|
||||
{
|
||||
return EaseBounceOut::create(pAction);
|
||||
}
|
||||
else if (nEasingType == kCCBKeyframeEasingBounceInOut)
|
||||
else if (easingType == CCBKeyframe::EasingType::BOUNCE_INOUT)
|
||||
{
|
||||
return EaseBounceInOut::create(pAction);
|
||||
}
|
||||
else if (nEasingType == kCCBKeyframeEasingElasticIn)
|
||||
else if (easingType == CCBKeyframe::EasingType::ELASTIC_IN)
|
||||
{
|
||||
return EaseElasticIn::create(pAction, fEasingOpt);
|
||||
}
|
||||
else if (nEasingType == kCCBKeyframeEasingElasticOut)
|
||||
else if (easingType == CCBKeyframe::EasingType::ELASTIC_OUT)
|
||||
{
|
||||
return EaseElasticOut::create(pAction, fEasingOpt);
|
||||
}
|
||||
else if (nEasingType == kCCBKeyframeEasingElasticInOut)
|
||||
else if (easingType == CCBKeyframe::EasingType::ELASTIC_INOUT)
|
||||
{
|
||||
return EaseElasticInOut::create(pAction, fEasingOpt);
|
||||
}
|
||||
else
|
||||
{
|
||||
log("CCBReader: Unkown easing type %d", nEasingType);
|
||||
log("CCBReader: Unkown easing type %d", easingType);
|
||||
return pAction;
|
||||
}
|
||||
}
|
||||
|
@ -586,7 +586,8 @@ Object* CCBAnimationManager::actionForCallbackChannel(CCBSequenceProperty* chann
|
|||
Array *keyframes = channel->getKeyframes();
|
||||
int numKeyframes = keyframes->count();
|
||||
|
||||
for (int i = 0; i < numKeyframes; ++i) {
|
||||
for (int i = 0; i < numKeyframes; ++i)
|
||||
{
|
||||
|
||||
CCBKeyframe *keyframe = (CCBKeyframe*)keyframes->objectAtIndex(i);
|
||||
float timeSinceLastKeyframe = keyframe->getTime() - lastKeyframeTime;
|
||||
|
@ -595,37 +596,52 @@ Object* CCBAnimationManager::actionForCallbackChannel(CCBSequenceProperty* chann
|
|||
actions->addObject(DelayTime::create(timeSinceLastKeyframe));
|
||||
}
|
||||
|
||||
Array* keyVal = (Array *)keyframe->getValue();
|
||||
std::string selectorName = ((String *)keyVal->objectAtIndex(0))->getCString();
|
||||
int selectorTarget = atoi(((String *)keyVal->objectAtIndex(1))->getCString());
|
||||
Array* keyVal = static_cast<Array *>(keyframe->getValue());
|
||||
std::string selectorName = static_cast<String *>(keyVal->objectAtIndex(0))->getCString();
|
||||
CCBReader::TargetType selectorTarget = (CCBReader::TargetType)atoi(static_cast<String *>(keyVal->objectAtIndex(1))->getCString());
|
||||
|
||||
if(jsControlled) {
|
||||
if(_jsControlled) {
|
||||
String* callbackName = String::createWithFormat("%d:%s", selectorTarget, selectorName.c_str());
|
||||
CallFunc *callback = ((CallFunc*)(mKeyframeCallFuncs->objectForKey(callbackName->getCString())))->clone();
|
||||
CallFunc *callback = ((CallFunc*)(_keyframeCallFuncs->objectForKey(callbackName->getCString())))->clone();
|
||||
|
||||
if(callback != NULL) {
|
||||
actions->addObject(callback);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
Object* target = NULL;
|
||||
if(selectorTarget == kCCBTargetTypeDocumentRoot) target = mRootNode;
|
||||
else if (selectorTarget == kCCBTargetTypeOwner) target = mOwner;
|
||||
if(target != NULL) {
|
||||
if(selectorName.length() > 0) {
|
||||
|
||||
if(selectorTarget == CCBReader::TargetType::DOCUMENT_ROOT)
|
||||
target = _rootNode;
|
||||
else if (selectorTarget == CCBReader::TargetType::OWNER)
|
||||
target = _owner;
|
||||
|
||||
if(target != NULL)
|
||||
{
|
||||
if(selectorName.length() > 0)
|
||||
{
|
||||
SEL_CallFuncN selCallFunc = 0;
|
||||
|
||||
CCBSelectorResolver* targetAsCCBSelectorResolver = dynamic_cast<CCBSelectorResolver *>(target);
|
||||
|
||||
if(targetAsCCBSelectorResolver != NULL) {
|
||||
if(targetAsCCBSelectorResolver != NULL)
|
||||
{
|
||||
selCallFunc = targetAsCCBSelectorResolver->onResolveCCBCCCallFuncSelector(target, selectorName.c_str ());
|
||||
}
|
||||
if(selCallFunc == 0) {
|
||||
|
||||
if(selCallFunc == 0)
|
||||
{
|
||||
CCLOG("Skipping selector '%s' since no CCBSelectorResolver is present.", selectorName.c_str());
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
CallFuncN *callback = CallFuncN::create(target, selCallFunc);
|
||||
actions->addObject(callback);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
CCLOG("Unexpected empty selector.");
|
||||
}
|
||||
}
|
||||
|
@ -737,10 +753,10 @@ void CCBAnimationManager::runAnimationsForSequenceIdTweenDuration(int nSeqId, fl
|
|||
{
|
||||
CCASSERT(nSeqId != -1, "Sequence id couldn't be found");
|
||||
|
||||
mRootNode->stopAllActions();
|
||||
_rootNode->stopAllActions();
|
||||
|
||||
DictElement* pElement = NULL;
|
||||
CCDICT_FOREACH(mNodeSequences, pElement)
|
||||
CCDICT_FOREACH(_nodeSequences, pElement)
|
||||
{
|
||||
Node *node = reinterpret_cast<Node*>(pElement->getIntKey());
|
||||
node->stopAllActions();
|
||||
|
@ -767,7 +783,7 @@ void CCBAnimationManager::runAnimationsForSequenceIdTweenDuration(int nSeqId, fl
|
|||
}
|
||||
|
||||
// Reset the nodes that may have been changed by other timelines
|
||||
Dictionary *nodeBaseValues = (Dictionary*)mBaseValues->objectForKey(pElement->getIntKey());
|
||||
Dictionary *nodeBaseValues = (Dictionary*)_baseValues->objectForKey(pElement->getIntKey());
|
||||
if (nodeBaseValues)
|
||||
{
|
||||
DictElement* pElement2 = NULL;
|
||||
|
@ -790,25 +806,25 @@ void CCBAnimationManager::runAnimationsForSequenceIdTweenDuration(int nSeqId, fl
|
|||
CCBSequence *seq = getSequence(nSeqId);
|
||||
Action *completeAction = Sequence::createWithTwoActions(DelayTime::create(seq->getDuration() + fTweenDuration),
|
||||
CallFunc::create( CC_CALLBACK_0(CCBAnimationManager::sequenceCompleted,this)));
|
||||
mRootNode->runAction(completeAction);
|
||||
_rootNode->runAction(completeAction);
|
||||
|
||||
// Set the running scene
|
||||
|
||||
if(seq->getCallbackChannel() != NULL) {
|
||||
Action* action = (Action *)actionForCallbackChannel(seq->getCallbackChannel());
|
||||
if(action != NULL) {
|
||||
mRootNode->runAction(action);
|
||||
_rootNode->runAction(action);
|
||||
}
|
||||
}
|
||||
|
||||
if(seq->getSoundChannel() != NULL) {
|
||||
Action* action = (Action *)actionForSoundChannel(seq->getSoundChannel());
|
||||
if(action != NULL) {
|
||||
mRootNode->runAction(action);
|
||||
_rootNode->runAction(action);
|
||||
}
|
||||
}
|
||||
|
||||
mRunningSequence = getSequence(nSeqId);
|
||||
_runningSequence = getSequence(nSeqId);
|
||||
}
|
||||
|
||||
void CCBAnimationManager::runAnimationsForSequenceNamedTweenDuration(const char *pName, float fTweenDuration)
|
||||
|
@ -833,38 +849,38 @@ void CCBAnimationManager::setAnimationCompletedCallback(Object *target, SEL_Call
|
|||
target->retain();
|
||||
}
|
||||
|
||||
if (mTarget)
|
||||
if (_target)
|
||||
{
|
||||
mTarget->release();
|
||||
_target->release();
|
||||
}
|
||||
|
||||
mTarget = target;
|
||||
mAnimationCompleteCallbackFunc = callbackFunc;
|
||||
_target = target;
|
||||
_animationCompleteCallbackFunc = callbackFunc;
|
||||
}
|
||||
|
||||
void CCBAnimationManager::setCallFunc(CallFunc* callFunc, const std::string &callbackNamed) {
|
||||
mKeyframeCallFuncs->setObject((Object*)callFunc, callbackNamed);
|
||||
_keyframeCallFuncs->setObject((Object*)callFunc, callbackNamed);
|
||||
}
|
||||
|
||||
void CCBAnimationManager::sequenceCompleted()
|
||||
{
|
||||
const char *runningSequenceName = mRunningSequence->getName();
|
||||
int nextSeqId = mRunningSequence->getChainedSequenceId();
|
||||
mRunningSequence = NULL;
|
||||
const char *runningSequenceName = _runningSequence->getName();
|
||||
int nextSeqId = _runningSequence->getChainedSequenceId();
|
||||
_runningSequence = NULL;
|
||||
|
||||
if(lastCompletedSequenceName != runningSequenceName) {
|
||||
lastCompletedSequenceName = runningSequenceName;
|
||||
if(_lastCompletedSequenceName != runningSequenceName) {
|
||||
_lastCompletedSequenceName = runningSequenceName;
|
||||
}
|
||||
|
||||
if (mDelegate)
|
||||
if (_delegate)
|
||||
{
|
||||
// There may be another runAnimation() call in this delegate method
|
||||
// which will assign mRunningSequence
|
||||
mDelegate->completedAnimationSequenceNamed(runningSequenceName);
|
||||
// which will assign _runningSequence
|
||||
_delegate->completedAnimationSequenceNamed(runningSequenceName);
|
||||
}
|
||||
|
||||
if (mTarget && mAnimationCompleteCallbackFunc) {
|
||||
(mTarget->*mAnimationCompleteCallbackFunc)();
|
||||
if (_target && _animationCompleteCallbackFunc) {
|
||||
(_target->*_animationCompleteCallbackFunc)();
|
||||
}
|
||||
|
||||
if (nextSeqId != -1)
|
||||
|
@ -899,22 +915,22 @@ CCBSetSpriteFrame* CCBSetSpriteFrame::create(SpriteFrame *pSpriteFrame)
|
|||
|
||||
bool CCBSetSpriteFrame::initWithSpriteFrame(SpriteFrame *pSpriteFrame)
|
||||
{
|
||||
mSpriteFrame = pSpriteFrame;
|
||||
CC_SAFE_RETAIN(mSpriteFrame);
|
||||
_spriteFrame = pSpriteFrame;
|
||||
CC_SAFE_RETAIN(_spriteFrame);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
CCBSetSpriteFrame::~CCBSetSpriteFrame()
|
||||
{
|
||||
CC_SAFE_RELEASE_NULL(mSpriteFrame);
|
||||
CC_SAFE_RELEASE_NULL(_spriteFrame);
|
||||
}
|
||||
|
||||
CCBSetSpriteFrame* CCBSetSpriteFrame::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new CCBSetSpriteFrame();
|
||||
a->initWithSpriteFrame(mSpriteFrame);
|
||||
a->initWithSpriteFrame(_spriteFrame);
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
@ -927,7 +943,7 @@ CCBSetSpriteFrame* CCBSetSpriteFrame::reverse() const
|
|||
|
||||
void CCBSetSpriteFrame::update(float time)
|
||||
{
|
||||
((Sprite*)_target)->setDisplayFrame(mSpriteFrame);
|
||||
((Sprite*)_target)->setDisplayFrame(_spriteFrame);
|
||||
}
|
||||
|
||||
|
||||
|
@ -954,10 +970,10 @@ CCBSoundEffect::~CCBSoundEffect()
|
|||
}
|
||||
|
||||
bool CCBSoundEffect::initWithSoundFile(const std::string &filename, float pitch, float pan, float gain) {
|
||||
mSoundFile = filename;
|
||||
mPitch = pitch;
|
||||
mPan = pan;
|
||||
mGain = gain;
|
||||
_soundFile = filename;
|
||||
_pitch = pitch;
|
||||
_pan = pan;
|
||||
_gain = gain;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -965,7 +981,7 @@ CCBSoundEffect* CCBSoundEffect::clone() const
|
|||
{
|
||||
// no copy constructor
|
||||
auto a = new CCBSoundEffect();
|
||||
a->initWithSoundFile(mSoundFile, mPitch, mPan, mGain);
|
||||
a->initWithSoundFile(_soundFile, _pitch, _pan, _gain);
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
@ -978,7 +994,7 @@ CCBSoundEffect* CCBSoundEffect::reverse() const
|
|||
|
||||
void CCBSoundEffect::update(float time)
|
||||
{
|
||||
CocosDenshion::SimpleAudioEngine::getInstance()->playEffect(mSoundFile.c_str());
|
||||
CocosDenshion::SimpleAudioEngine::getInstance()->playEffect(_soundFile.c_str());
|
||||
}
|
||||
|
||||
|
||||
|
@ -1008,7 +1024,7 @@ bool CCBRotateTo::initWithDuration(float fDuration, float fAngle)
|
|||
{
|
||||
if (ActionInterval::initWithDuration(fDuration))
|
||||
{
|
||||
mDstAngle = fAngle;
|
||||
_dstAngle = fAngle;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1022,7 +1038,7 @@ CCBRotateTo* CCBRotateTo::clone() const
|
|||
{
|
||||
// no copy constructor
|
||||
auto a = new CCBRotateTo();
|
||||
a->initWithDuration(_duration, mDstAngle);
|
||||
a->initWithDuration(_duration, _dstAngle);
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
@ -1036,13 +1052,13 @@ CCBRotateTo* CCBRotateTo::reverse() const
|
|||
void CCBRotateTo::startWithTarget(Node *pNode)
|
||||
{
|
||||
ActionInterval::startWithTarget(pNode);
|
||||
mStartAngle = _target->getRotation();
|
||||
mDiffAngle = mDstAngle - mStartAngle;
|
||||
_startAngle = _target->getRotation();
|
||||
_diffAngle = _dstAngle - _startAngle;
|
||||
}
|
||||
|
||||
void CCBRotateTo::update(float time)
|
||||
{
|
||||
_target->setRotation(mStartAngle + (mDiffAngle * time))
|
||||
_target->setRotation(_startAngle + (_diffAngle * time))
|
||||
;
|
||||
}
|
||||
|
||||
|
@ -1076,7 +1092,7 @@ bool CCBRotateXTo::initWithDuration(float fDuration, float fAngle)
|
|||
{
|
||||
if (ActionInterval::initWithDuration(fDuration))
|
||||
{
|
||||
mDstAngle = fAngle;
|
||||
_dstAngle = fAngle;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1094,15 +1110,15 @@ void CCBRotateXTo::startWithTarget(Node *pNode)
|
|||
_target = pNode;
|
||||
_elapsed = 0.0f;
|
||||
_firstTick = true;
|
||||
mStartAngle = _target->getRotationX();
|
||||
mDiffAngle = mDstAngle - mStartAngle;
|
||||
_startAngle = _target->getRotationX();
|
||||
_diffAngle = _dstAngle - _startAngle;
|
||||
}
|
||||
|
||||
CCBRotateXTo* CCBRotateXTo::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new CCBRotateXTo();
|
||||
a->initWithDuration(_duration, mDstAngle);
|
||||
a->initWithDuration(_duration, _dstAngle);
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
@ -1115,7 +1131,7 @@ CCBRotateXTo* CCBRotateXTo::reverse() const
|
|||
|
||||
void CCBRotateXTo::update(float time)
|
||||
{
|
||||
_target->setRotationX(mStartAngle + (mDiffAngle * time))
|
||||
_target->setRotationX(_startAngle + (_diffAngle * time))
|
||||
;
|
||||
}
|
||||
|
||||
|
@ -1149,7 +1165,7 @@ bool CCBRotateYTo::initWithDuration(float fDuration, float fAngle)
|
|||
{
|
||||
if (ActionInterval::initWithDuration(fDuration))
|
||||
{
|
||||
mDstAngle = fAngle;
|
||||
_dstAngle = fAngle;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1163,7 +1179,7 @@ CCBRotateYTo* CCBRotateYTo::clone() const
|
|||
{
|
||||
// no copy constructor
|
||||
auto a = new CCBRotateYTo();
|
||||
a->initWithDuration(_duration, mDstAngle);
|
||||
a->initWithDuration(_duration, _dstAngle);
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
@ -1182,13 +1198,13 @@ void CCBRotateYTo::startWithTarget(Node *pNode)
|
|||
_target = pNode;
|
||||
_elapsed = 0.0f;
|
||||
_firstTick = true;
|
||||
mStartAngle = _target->getRotationY();
|
||||
mDiffAngle = mDstAngle - mStartAngle;
|
||||
_startAngle = _target->getRotationY();
|
||||
_diffAngle = _dstAngle - _startAngle;
|
||||
}
|
||||
|
||||
void CCBRotateYTo::update(float time)
|
||||
{
|
||||
_target->setRotationY(mStartAngle + (mDiffAngle * time))
|
||||
_target->setRotationY(_startAngle + (_diffAngle * time))
|
||||
;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,40 +17,13 @@ public:
|
|||
|
||||
class CCBAnimationManager : public Object
|
||||
{
|
||||
private:
|
||||
Array *mSequences;
|
||||
Dictionary *mNodeSequences;
|
||||
Dictionary *mBaseValues;
|
||||
int mAutoPlaySequenceId;
|
||||
|
||||
Node *mRootNode;
|
||||
|
||||
Size mRootContainerSize;
|
||||
|
||||
CCBAnimationManagerDelegate *mDelegate;
|
||||
CCBSequence *mRunningSequence;
|
||||
|
||||
Array *mDocumentOutletNames;
|
||||
Array *mDocumentOutletNodes;
|
||||
Array *mDocumentCallbackNames;
|
||||
Array *mDocumentCallbackNodes;
|
||||
Array *mKeyframeCallbacks;
|
||||
Dictionary *mKeyframeCallFuncs;
|
||||
|
||||
std::string mDocumentControllerName;
|
||||
std::string lastCompletedSequenceName;
|
||||
|
||||
SEL_CallFunc mAnimationCompleteCallbackFunc;
|
||||
Object *mTarget;
|
||||
|
||||
|
||||
public:
|
||||
bool jsControlled;
|
||||
bool _jsControlled;
|
||||
CCBAnimationManager();
|
||||
~CCBAnimationManager();
|
||||
|
||||
|
||||
Object *mOwner;
|
||||
Object *_owner;
|
||||
|
||||
virtual bool init();
|
||||
|
||||
|
@ -92,7 +65,7 @@ public:
|
|||
const Size& getContainerSize(Node* pNode);
|
||||
|
||||
void addNode(Node *pNode, Dictionary *pSeq);
|
||||
void setBaseValue(Object *pValue, Node *pNode, const char *pPropName);
|
||||
void setBaseValue(Object *pValue, Node *pNode, const char *propName);
|
||||
void moveAnimationsFromNode(Node* fromNode, Node* toNode);
|
||||
|
||||
/** @deprecated This interface will be deprecated sooner or later.*/
|
||||
|
@ -116,15 +89,41 @@ public:
|
|||
Object* actionForSoundChannel(CCBSequenceProperty* channel);
|
||||
|
||||
private:
|
||||
Object* getBaseValue(Node *pNode, const char* pPropName);
|
||||
Object* getBaseValue(Node *pNode, const char* propName);
|
||||
int getSequenceId(const char* pSequenceName);
|
||||
CCBSequence* getSequence(int nSequenceId);
|
||||
ActionInterval* getAction(CCBKeyframe *pKeyframe0, CCBKeyframe *pKeyframe1, const char *pPropName, Node *pNode);
|
||||
void setAnimatedProperty(const char *pPropName, Node *pNode, Object *pValue, float fTweenDuraion);
|
||||
ActionInterval* getAction(CCBKeyframe *pKeyframe0, CCBKeyframe *pKeyframe1, const char *propName, Node *pNode);
|
||||
void setAnimatedProperty(const char *propName, Node *pNode, Object *pValue, float fTweenDuraion);
|
||||
void setFirstFrame(Node *pNode, CCBSequenceProperty *pSeqProp, float fTweenDuration);
|
||||
ActionInterval* getEaseAction(ActionInterval *pAction, int nEasingType, float fEasingOpt);
|
||||
ActionInterval* getEaseAction(ActionInterval *pAction, CCBKeyframe::EasingType easingType, float fEasingOpt);
|
||||
void runAction(Node *pNode, CCBSequenceProperty *pSeqProp, float fTweenDuration);
|
||||
void sequenceCompleted();
|
||||
|
||||
private:
|
||||
Array *_sequences;
|
||||
Dictionary *_nodeSequences;
|
||||
Dictionary *_baseValues;
|
||||
int _autoPlaySequenceId;
|
||||
|
||||
Node *_rootNode;
|
||||
|
||||
Size _rootContainerSize;
|
||||
|
||||
CCBAnimationManagerDelegate *_delegate;
|
||||
CCBSequence *_runningSequence;
|
||||
|
||||
Array *_documentOutletNames;
|
||||
Array *_documentOutletNodes;
|
||||
Array *_documentCallbackNames;
|
||||
Array *_documentCallbackNodes;
|
||||
Array *_keyframeCallbacks;
|
||||
Dictionary *_keyframeCallFuncs;
|
||||
|
||||
std::string _documentControllerName;
|
||||
std::string _lastCompletedSequenceName;
|
||||
|
||||
SEL_CallFunc _animationCompleteCallbackFunc;
|
||||
Object *_target;
|
||||
};
|
||||
|
||||
class CCBSetSpriteFrame : public ActionInstant
|
||||
|
@ -143,7 +142,7 @@ public:
|
|||
virtual CCBSetSpriteFrame* reverse() const override;
|
||||
|
||||
private:
|
||||
SpriteFrame *mSpriteFrame;
|
||||
SpriteFrame *_spriteFrame;
|
||||
};
|
||||
|
||||
|
||||
|
@ -160,8 +159,8 @@ public:
|
|||
virtual CCBSoundEffect* reverse() const override;
|
||||
|
||||
private:
|
||||
std::string mSoundFile;
|
||||
float mPitch, mPan, mGain;
|
||||
std::string _soundFile;
|
||||
float _pitch, _pan, _gain;
|
||||
};
|
||||
|
||||
|
||||
|
@ -178,9 +177,9 @@ public:
|
|||
virtual void startWithTarget(Node *pNode) override;
|
||||
|
||||
private:
|
||||
float mStartAngle;
|
||||
float mDstAngle;
|
||||
float mDiffAngle;
|
||||
float _startAngle;
|
||||
float _dstAngle;
|
||||
float _diffAngle;
|
||||
};
|
||||
|
||||
|
||||
|
@ -197,9 +196,9 @@ public:
|
|||
virtual void update(float time) override;
|
||||
|
||||
private:
|
||||
float mStartAngle;
|
||||
float mDstAngle;
|
||||
float mDiffAngle;
|
||||
float _startAngle;
|
||||
float _dstAngle;
|
||||
float _diffAngle;
|
||||
};
|
||||
|
||||
|
||||
|
@ -216,9 +215,9 @@ public:
|
|||
virtual void update(float time) override;
|
||||
|
||||
private:
|
||||
float mStartAngle;
|
||||
float mDstAngle;
|
||||
float mDiffAngle;
|
||||
float _startAngle;
|
||||
float _dstAngle;
|
||||
float _diffAngle;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -6,11 +6,11 @@ NS_CC_EXT_BEGIN
|
|||
|
||||
#define PROPERTY_CCBFILE "ccbFile"
|
||||
|
||||
void CCBFileLoader::onHandlePropTypeCCBFile(Node * pNode, Node * pParent, const char * pPropertyName, Node * pCCBFileNode, CCBReader * pCCBReader) {
|
||||
void CCBFileLoader::onHandlePropTypeCCBFile(Node * pNode, Node * pParent, const char * pPropertyName, Node * pCCBFileNode, CCBReader * ccbReader) {
|
||||
if(strcmp(pPropertyName, PROPERTY_CCBFILE) == 0) {
|
||||
((CCBFile*)pNode)->setCCBFileNode(pCCBFileNode);
|
||||
} else {
|
||||
NodeLoader::onHandlePropTypeCCBFile(pNode, pParent, pPropertyName, pCCBFileNode, pCCBReader);
|
||||
NodeLoader::onHandlePropTypeCCBFile(pNode, pParent, pPropertyName, pCCBFileNode, ccbReader);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ class CCBFileLoader : public NodeLoader {
|
|||
protected:
|
||||
CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCBFile);
|
||||
|
||||
virtual void onHandlePropTypeCCBFile(Node * pNode, Node * pParent, const char * pPropertyName, Node * pCCBFileNode, CCBReader * pCCBReader);
|
||||
virtual void onHandlePropTypeCCBFile(Node * pNode, Node * pParent, const char * pPropertyName, Node * pCCBFileNode, CCBReader * ccbReader);
|
||||
};
|
||||
|
||||
NS_CC_EXT_END
|
||||
|
|
|
@ -5,57 +5,57 @@ using namespace cocos2d;
|
|||
NS_CC_EXT_BEGIN
|
||||
|
||||
CCBKeyframe::CCBKeyframe()
|
||||
: mValue(NULL)
|
||||
, mTime(0.0f)
|
||||
, mEasingType(0)
|
||||
, mEasingOpt(0.0f)
|
||||
: _value(NULL)
|
||||
, _time(0.0f)
|
||||
, _easingType(EasingType::INSTANT)
|
||||
, _easingOpt(0.0f)
|
||||
{}
|
||||
|
||||
CCBKeyframe::~CCBKeyframe()
|
||||
{
|
||||
CC_SAFE_RELEASE_NULL(mValue);
|
||||
CC_SAFE_RELEASE_NULL(_value);
|
||||
}
|
||||
|
||||
Object* CCBKeyframe::getValue()
|
||||
{
|
||||
return mValue;
|
||||
return _value;
|
||||
}
|
||||
|
||||
void CCBKeyframe::setValue(Object *pValue)
|
||||
{
|
||||
CC_SAFE_RELEASE(mValue);
|
||||
mValue = pValue;
|
||||
CC_SAFE_RETAIN(mValue);
|
||||
CC_SAFE_RELEASE(_value);
|
||||
_value = pValue;
|
||||
CC_SAFE_RETAIN(_value);
|
||||
}
|
||||
|
||||
float CCBKeyframe::getTime()
|
||||
{
|
||||
return mTime;
|
||||
return _time;
|
||||
}
|
||||
|
||||
void CCBKeyframe::setTime(float fTime)
|
||||
{
|
||||
mTime = fTime;
|
||||
_time = fTime;
|
||||
}
|
||||
|
||||
int CCBKeyframe::getEasingType()
|
||||
CCBKeyframe::EasingType CCBKeyframe::getEasingType()
|
||||
{
|
||||
return mEasingType;
|
||||
return _easingType;
|
||||
}
|
||||
|
||||
void CCBKeyframe::setEasingType(int nEasingType)
|
||||
void CCBKeyframe::setEasingType(CCBKeyframe::EasingType easingType)
|
||||
{
|
||||
mEasingType = nEasingType;
|
||||
_easingType = easingType;
|
||||
}
|
||||
|
||||
float CCBKeyframe::getEasingOpt()
|
||||
{
|
||||
return mEasingOpt;
|
||||
return _easingOpt;
|
||||
}
|
||||
|
||||
void CCBKeyframe::setEasingOpt(float fEasingOpt)
|
||||
{
|
||||
mEasingOpt = fEasingOpt;
|
||||
_easingOpt = fEasingOpt;
|
||||
}
|
||||
|
||||
NS_CC_EXT_END
|
||||
|
|
|
@ -8,13 +8,30 @@ NS_CC_EXT_BEGIN
|
|||
|
||||
class CCBKeyframe : public Object
|
||||
{
|
||||
private:
|
||||
Object *mValue;
|
||||
float mTime;
|
||||
int mEasingType;
|
||||
float mEasingOpt;
|
||||
|
||||
public:
|
||||
enum class EasingType
|
||||
{
|
||||
INSTANT,
|
||||
|
||||
LINEAR,
|
||||
|
||||
CUBIC_IN,
|
||||
CUBIC_OUT,
|
||||
CUBIC_INOUT,
|
||||
|
||||
ELASTIC_IN,
|
||||
ELASTIC_OUT,
|
||||
ELASTIC_INOUT,
|
||||
|
||||
BOUNCE_IN,
|
||||
BOUNCE_OUT,
|
||||
BOUNCE_INOUT,
|
||||
|
||||
BACK_IN,
|
||||
BACK_OUT,
|
||||
BACK_INOUT,
|
||||
};
|
||||
|
||||
CCBKeyframe();
|
||||
~CCBKeyframe();
|
||||
|
||||
|
@ -24,11 +41,17 @@ public:
|
|||
float getTime();
|
||||
void setTime(float fTime);
|
||||
|
||||
int getEasingType();
|
||||
void setEasingType(int nEasingType);
|
||||
EasingType getEasingType();
|
||||
void setEasingType(EasingType easingType);
|
||||
|
||||
float getEasingOpt();
|
||||
void setEasingOpt(float fEasingOpt);
|
||||
|
||||
private:
|
||||
Object *_value;
|
||||
float _time;
|
||||
EasingType _easingType;
|
||||
float _easingOpt;
|
||||
};
|
||||
|
||||
NS_CC_EXT_END
|
||||
|
|
|
@ -14,10 +14,6 @@
|
|||
|
||||
#include <ctype.h>
|
||||
|
||||
#ifdef __CC_PLATFORM_IOS
|
||||
#include <UIKit/UIDevice.h>
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
|
||||
NS_CC_EXT_BEGIN;
|
||||
|
@ -26,7 +22,7 @@ NS_CC_EXT_BEGIN;
|
|||
Implementation of CCBFile
|
||||
*************************************************************************/
|
||||
|
||||
CCBFile::CCBFile():mCCBFileNode(NULL) {}
|
||||
CCBFile::CCBFile():_CCBFileNode(NULL) {}
|
||||
|
||||
CCBFile* CCBFile::create()
|
||||
{
|
||||
|
@ -42,14 +38,14 @@ CCBFile* CCBFile::create()
|
|||
|
||||
Node* CCBFile::getCCBFileNode()
|
||||
{
|
||||
return mCCBFileNode;
|
||||
return _CCBFileNode;
|
||||
}
|
||||
|
||||
void CCBFile::setCCBFileNode(Node *pNode)
|
||||
{
|
||||
CC_SAFE_RELEASE(mCCBFileNode);
|
||||
mCCBFileNode = pNode;
|
||||
CC_SAFE_RETAIN(mCCBFileNode);
|
||||
CC_SAFE_RELEASE(_CCBFileNode);
|
||||
_CCBFileNode = pNode;
|
||||
CC_SAFE_RETAIN(_CCBFileNode);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
|
@ -57,111 +53,111 @@ void CCBFile::setCCBFileNode(Node *pNode)
|
|||
*************************************************************************/
|
||||
|
||||
CCBReader::CCBReader(NodeLoaderLibrary * pNodeLoaderLibrary, CCBMemberVariableAssigner * pCCBMemberVariableAssigner, CCBSelectorResolver * pCCBSelectorResolver, NodeLoaderListener * pNodeLoaderListener)
|
||||
: mData(NULL)
|
||||
, mBytes(NULL)
|
||||
, mCurrentByte(-1)
|
||||
, mCurrentBit(-1)
|
||||
, mOwner(NULL)
|
||||
, mActionManager(NULL)
|
||||
, mActionManagers(NULL)
|
||||
, mAnimatedProps(NULL)
|
||||
, mOwnerOutletNodes(NULL)
|
||||
, mNodesWithAnimationManagers(NULL)
|
||||
, mAnimationManagersForNodes(NULL)
|
||||
, mOwnerCallbackNodes(NULL)
|
||||
, hasScriptingOwner(false)
|
||||
: _data(NULL)
|
||||
, _bytes(NULL)
|
||||
, _currentByte(-1)
|
||||
, _currentBit(-1)
|
||||
, _owner(NULL)
|
||||
, _actionManager(NULL)
|
||||
, _actionManagers(NULL)
|
||||
, _animatedProps(NULL)
|
||||
, _ownerOutletNodes(NULL)
|
||||
, _nodesWithAnimationManagers(NULL)
|
||||
, _animationManagersForNodes(NULL)
|
||||
, _ownerCallbackNodes(NULL)
|
||||
, _hasScriptingOwner(false)
|
||||
{
|
||||
this->mNodeLoaderLibrary = pNodeLoaderLibrary;
|
||||
this->mNodeLoaderLibrary->retain();
|
||||
this->mCCBMemberVariableAssigner = pCCBMemberVariableAssigner;
|
||||
this->mCCBSelectorResolver = pCCBSelectorResolver;
|
||||
this->mNodeLoaderListener = pNodeLoaderListener;
|
||||
this->_nodeLoaderLibrary = pNodeLoaderLibrary;
|
||||
this->_nodeLoaderLibrary->retain();
|
||||
this->_CCBMemberVariableAssigner = pCCBMemberVariableAssigner;
|
||||
this->_CCBSelectorResolver = pCCBSelectorResolver;
|
||||
this->_nodeLoaderListener = pNodeLoaderListener;
|
||||
init();
|
||||
}
|
||||
|
||||
CCBReader::CCBReader(CCBReader * pCCBReader)
|
||||
: mData(NULL)
|
||||
, mBytes(NULL)
|
||||
, mCurrentByte(-1)
|
||||
, mCurrentBit(-1)
|
||||
, mOwner(NULL)
|
||||
, mActionManager(NULL)
|
||||
, mActionManagers(NULL)
|
||||
, mAnimatedProps(NULL)
|
||||
, mOwnerOutletNodes(NULL)
|
||||
, mNodesWithAnimationManagers(NULL)
|
||||
, mAnimationManagersForNodes(NULL)
|
||||
, mOwnerCallbackNodes(NULL)
|
||||
, hasScriptingOwner(false)
|
||||
CCBReader::CCBReader(CCBReader * ccbReader)
|
||||
: _data(NULL)
|
||||
, _bytes(NULL)
|
||||
, _currentByte(-1)
|
||||
, _currentBit(-1)
|
||||
, _owner(NULL)
|
||||
, _actionManager(NULL)
|
||||
, _actionManagers(NULL)
|
||||
, _animatedProps(NULL)
|
||||
, _ownerOutletNodes(NULL)
|
||||
, _nodesWithAnimationManagers(NULL)
|
||||
, _animationManagersForNodes(NULL)
|
||||
, _ownerCallbackNodes(NULL)
|
||||
, _hasScriptingOwner(false)
|
||||
{
|
||||
this->mLoadedSpriteSheets = pCCBReader->mLoadedSpriteSheets;
|
||||
this->mNodeLoaderLibrary = pCCBReader->mNodeLoaderLibrary;
|
||||
this->mNodeLoaderLibrary->retain();
|
||||
this->_loadedSpriteSheets = ccbReader->_loadedSpriteSheets;
|
||||
this->_nodeLoaderLibrary = ccbReader->_nodeLoaderLibrary;
|
||||
this->_nodeLoaderLibrary->retain();
|
||||
|
||||
this->mCCBMemberVariableAssigner = pCCBReader->mCCBMemberVariableAssigner;
|
||||
this->mCCBSelectorResolver = pCCBReader->mCCBSelectorResolver;
|
||||
this->mNodeLoaderListener = pCCBReader->mNodeLoaderListener;
|
||||
this->_CCBMemberVariableAssigner = ccbReader->_CCBMemberVariableAssigner;
|
||||
this->_CCBSelectorResolver = ccbReader->_CCBSelectorResolver;
|
||||
this->_nodeLoaderListener = ccbReader->_nodeLoaderListener;
|
||||
|
||||
this->mOwnerCallbackNames = pCCBReader->mOwnerCallbackNames;
|
||||
this->mOwnerCallbackNodes = pCCBReader->mOwnerCallbackNodes;
|
||||
this->mOwnerCallbackNodes->retain();
|
||||
this->mOwnerOutletNames = pCCBReader->mOwnerOutletNames;
|
||||
this->mOwnerOutletNodes = pCCBReader->mOwnerOutletNodes;
|
||||
this->mOwnerOutletNodes->retain();
|
||||
this->_ownerCallbackNames = ccbReader->_ownerCallbackNames;
|
||||
this->_ownerCallbackNodes = ccbReader->_ownerCallbackNodes;
|
||||
this->_ownerCallbackNodes->retain();
|
||||
this->_ownerOutletNames = ccbReader->_ownerOutletNames;
|
||||
this->_ownerOutletNodes = ccbReader->_ownerOutletNodes;
|
||||
this->_ownerOutletNodes->retain();
|
||||
|
||||
this->mCCBRootPath = pCCBReader->getCCBRootPath();
|
||||
this->_CCBRootPath = ccbReader->getCCBRootPath();
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
CCBReader::CCBReader()
|
||||
: mData(NULL)
|
||||
, mBytes(NULL)
|
||||
, mCurrentByte(-1)
|
||||
, mCurrentBit(-1)
|
||||
, mOwner(NULL)
|
||||
, mActionManager(NULL)
|
||||
, mActionManagers(NULL)
|
||||
, mNodeLoaderLibrary(NULL)
|
||||
, mNodeLoaderListener(NULL)
|
||||
, mCCBMemberVariableAssigner(NULL)
|
||||
, mCCBSelectorResolver(NULL)
|
||||
, mNodesWithAnimationManagers(NULL)
|
||||
, mAnimationManagersForNodes(NULL)
|
||||
, hasScriptingOwner(false)
|
||||
: _data(NULL)
|
||||
, _bytes(NULL)
|
||||
, _currentByte(-1)
|
||||
, _currentBit(-1)
|
||||
, _owner(NULL)
|
||||
, _actionManager(NULL)
|
||||
, _actionManagers(NULL)
|
||||
, _nodeLoaderLibrary(NULL)
|
||||
, _nodeLoaderListener(NULL)
|
||||
, _CCBMemberVariableAssigner(NULL)
|
||||
, _CCBSelectorResolver(NULL)
|
||||
, _nodesWithAnimationManagers(NULL)
|
||||
, _animationManagersForNodes(NULL)
|
||||
, _hasScriptingOwner(false)
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
CCBReader::~CCBReader() {
|
||||
CC_SAFE_RELEASE_NULL(mOwner);
|
||||
CC_SAFE_RELEASE_NULL(mData);
|
||||
CC_SAFE_RELEASE_NULL(_owner);
|
||||
CC_SAFE_RELEASE_NULL(_data);
|
||||
|
||||
this->mNodeLoaderLibrary->release();
|
||||
this->_nodeLoaderLibrary->release();
|
||||
|
||||
CC_SAFE_RELEASE(mOwnerOutletNodes);
|
||||
mOwnerOutletNames.clear();
|
||||
CC_SAFE_RELEASE(mOwnerCallbackNodes);
|
||||
mOwnerCallbackNames.clear();
|
||||
CC_SAFE_RELEASE(_ownerOutletNodes);
|
||||
_ownerOutletNames.clear();
|
||||
CC_SAFE_RELEASE(_ownerCallbackNodes);
|
||||
_ownerCallbackNames.clear();
|
||||
|
||||
// Clear string cache.
|
||||
|
||||
this->mStringCache.clear();
|
||||
CC_SAFE_RELEASE(mNodesWithAnimationManagers);
|
||||
CC_SAFE_RELEASE(mAnimationManagersForNodes);
|
||||
this->_stringCache.clear();
|
||||
CC_SAFE_RELEASE(_nodesWithAnimationManagers);
|
||||
CC_SAFE_RELEASE(_animationManagersForNodes);
|
||||
|
||||
setAnimationManager(NULL);
|
||||
}
|
||||
|
||||
void CCBReader::setCCBRootPath(const char* pCCBRootPath)
|
||||
void CCBReader::setCCBRootPath(const char* ccbRootPath)
|
||||
{
|
||||
CCASSERT(pCCBRootPath != NULL, "");
|
||||
mCCBRootPath = pCCBRootPath;
|
||||
CCASSERT(ccbRootPath != NULL, "");
|
||||
_CCBRootPath = ccbRootPath;
|
||||
}
|
||||
|
||||
const std::string& CCBReader::getCCBRootPath() const
|
||||
{
|
||||
return mCCBRootPath;
|
||||
return _CCBRootPath;
|
||||
}
|
||||
|
||||
bool CCBReader::init()
|
||||
|
@ -172,54 +168,54 @@ bool CCBReader::init()
|
|||
pActionManager->release();
|
||||
|
||||
// Setup resolution scale and container size
|
||||
mActionManager->setRootContainerSize(Director::getInstance()->getWinSize());
|
||||
_actionManager->setRootContainerSize(Director::getInstance()->getWinSize());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
CCBAnimationManager* CCBReader::getAnimationManager()
|
||||
{
|
||||
return mActionManager;
|
||||
return _actionManager;
|
||||
}
|
||||
|
||||
void CCBReader::setAnimationManager(CCBAnimationManager *pAnimationManager)
|
||||
{
|
||||
CC_SAFE_RELEASE(mActionManager);
|
||||
mActionManager = pAnimationManager;
|
||||
CC_SAFE_RETAIN(mActionManager);
|
||||
CC_SAFE_RELEASE(_actionManager);
|
||||
_actionManager = pAnimationManager;
|
||||
CC_SAFE_RETAIN(_actionManager);
|
||||
}
|
||||
|
||||
Dictionary* CCBReader::getAnimationManagers()
|
||||
{
|
||||
return mActionManagers;
|
||||
return _actionManagers;
|
||||
}
|
||||
|
||||
void CCBReader::setAnimationManagers(Dictionary* x)
|
||||
{
|
||||
mActionManagers = x;
|
||||
_actionManagers = x;
|
||||
}
|
||||
|
||||
CCBMemberVariableAssigner * CCBReader::getCCBMemberVariableAssigner() {
|
||||
return this->mCCBMemberVariableAssigner;
|
||||
return this->_CCBMemberVariableAssigner;
|
||||
}
|
||||
|
||||
CCBSelectorResolver * CCBReader::getCCBSelectorResolver() {
|
||||
return this->mCCBSelectorResolver;
|
||||
return this->_CCBSelectorResolver;
|
||||
}
|
||||
|
||||
set<string>* CCBReader::getAnimatedProperties()
|
||||
{
|
||||
return mAnimatedProps;
|
||||
return _animatedProps;
|
||||
}
|
||||
|
||||
set<string>& CCBReader::getLoadedSpriteSheet()
|
||||
{
|
||||
return mLoadedSpriteSheets;
|
||||
return _loadedSpriteSheets;
|
||||
}
|
||||
|
||||
Object* CCBReader::getOwner()
|
||||
{
|
||||
return mOwner;
|
||||
return _owner;
|
||||
}
|
||||
|
||||
Node* CCBReader::readNodeGraphFromFile(const char *pCCBFileName)
|
||||
|
@ -263,31 +259,31 @@ Node* CCBReader::readNodeGraphFromFile(const char *pCCBFileName, Object *pOwner,
|
|||
|
||||
Node* CCBReader::readNodeGraphFromData(Data *pData, Object *pOwner, const Size &parentSize)
|
||||
{
|
||||
mData = pData;
|
||||
CC_SAFE_RETAIN(mData);
|
||||
mBytes = mData->getBytes();
|
||||
mCurrentByte = 0;
|
||||
mCurrentBit = 0;
|
||||
mOwner = pOwner;
|
||||
CC_SAFE_RETAIN(mOwner);
|
||||
_data = pData;
|
||||
CC_SAFE_RETAIN(_data);
|
||||
_bytes =_data->getBytes();
|
||||
_currentByte = 0;
|
||||
_currentBit = 0;
|
||||
_owner = pOwner;
|
||||
CC_SAFE_RETAIN(_owner);
|
||||
|
||||
mActionManager->setRootContainerSize(parentSize);
|
||||
mActionManager->mOwner = mOwner;
|
||||
mOwnerOutletNodes = new Array();
|
||||
mOwnerCallbackNodes = new Array();
|
||||
_actionManager->setRootContainerSize(parentSize);
|
||||
_actionManager->_owner = _owner;
|
||||
_ownerOutletNodes = new Array();
|
||||
_ownerCallbackNodes = new Array();
|
||||
|
||||
Dictionary* animationManagers = Dictionary::create();
|
||||
Node *pNodeGraph = readFileWithCleanUp(true, animationManagers);
|
||||
|
||||
if (pNodeGraph && mActionManager->getAutoPlaySequenceId() != -1 && !jsControlled)
|
||||
if (pNodeGraph && _actionManager->getAutoPlaySequenceId() != -1 && !_jsControlled)
|
||||
{
|
||||
// Auto play animations
|
||||
mActionManager->runAnimationsForSequenceIdTweenDuration(mActionManager->getAutoPlaySequenceId(), 0);
|
||||
_actionManager->runAnimationsForSequenceIdTweenDuration(_actionManager->getAutoPlaySequenceId(), 0);
|
||||
}
|
||||
// Assign actionManagers to userObject
|
||||
if(jsControlled) {
|
||||
mNodesWithAnimationManagers = new Array();
|
||||
mAnimationManagersForNodes = new Array();
|
||||
if(_jsControlled) {
|
||||
_nodesWithAnimationManagers = new Array();
|
||||
_animationManagersForNodes = new Array();
|
||||
}
|
||||
|
||||
DictElement* pElement = NULL;
|
||||
|
@ -297,10 +293,10 @@ Node* CCBReader::readNodeGraphFromData(Data *pData, Object *pOwner, const Size &
|
|||
CCBAnimationManager* manager = static_cast<CCBAnimationManager*>(animationManagers->objectForKey((intptr_t)pNode));
|
||||
pNode->setUserObject(manager);
|
||||
|
||||
if (jsControlled)
|
||||
if (_jsControlled)
|
||||
{
|
||||
mNodesWithAnimationManagers->addObject(pNode);
|
||||
mAnimationManagersForNodes->addObject(manager);
|
||||
_nodesWithAnimationManagers->addObject(pNode);
|
||||
_animationManagersForNodes->addObject(manager);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -358,7 +354,7 @@ Node* CCBReader::readFileWithCleanUp(bool bCleanUp, Dictionary* am)
|
|||
|
||||
Node *pNode = readNodeGraph(NULL);
|
||||
|
||||
mActionManagers->setObject(mActionManager, intptr_t(pNode));
|
||||
_actionManagers->setObject(_actionManager, intptr_t(pNode));
|
||||
|
||||
if (bCleanUp)
|
||||
{
|
||||
|
@ -372,7 +368,7 @@ bool CCBReader::readStringCache() {
|
|||
int numStrings = this->readInt(false);
|
||||
|
||||
for(int i = 0; i < numStrings; i++) {
|
||||
this->mStringCache.push_back(this->readUTF8());
|
||||
this->_stringCache.push_back(this->readUTF8());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -381,13 +377,13 @@ bool CCBReader::readStringCache() {
|
|||
bool CCBReader::readHeader()
|
||||
{
|
||||
/* If no bytes loaded, don't crash about it. */
|
||||
if(this->mBytes == NULL) {
|
||||
if(this->_bytes == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Read magic bytes */
|
||||
int magicBytes = *((int*)(this->mBytes + this->mCurrentByte));
|
||||
this->mCurrentByte += 4;
|
||||
int magicBytes = *((int*)(this->_bytes + this->_currentByte));
|
||||
this->_currentByte += 4;
|
||||
|
||||
if(CC_SWAP_INT32_LITTLE_TO_HOST(magicBytes) != 'ccbi') {
|
||||
return false;
|
||||
|
@ -395,25 +391,27 @@ bool CCBReader::readHeader()
|
|||
|
||||
/* Read version. */
|
||||
int version = this->readInt(false);
|
||||
if(version != kCCBVersion) {
|
||||
log("WARNING! Incompatible ccbi file version (file: %d reader: %d)", version, kCCBVersion);
|
||||
if(version != CCB_VERSION) {
|
||||
log("WARNING! Incompatible ccbi file version (file: %d reader: %d)", version, CCB_VERSION);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Read JS check
|
||||
jsControlled = this->readBool();
|
||||
mActionManager->jsControlled = jsControlled;
|
||||
_jsControlled = this->readBool();
|
||||
_actionManager->_jsControlled = _jsControlled;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
unsigned char CCBReader::readByte() {
|
||||
unsigned char byte = this->mBytes[this->mCurrentByte];
|
||||
this->mCurrentByte++;
|
||||
unsigned char CCBReader::readByte()
|
||||
{
|
||||
unsigned char byte = this->_bytes[this->_currentByte];
|
||||
this->_currentByte++;
|
||||
return byte;
|
||||
}
|
||||
|
||||
bool CCBReader::readBool() {
|
||||
bool CCBReader::readBool()
|
||||
{
|
||||
return 0 == this->readByte() ? false : true;
|
||||
}
|
||||
|
||||
|
@ -427,39 +425,39 @@ std::string CCBReader::readUTF8()
|
|||
int numBytes = b0 << 8 | b1;
|
||||
|
||||
char* pStr = (char*)malloc(numBytes+1);
|
||||
memcpy(pStr, mBytes+mCurrentByte, numBytes);
|
||||
memcpy(pStr, _bytes+_currentByte, numBytes);
|
||||
pStr[numBytes] = '\0';
|
||||
ret = pStr;
|
||||
free(pStr);
|
||||
|
||||
mCurrentByte += numBytes;
|
||||
_currentByte += numBytes;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool CCBReader::getBit() {
|
||||
bool bit;
|
||||
unsigned char byte = *(this->mBytes + this->mCurrentByte);
|
||||
if(byte & (1 << this->mCurrentBit)) {
|
||||
unsigned char byte = *(this->_bytes + this->_currentByte);
|
||||
if(byte & (1 << this->_currentBit)) {
|
||||
bit = true;
|
||||
} else {
|
||||
bit = false;
|
||||
}
|
||||
|
||||
this->mCurrentBit++;
|
||||
this->_currentBit++;
|
||||
|
||||
if(this->mCurrentBit >= 8) {
|
||||
this->mCurrentBit = 0;
|
||||
this->mCurrentByte++;
|
||||
if(this->_currentBit >= 8) {
|
||||
this->_currentBit = 0;
|
||||
this->_currentByte++;
|
||||
}
|
||||
|
||||
return bit;
|
||||
}
|
||||
|
||||
void CCBReader::alignBits() {
|
||||
if(this->mCurrentBit) {
|
||||
this->mCurrentBit = 0;
|
||||
this->mCurrentByte++;
|
||||
if(this->_currentBit) {
|
||||
this->_currentBit = 0;
|
||||
this->_currentByte++;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -496,26 +494,28 @@ int CCBReader::readInt(bool pSigned) {
|
|||
}
|
||||
|
||||
|
||||
float CCBReader::readFloat() {
|
||||
unsigned char type = this->readByte();
|
||||
float CCBReader::readFloat()
|
||||
{
|
||||
FloatType type = static_cast<FloatType>(this->readByte());
|
||||
|
||||
switch (type) {
|
||||
case kCCBFloat0:
|
||||
switch (type)
|
||||
{
|
||||
case FloatType::_0:
|
||||
return 0;
|
||||
case kCCBFloat1:
|
||||
case FloatType::_1:
|
||||
return 1;
|
||||
case kCCBFloatMinus1:
|
||||
case FloatType::MINUS1:
|
||||
return -1;
|
||||
case kCCBFloat05:
|
||||
case FloatType::_05:
|
||||
return 0.5f;
|
||||
case kCCBFloatInteger:
|
||||
case FloatType::INTEGER:
|
||||
return (float)this->readInt(true);
|
||||
default:
|
||||
{
|
||||
/* using a memcpy since the compiler isn't
|
||||
* doing the float ptr math correctly on device.
|
||||
* TODO still applies in C++ ? */
|
||||
unsigned char* pF = (this->mBytes + this->mCurrentByte);
|
||||
unsigned char* pF = (this->_bytes + this->_currentByte);
|
||||
float f = 0;
|
||||
|
||||
// N.B - in order to avoid an unaligned memory access crash on 'memcpy()' the the (void*) casts of the source and
|
||||
|
@ -531,35 +531,38 @@ float CCBReader::readFloat() {
|
|||
// http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.faqs/ka3934.html
|
||||
memcpy((void*) &f, (const void*) pF, sizeof(float));
|
||||
|
||||
this->mCurrentByte += sizeof(float);
|
||||
this->_currentByte += sizeof(float);
|
||||
return f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string CCBReader::readCachedString() {
|
||||
std::string CCBReader::readCachedString()
|
||||
{
|
||||
int n = this->readInt(false);
|
||||
return this->mStringCache[n];
|
||||
return this->_stringCache[n];
|
||||
}
|
||||
|
||||
Node * CCBReader::readNodeGraph(Node * pParent) {
|
||||
Node * CCBReader::readNodeGraph(Node * pParent)
|
||||
{
|
||||
/* Read class name. */
|
||||
std::string className = this->readCachedString();
|
||||
|
||||
std::string jsControlledName;
|
||||
std::string _jsControlledName;
|
||||
|
||||
if(jsControlled) {
|
||||
jsControlledName = this->readCachedString();
|
||||
if(_jsControlled) {
|
||||
_jsControlledName = this->readCachedString();
|
||||
}
|
||||
|
||||
// Read assignment type and name
|
||||
int memberVarAssignmentType = this->readInt(false);
|
||||
TargetType memberVarAssignmentType = static_cast<TargetType>(this->readInt(false));
|
||||
std::string memberVarAssignmentName;
|
||||
if(memberVarAssignmentType != kCCBTargetTypeNone) {
|
||||
if(memberVarAssignmentType != TargetType::NONE)
|
||||
{
|
||||
memberVarAssignmentName = this->readCachedString();
|
||||
}
|
||||
|
||||
NodeLoader *ccNodeLoader = this->mNodeLoaderLibrary->getNodeLoader(className.c_str());
|
||||
NodeLoader *ccNodeLoader = this->_nodeLoaderLibrary->getNodeLoader(className.c_str());
|
||||
|
||||
if (! ccNodeLoader)
|
||||
{
|
||||
|
@ -570,20 +573,20 @@ Node * CCBReader::readNodeGraph(Node * pParent) {
|
|||
Node *node = ccNodeLoader->loadNode(pParent, this);
|
||||
|
||||
// Set root node
|
||||
if (! mActionManager->getRootNode())
|
||||
if (! _actionManager->getRootNode())
|
||||
{
|
||||
mActionManager->setRootNode(node);
|
||||
_actionManager->setRootNode(node);
|
||||
}
|
||||
|
||||
// Assign controller
|
||||
if(jsControlled && node == mActionManager->getRootNode())
|
||||
if(_jsControlled && node == _actionManager->getRootNode())
|
||||
{
|
||||
mActionManager->setDocumentControllerName(jsControlledName);
|
||||
_actionManager->setDocumentControllerName(_jsControlledName);
|
||||
}
|
||||
|
||||
// Read animated properties
|
||||
Dictionary *seqs = Dictionary::create();
|
||||
mAnimatedProps = new set<string>();
|
||||
_animatedProps = new set<string>();
|
||||
|
||||
int numSequence = readInt(false);
|
||||
for (int i = 0; i < numSequence; ++i)
|
||||
|
@ -600,13 +603,13 @@ Node * CCBReader::readNodeGraph(Node * pParent) {
|
|||
|
||||
seqProp->setName(readCachedString().c_str());
|
||||
seqProp->setType(readInt(false));
|
||||
mAnimatedProps->insert(seqProp->getName());
|
||||
_animatedProps->insert(seqProp->getName());
|
||||
|
||||
int numKeyframes = readInt(false);
|
||||
|
||||
for (int k = 0; k < numKeyframes; ++k)
|
||||
{
|
||||
CCBKeyframe *keyframe = readKeyframe(seqProp->getType());
|
||||
CCBKeyframe *keyframe = readKeyframe(static_cast<PropertyType>(seqProp->getType()));
|
||||
|
||||
seqProp->getKeyframes()->addObject(keyframe);
|
||||
}
|
||||
|
@ -619,7 +622,7 @@ Node * CCBReader::readNodeGraph(Node * pParent) {
|
|||
|
||||
if (seqs->count() > 0)
|
||||
{
|
||||
mActionManager->addNode(node, seqs);
|
||||
_actionManager->addNode(node, seqs);
|
||||
}
|
||||
|
||||
// Read properties
|
||||
|
@ -640,7 +643,7 @@ Node * CCBReader::readNodeGraph(Node * pParent) {
|
|||
embeddedNode->setVisible(true);
|
||||
//embeddedNode->ignoreAnchorPointForPosition(ccbFileNode->isIgnoreAnchorPointForPosition());
|
||||
|
||||
mActionManager->moveAnimationsFromNode(ccbFileNode, embeddedNode);
|
||||
_actionManager->moveAnimationsFromNode(ccbFileNode, embeddedNode);
|
||||
|
||||
ccbFileNode->setCCBFileNode(NULL);
|
||||
|
||||
|
@ -654,18 +657,18 @@ Node * CCBReader::readNodeGraph(Node * pParent) {
|
|||
[[JSCocoa sharedController] setObject:node withName:memberVarAssignmentName];
|
||||
}*/
|
||||
#else
|
||||
if (memberVarAssignmentType != kCCBTargetTypeNone)
|
||||
if (memberVarAssignmentType != TargetType::NONE)
|
||||
{
|
||||
if(!jsControlled)
|
||||
if(!_jsControlled)
|
||||
{
|
||||
Object * target = NULL;
|
||||
if(memberVarAssignmentType == kCCBTargetTypeDocumentRoot)
|
||||
if(memberVarAssignmentType == TargetType::DOCUMENT_ROOT)
|
||||
{
|
||||
target = mActionManager->getRootNode();
|
||||
target = _actionManager->getRootNode();
|
||||
}
|
||||
else if(memberVarAssignmentType == kCCBTargetTypeOwner)
|
||||
else if(memberVarAssignmentType == TargetType::OWNER)
|
||||
{
|
||||
target = this->mOwner;
|
||||
target = this->_owner;
|
||||
}
|
||||
|
||||
if(target != NULL)
|
||||
|
@ -673,36 +676,41 @@ Node * CCBReader::readNodeGraph(Node * pParent) {
|
|||
CCBMemberVariableAssigner * targetAsCCBMemberVariableAssigner = dynamic_cast<CCBMemberVariableAssigner *>(target);
|
||||
|
||||
bool assigned = false;
|
||||
if (memberVarAssignmentType != kCCBTargetTypeNone)
|
||||
if (memberVarAssignmentType != TargetType::NONE)
|
||||
{
|
||||
if(targetAsCCBMemberVariableAssigner != NULL) {
|
||||
if(targetAsCCBMemberVariableAssigner != NULL)
|
||||
{
|
||||
assigned = targetAsCCBMemberVariableAssigner->onAssignCCBMemberVariable(target, memberVarAssignmentName.c_str(), node);
|
||||
}
|
||||
|
||||
if(!assigned && this->mCCBMemberVariableAssigner != NULL) {
|
||||
assigned = this->mCCBMemberVariableAssigner->onAssignCCBMemberVariable(target, memberVarAssignmentName.c_str(), node);
|
||||
if(!assigned && this->_CCBMemberVariableAssigner != NULL)
|
||||
{
|
||||
assigned = this->_CCBMemberVariableAssigner->onAssignCCBMemberVariable(target, memberVarAssignmentName.c_str(), node);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(memberVarAssignmentType == kCCBTargetTypeDocumentRoot) {
|
||||
mActionManager->addDocumentOutletName(memberVarAssignmentName);
|
||||
mActionManager->addDocumentOutletNode(node);
|
||||
} else {
|
||||
mOwnerOutletNames.push_back(memberVarAssignmentName);
|
||||
mOwnerOutletNodes->addObject(node);
|
||||
if(memberVarAssignmentType == TargetType::DOCUMENT_ROOT)
|
||||
{
|
||||
_actionManager->addDocumentOutletName(memberVarAssignmentName);
|
||||
_actionManager->addDocumentOutletNode(node);
|
||||
}
|
||||
else
|
||||
{
|
||||
_ownerOutletNames.push_back(memberVarAssignmentName);
|
||||
_ownerOutletNodes->addObject(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Assign custom properties.
|
||||
if (ccNodeLoader->getCustomProperties()->count() > 0) {
|
||||
|
||||
if (ccNodeLoader->getCustomProperties()->count() > 0)
|
||||
{
|
||||
bool customAssigned = false;
|
||||
|
||||
if(!jsControlled)
|
||||
if(!_jsControlled)
|
||||
{
|
||||
Object * target = node;
|
||||
if(target != NULL)
|
||||
|
@ -716,9 +724,9 @@ Node * CCBReader::readNodeGraph(Node * pParent) {
|
|||
{
|
||||
customAssigned = targetAsCCBMemberVariableAssigner->onAssignCCBCustomProperty(target, pElement->getStrKey(), static_cast<CCBValue*>(pElement->getObject()));
|
||||
|
||||
if(!customAssigned && this->mCCBMemberVariableAssigner != NULL)
|
||||
if(!customAssigned && this->_CCBMemberVariableAssigner != NULL)
|
||||
{
|
||||
customAssigned = this->mCCBMemberVariableAssigner->onAssignCCBCustomProperty(target, pElement->getStrKey(), static_cast<CCBValue*>(pElement->getObject()));
|
||||
customAssigned = this->_CCBMemberVariableAssigner->onAssignCCBCustomProperty(target, pElement->getStrKey(), static_cast<CCBValue*>(pElement->getObject()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -728,8 +736,8 @@ Node * CCBReader::readNodeGraph(Node * pParent) {
|
|||
|
||||
#endif // CCB_ENABLE_JAVASCRIPT
|
||||
|
||||
delete mAnimatedProps;
|
||||
mAnimatedProps = NULL;
|
||||
delete _animatedProps;
|
||||
_animatedProps = NULL;
|
||||
|
||||
/* Read and add children. */
|
||||
int numChildren = this->readInt(false);
|
||||
|
@ -746,45 +754,45 @@ Node * CCBReader::readNodeGraph(Node * pParent) {
|
|||
NodeLoaderListener * nodeAsNodeLoaderListener = dynamic_cast<NodeLoaderListener *>(node);
|
||||
if(nodeAsNodeLoaderListener != NULL) {
|
||||
nodeAsNodeLoaderListener->onNodeLoaded(node, ccNodeLoader);
|
||||
} else if(this->mNodeLoaderListener != NULL) {
|
||||
this->mNodeLoaderListener->onNodeLoaded(node, ccNodeLoader);
|
||||
} else if(this->_nodeLoaderListener != NULL) {
|
||||
this->_nodeLoaderListener->onNodeLoaded(node, ccNodeLoader);
|
||||
}
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
CCBKeyframe* CCBReader::readKeyframe(int type)
|
||||
CCBKeyframe* CCBReader::readKeyframe(PropertyType type)
|
||||
{
|
||||
CCBKeyframe *keyframe = new CCBKeyframe();
|
||||
keyframe->autorelease();
|
||||
|
||||
keyframe->setTime(readFloat());
|
||||
|
||||
int easingType = readInt(false);
|
||||
CCBKeyframe::EasingType easingType = static_cast<CCBKeyframe::EasingType>(readInt(false));
|
||||
float easingOpt = 0;
|
||||
Object *value = NULL;
|
||||
|
||||
if (easingType == kCCBKeyframeEasingCubicIn
|
||||
|| easingType == kCCBKeyframeEasingCubicOut
|
||||
|| easingType == kCCBKeyframeEasingCubicInOut
|
||||
|| easingType == kCCBKeyframeEasingElasticIn
|
||||
|| easingType == kCCBKeyframeEasingElasticOut
|
||||
|| easingType == kCCBKeyframeEasingElasticInOut)
|
||||
if (easingType == CCBKeyframe::EasingType::CUBIC_IN
|
||||
|| easingType == CCBKeyframe::EasingType::CUBIC_OUT
|
||||
|| easingType == CCBKeyframe::EasingType::CUBIC_INOUT
|
||||
|| easingType == CCBKeyframe::EasingType::ELASTIC_IN
|
||||
|| easingType == CCBKeyframe::EasingType::ELASTIC_OUT
|
||||
|| easingType == CCBKeyframe::EasingType::ELASTIC_INOUT)
|
||||
{
|
||||
easingOpt = readFloat();
|
||||
}
|
||||
keyframe->setEasingType(easingType);
|
||||
keyframe->setEasingOpt(easingOpt);
|
||||
|
||||
if (type == kCCBPropTypeCheck)
|
||||
if (type == PropertyType::CHECK)
|
||||
{
|
||||
value = CCBValue::create(readBool());
|
||||
}
|
||||
else if (type == kCCBPropTypeByte)
|
||||
else if (type == PropertyType::BYTE)
|
||||
{
|
||||
value = CCBValue::create(readByte());
|
||||
}
|
||||
else if (type == kCCBPropTypeColor3)
|
||||
else if (type == PropertyType::COLOR3)
|
||||
{
|
||||
int r = readByte();
|
||||
int g = readByte();
|
||||
|
@ -793,12 +801,12 @@ CCBKeyframe* CCBReader::readKeyframe(int type)
|
|||
Color3B c = Color3B(r,g,b);
|
||||
value = Color3BWapper::create(c);
|
||||
}
|
||||
else if (type == kCCBPropTypeDegrees)
|
||||
else if (type == PropertyType::DEGREES)
|
||||
{
|
||||
value = CCBValue::create(readFloat());
|
||||
}
|
||||
else if (type == kCCBPropTypeScaleLock || type == kCCBPropTypePosition
|
||||
|| type == kCCBPropTypeFloatXY)
|
||||
else if (type == PropertyType::SCALE_LOCK || type == PropertyType::POSITION
|
||||
|| type == PropertyType::FLOAT_XY)
|
||||
{
|
||||
float a = readFloat();
|
||||
float b = readFloat();
|
||||
|
@ -807,7 +815,7 @@ CCBKeyframe* CCBReader::readKeyframe(int type)
|
|||
CCBValue::create(b),
|
||||
NULL);
|
||||
}
|
||||
else if (type == kCCBPropTypeSpriteFrame)
|
||||
else if (type == PropertyType::SPRITEFRAME)
|
||||
{
|
||||
std::string spriteSheet = readCachedString();
|
||||
std::string spriteFile = readCachedString();
|
||||
|
@ -816,7 +824,7 @@ CCBKeyframe* CCBReader::readKeyframe(int type)
|
|||
|
||||
if (spriteSheet.length() == 0)
|
||||
{
|
||||
spriteFile = mCCBRootPath + spriteFile;
|
||||
spriteFile = _CCBRootPath + spriteFile;
|
||||
|
||||
Texture2D *texture = TextureCache::getInstance()->addImage(spriteFile.c_str());
|
||||
Rect bounds = Rect(0, 0, texture->getContentSize().width, texture->getContentSize().height);
|
||||
|
@ -825,14 +833,14 @@ CCBKeyframe* CCBReader::readKeyframe(int type)
|
|||
}
|
||||
else
|
||||
{
|
||||
spriteSheet = mCCBRootPath + spriteSheet;
|
||||
spriteSheet = _CCBRootPath + spriteSheet;
|
||||
SpriteFrameCache* frameCache = SpriteFrameCache::getInstance();
|
||||
|
||||
// Load the sprite sheet only if it is not loaded
|
||||
if (mLoadedSpriteSheets.find(spriteSheet) == mLoadedSpriteSheets.end())
|
||||
if (_loadedSpriteSheets.find(spriteSheet) == _loadedSpriteSheets.end())
|
||||
{
|
||||
frameCache->addSpriteFramesWithFile(spriteSheet.c_str());
|
||||
mLoadedSpriteSheets.insert(spriteSheet);
|
||||
_loadedSpriteSheets.insert(spriteSheet);
|
||||
}
|
||||
|
||||
spriteFrame = frameCache->getSpriteFrameByName(spriteFile.c_str());
|
||||
|
@ -846,7 +854,8 @@ CCBKeyframe* CCBReader::readKeyframe(int type)
|
|||
}
|
||||
|
||||
|
||||
bool CCBReader::readCallbackKeyframesForSeq(CCBSequence* seq) {
|
||||
bool CCBReader::readCallbackKeyframesForSeq(CCBSequence* seq)
|
||||
{
|
||||
int numKeyframes = readInt(false);
|
||||
if(!numKeyframes) return true;
|
||||
|
||||
|
@ -870,9 +879,9 @@ bool CCBReader::readCallbackKeyframesForSeq(CCBSequence* seq) {
|
|||
keyframe->setTime(time);
|
||||
keyframe->setValue(value);
|
||||
|
||||
if(jsControlled) {
|
||||
if(_jsControlled) {
|
||||
string callbackIdentifier;
|
||||
mActionManager->getKeyframeCallbacks()->addObject(String::createWithFormat("%d:%s",callbackType, callbackName.c_str()));
|
||||
_actionManager->getKeyframeCallbacks()->addObject(String::createWithFormat("%d:%s",callbackType, callbackName.c_str()));
|
||||
}
|
||||
|
||||
channel->getKeyframes()->addObject(keyframe);
|
||||
|
@ -924,7 +933,7 @@ Node * CCBReader::readNodeGraph() {
|
|||
|
||||
bool CCBReader::readSequences()
|
||||
{
|
||||
Array *sequences = mActionManager->getSequences();
|
||||
Array *sequences = _actionManager->getSequences();
|
||||
|
||||
int numSeqs = readInt(false);
|
||||
|
||||
|
@ -944,7 +953,7 @@ bool CCBReader::readSequences()
|
|||
sequences->addObject(seq);
|
||||
}
|
||||
|
||||
mActionManager->setAutoPlaySequenceId(readInt(true));
|
||||
_actionManager->setAutoPlaySequenceId(readInt(true));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -983,31 +992,31 @@ bool CCBReader::endsWith(const char* pString, const char* pEnding) {
|
|||
}
|
||||
|
||||
bool CCBReader::isJSControlled() {
|
||||
return jsControlled;
|
||||
return _jsControlled;
|
||||
}
|
||||
|
||||
void CCBReader::addOwnerCallbackName(std::string name) {
|
||||
mOwnerCallbackNames.push_back(name);
|
||||
_ownerCallbackNames.push_back(name);
|
||||
}
|
||||
|
||||
void CCBReader::addOwnerCallbackNode(Node *node) {
|
||||
mOwnerCallbackNodes->addObject(node);
|
||||
_ownerCallbackNodes->addObject(node);
|
||||
}
|
||||
|
||||
|
||||
void CCBReader::addDocumentCallbackName(std::string name) {
|
||||
mActionManager->addDocumentCallbackName(name);
|
||||
_actionManager->addDocumentCallbackName(name);
|
||||
}
|
||||
|
||||
void CCBReader::addDocumentCallbackNode(Node *node) {
|
||||
mActionManager->addDocumentCallbackNode(node);
|
||||
_actionManager->addDocumentCallbackNode(node);
|
||||
}
|
||||
|
||||
|
||||
Array* CCBReader::getOwnerCallbackNames() {
|
||||
Array* pRet = Array::createWithCapacity(mOwnerCallbackNames.size());
|
||||
std::vector<std::string>::iterator it = mOwnerCallbackNames.begin();
|
||||
for (; it != mOwnerCallbackNames.end(); ++it)
|
||||
Array* pRet = Array::createWithCapacity(_ownerCallbackNames.size());
|
||||
std::vector<std::string>::iterator it = _ownerCallbackNames.begin();
|
||||
for (; it != _ownerCallbackNames.end(); ++it)
|
||||
{
|
||||
pRet->addObject(String::create(*it));
|
||||
}
|
||||
|
@ -1016,13 +1025,13 @@ Array* CCBReader::getOwnerCallbackNames() {
|
|||
}
|
||||
|
||||
Array* CCBReader::getOwnerCallbackNodes() {
|
||||
return mOwnerCallbackNodes;
|
||||
return _ownerCallbackNodes;
|
||||
}
|
||||
|
||||
Array* CCBReader::getOwnerOutletNames() {
|
||||
Array* pRet = Array::createWithCapacity(mOwnerOutletNames.size());
|
||||
std::vector<std::string>::iterator it = mOwnerOutletNames.begin();
|
||||
for (; it != mOwnerOutletNames.end(); ++it)
|
||||
Array* pRet = Array::createWithCapacity(_ownerOutletNames.size());
|
||||
std::vector<std::string>::iterator it = _ownerOutletNames.begin();
|
||||
for (; it != _ownerOutletNames.end(); ++it)
|
||||
{
|
||||
pRet->addObject(String::create(*it));
|
||||
}
|
||||
|
@ -1030,20 +1039,20 @@ Array* CCBReader::getOwnerOutletNames() {
|
|||
}
|
||||
|
||||
Array* CCBReader::getOwnerOutletNodes() {
|
||||
return mOwnerOutletNodes;
|
||||
return _ownerOutletNodes;
|
||||
}
|
||||
|
||||
Array* CCBReader::getNodesWithAnimationManagers() {
|
||||
return mNodesWithAnimationManagers;
|
||||
return _nodesWithAnimationManagers;
|
||||
}
|
||||
|
||||
Array* CCBReader::getAnimationManagersForNodes() {
|
||||
return mAnimationManagersForNodes;
|
||||
return _animationManagersForNodes;
|
||||
}
|
||||
|
||||
void CCBReader::addOwnerOutletName(std::string name)
|
||||
{
|
||||
mOwnerOutletNames.push_back(name);
|
||||
_ownerOutletNames.push_back(name);
|
||||
|
||||
}
|
||||
void CCBReader::addOwnerOutletNode(Node *node)
|
||||
|
@ -1051,7 +1060,7 @@ void CCBReader::addOwnerOutletNode(Node *node)
|
|||
if (NULL != node)
|
||||
return;
|
||||
|
||||
mOwnerOutletNodes->addObject(node);
|
||||
_ownerOutletNodes->addObject(node);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
|
|
|
@ -28,109 +28,7 @@
|
|||
return NULL; \
|
||||
}
|
||||
|
||||
#define kCCBVersion 5
|
||||
|
||||
enum {
|
||||
kCCBPropTypePosition = 0,
|
||||
kCCBPropTypeSize,
|
||||
kCCBPropTypePoint,
|
||||
kCCBPropTypePointLock,
|
||||
kCCBPropTypeScaleLock,
|
||||
kCCBPropTypeDegrees,
|
||||
kCCBPropTypeInteger,
|
||||
kCCBPropTypeFloat,
|
||||
kCCBPropTypeFloatVar,
|
||||
kCCBPropTypeCheck,
|
||||
kCCBPropTypeSpriteFrame,
|
||||
kCCBPropTypeTexture,
|
||||
kCCBPropTypeByte,
|
||||
kCCBPropTypeColor3,
|
||||
kCCBPropTypeColor4FVar,
|
||||
kCCBPropTypeFlip,
|
||||
kCCBPropTypeBlendmode,
|
||||
kCCBPropTypeFntFile,
|
||||
kCCBPropTypeText,
|
||||
kCCBPropTypeFontTTF,
|
||||
kCCBPropTypeIntegerLabeled,
|
||||
kCCBPropTypeBlock,
|
||||
kCCBPropTypeAnimation,
|
||||
kCCBPropTypeCCBFile,
|
||||
kCCBPropTypeString,
|
||||
kCCBPropTypeBlockControl,
|
||||
kCCBPropTypeFloatScale,
|
||||
kCCBPropTypeFloatXY
|
||||
};
|
||||
|
||||
enum {
|
||||
kCCBFloat0 = 0,
|
||||
kCCBFloat1,
|
||||
kCCBFloatMinus1,
|
||||
kCCBFloat05,
|
||||
kCCBFloatInteger,
|
||||
kCCBFloatFull
|
||||
};
|
||||
|
||||
enum {
|
||||
kCCBPlatformAll = 0,
|
||||
kCCBPlatformIOS,
|
||||
kCCBPlatformMac
|
||||
};
|
||||
|
||||
enum {
|
||||
kCCBTargetTypeNone = 0,
|
||||
kCCBTargetTypeDocumentRoot = 1,
|
||||
kCCBTargetTypeOwner = 2,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
kCCBKeyframeEasingInstant,
|
||||
|
||||
kCCBKeyframeEasingLinear,
|
||||
|
||||
kCCBKeyframeEasingCubicIn,
|
||||
kCCBKeyframeEasingCubicOut,
|
||||
kCCBKeyframeEasingCubicInOut,
|
||||
|
||||
kCCBKeyframeEasingElasticIn,
|
||||
kCCBKeyframeEasingElasticOut,
|
||||
kCCBKeyframeEasingElasticInOut,
|
||||
|
||||
kCCBKeyframeEasingBounceIn,
|
||||
kCCBKeyframeEasingBounceOut,
|
||||
kCCBKeyframeEasingBounceInOut,
|
||||
|
||||
kCCBKeyframeEasingBackIn,
|
||||
kCCBKeyframeEasingBackOut,
|
||||
kCCBKeyframeEasingBackInOut,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
kCCBPositionTypeRelativeBottomLeft,
|
||||
kCCBPositionTypeRelativeTopLeft,
|
||||
kCCBPositionTypeRelativeTopRight,
|
||||
kCCBPositionTypeRelativeBottomRight,
|
||||
kCCBPositionTypePercent,
|
||||
kCCBPositionTypeMultiplyResolution,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
kCCBSizeTypeAbsolute,
|
||||
kCCBSizeTypePercent,
|
||||
kCCBSizeTypeRelativeContainer,
|
||||
kCCBSizeTypeHorizontalPercent,
|
||||
kCCBSizeTypeVerticalPercent,
|
||||
kCCBSizeTypeMultiplyResolution,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
kCCBScaleTypeAbsolute,
|
||||
kCCBScaleTypeMultiplyResolution
|
||||
};
|
||||
|
||||
#define CCB_VERSION 5
|
||||
|
||||
NS_CC_EXT_BEGIN
|
||||
|
||||
|
@ -142,7 +40,7 @@ NS_CC_EXT_BEGIN
|
|||
class CCBFile : public Node
|
||||
{
|
||||
private:
|
||||
Node *mCCBFileNode;
|
||||
Node *_CCBFileNode;
|
||||
|
||||
public:
|
||||
CCBFile();
|
||||
|
@ -167,47 +65,91 @@ class CCBKeyframe;
|
|||
*/
|
||||
class CCBReader : public Object
|
||||
{
|
||||
private:
|
||||
|
||||
Data *mData;
|
||||
unsigned char *mBytes;
|
||||
int mCurrentByte;
|
||||
int mCurrentBit;
|
||||
|
||||
std::vector<std::string> mStringCache;
|
||||
std::set<std::string> mLoadedSpriteSheets;
|
||||
|
||||
Object *mOwner;
|
||||
|
||||
CCBAnimationManager *mActionManager; //retain
|
||||
Dictionary* mActionManagers;
|
||||
|
||||
std::set<std::string> *mAnimatedProps;
|
||||
|
||||
NodeLoaderLibrary *mNodeLoaderLibrary;
|
||||
NodeLoaderListener *mNodeLoaderListener;
|
||||
CCBMemberVariableAssigner *mCCBMemberVariableAssigner;
|
||||
CCBSelectorResolver *mCCBSelectorResolver;
|
||||
|
||||
std::vector<std::string> mOwnerOutletNames;
|
||||
Array* mOwnerOutletNodes;
|
||||
Array* mNodesWithAnimationManagers;
|
||||
Array* mAnimationManagersForNodes;
|
||||
|
||||
std::vector<std::string> mOwnerCallbackNames;
|
||||
Array* mOwnerCallbackNodes;
|
||||
std::string mCCBRootPath;
|
||||
bool hasScriptingOwner;
|
||||
bool init();
|
||||
public:
|
||||
enum class PropertyType {
|
||||
POSITION = 0,
|
||||
SIZE,
|
||||
POINT,
|
||||
POINT_LOCK,
|
||||
SCALE_LOCK,
|
||||
DEGREES,
|
||||
INTEGER,
|
||||
FLOAT,
|
||||
FLOAT_VAR,
|
||||
CHECK,
|
||||
SPRITEFRAME,
|
||||
TEXTURE,
|
||||
BYTE,
|
||||
COLOR3,
|
||||
COLOR4F_VAR,
|
||||
FLIP,
|
||||
BLEND_MODE,
|
||||
FNT_FILE,
|
||||
TEXT,
|
||||
FONT_TTF,
|
||||
INTEGER_LABELED,
|
||||
BLOCK,
|
||||
ANIMATION,
|
||||
CCB_FILE,
|
||||
STRING,
|
||||
BLOCK_CONTROL,
|
||||
FLOAT_SCALE,
|
||||
FLOAT_XY
|
||||
};
|
||||
|
||||
enum class FloatType {
|
||||
_0 = 0,
|
||||
_1,
|
||||
MINUS1,
|
||||
_05,
|
||||
INTEGER,
|
||||
FULL
|
||||
};
|
||||
|
||||
enum class PlatformType {
|
||||
ALL = 0,
|
||||
IOS,
|
||||
MAC
|
||||
};
|
||||
|
||||
enum class TargetType {
|
||||
NONE = 0,
|
||||
DOCUMENT_ROOT = 1,
|
||||
OWNER = 2,
|
||||
};
|
||||
|
||||
enum class PositionType
|
||||
{
|
||||
RELATIVE_BOTTOM_LEFT,
|
||||
RELATIVE_TOP_LEFT,
|
||||
RELATIVE_TOP_RIGHT,
|
||||
RELATIVE_BOTTOM_RIGHT,
|
||||
PERCENT,
|
||||
MULTIPLY_RESOLUTION,
|
||||
};
|
||||
|
||||
enum class SizeType
|
||||
{
|
||||
ABSOLUTE,
|
||||
PERCENT,
|
||||
RELATIVE_CONTAINER,
|
||||
HORIZONTAL_PERCENT,
|
||||
VERTICAL_PERCENT,
|
||||
MULTIPLY_RESOLUTION,
|
||||
};
|
||||
|
||||
enum class ScaleType
|
||||
{
|
||||
ABSOLUTE,
|
||||
MULTIPLY_RESOLUTION
|
||||
};
|
||||
|
||||
bool jsControlled;
|
||||
CCBReader(NodeLoaderLibrary *pNodeLoaderLibrary, CCBMemberVariableAssigner *pCCBMemberVariableAssigner = NULL, CCBSelectorResolver *pCCBSelectorResolver = NULL, NodeLoaderListener *pNodeLoaderListener = NULL);
|
||||
CCBReader(CCBReader *pCCBReader);
|
||||
CCBReader(CCBReader *ccbReader);
|
||||
virtual ~CCBReader();
|
||||
CCBReader();
|
||||
|
||||
void setCCBRootPath(const char* pCCBRootPath);
|
||||
void setCCBRootPath(const char* ccbRootPath);
|
||||
const std::string& getCCBRootPath() const;
|
||||
|
||||
Node* readNodeGraphFromFile(const char *pCCBFileName);
|
||||
|
@ -279,7 +221,7 @@ public:
|
|||
private:
|
||||
void cleanUpNodeGraph(Node *pNode);
|
||||
bool readSequences();
|
||||
CCBKeyframe* readKeyframe(int type);
|
||||
CCBKeyframe* readKeyframe(PropertyType type);
|
||||
|
||||
bool readHeader();
|
||||
bool readStringCache();
|
||||
|
@ -291,6 +233,41 @@ private:
|
|||
void alignBits();
|
||||
|
||||
friend class NodeLoader;
|
||||
|
||||
private:
|
||||
Data *_data;
|
||||
unsigned char *_bytes;
|
||||
int _currentByte;
|
||||
int _currentBit;
|
||||
|
||||
std::vector<std::string> _stringCache;
|
||||
std::set<std::string> _loadedSpriteSheets;
|
||||
|
||||
Object *_owner;
|
||||
|
||||
CCBAnimationManager *_actionManager; //retain
|
||||
Dictionary* _actionManagers;
|
||||
|
||||
std::set<std::string> *_animatedProps;
|
||||
|
||||
NodeLoaderLibrary *_nodeLoaderLibrary;
|
||||
NodeLoaderListener *_nodeLoaderListener;
|
||||
CCBMemberVariableAssigner *_CCBMemberVariableAssigner;
|
||||
CCBSelectorResolver *_CCBSelectorResolver;
|
||||
|
||||
std::vector<std::string> _ownerOutletNames;
|
||||
Array* _ownerOutletNodes;
|
||||
Array* _nodesWithAnimationManagers;
|
||||
Array* _animationManagersForNodes;
|
||||
|
||||
std::vector<std::string> _ownerCallbackNames;
|
||||
Array* _ownerCallbackNodes;
|
||||
std::string _CCBRootPath;
|
||||
|
||||
bool _jsControlled;
|
||||
|
||||
bool _hasScriptingOwner;
|
||||
bool init();
|
||||
};
|
||||
|
||||
// end of effects group
|
||||
|
|
|
@ -25,7 +25,7 @@ class CCBSelectorResolver {
|
|||
virtual ~CCBSelectorResolver() {};
|
||||
virtual SEL_MenuHandler onResolveCCBCCMenuItemSelector(Object * pTarget, const char* pSelectorName) = 0;
|
||||
virtual SEL_CallFuncN onResolveCCBCCCallFuncSelector(Object * pTarget, const char* pSelectorName) { return NULL; };
|
||||
virtual SEL_CCControlHandler onResolveCCBCCControlSelector(Object * pTarget, const char* pSelectorName) = 0;
|
||||
virtual Control::Handler onResolveCCBCCControlSelector(Object * pTarget, const char* pSelectorName) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -7,8 +7,8 @@ using namespace std;
|
|||
NS_CC_EXT_BEGIN
|
||||
|
||||
CCBSequence::CCBSequence()
|
||||
: mDuration(0.0f)
|
||||
, mName("")
|
||||
: _duration(0.0f)
|
||||
, _name("")
|
||||
, mSequenceId(0)
|
||||
, mChainedSequenceId(0)
|
||||
, mCallbackChannel(NULL)
|
||||
|
@ -22,22 +22,22 @@ CCBSequence::~CCBSequence() {
|
|||
|
||||
float CCBSequence::getDuration()
|
||||
{
|
||||
return mDuration;
|
||||
return _duration;
|
||||
}
|
||||
|
||||
void CCBSequence::setDuration(float fDuration)
|
||||
{
|
||||
mDuration = fDuration;
|
||||
_duration = fDuration;
|
||||
}
|
||||
|
||||
const char* CCBSequence::getName()
|
||||
{
|
||||
return mName.c_str();
|
||||
return _name.c_str();
|
||||
}
|
||||
|
||||
void CCBSequence::setName(const char *pName)
|
||||
{
|
||||
mName = pName;
|
||||
_name = pName;
|
||||
}
|
||||
|
||||
int CCBSequence::getSequenceId()
|
||||
|
|
|
@ -10,14 +10,6 @@ NS_CC_EXT_BEGIN
|
|||
|
||||
class CCBSequence : public Object
|
||||
{
|
||||
private:
|
||||
float mDuration;
|
||||
std::string mName;
|
||||
int mSequenceId;
|
||||
int mChainedSequenceId;
|
||||
CCBSequenceProperty* mCallbackChannel;
|
||||
CCBSequenceProperty* mSoundChannel;
|
||||
|
||||
public:
|
||||
CCBSequence();
|
||||
~CCBSequence();
|
||||
|
@ -38,6 +30,14 @@ public:
|
|||
|
||||
int getChainedSequenceId();
|
||||
void setChainedSequenceId(int nChainedSequenceId);
|
||||
|
||||
private:
|
||||
float _duration;
|
||||
std::string _name;
|
||||
int mSequenceId;
|
||||
int mChainedSequenceId;
|
||||
CCBSequenceProperty* mCallbackChannel;
|
||||
CCBSequenceProperty* mSoundChannel;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -6,47 +6,47 @@ using namespace std;
|
|||
NS_CC_EXT_BEGIN
|
||||
|
||||
CCBSequenceProperty::CCBSequenceProperty()
|
||||
: mName("")
|
||||
, mType(0)
|
||||
: _name("")
|
||||
, _type(0)
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
bool CCBSequenceProperty::init()
|
||||
{
|
||||
mKeyframes = new Array();
|
||||
_keyframes = new Array();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
CCBSequenceProperty::~CCBSequenceProperty()
|
||||
{
|
||||
CC_SAFE_RELEASE_NULL(mKeyframes);
|
||||
CC_SAFE_RELEASE_NULL(_keyframes);
|
||||
}
|
||||
|
||||
const char* CCBSequenceProperty::getName()
|
||||
{
|
||||
return mName.c_str();
|
||||
return _name.c_str();
|
||||
}
|
||||
|
||||
void CCBSequenceProperty::setName(const char *pName)
|
||||
{
|
||||
mName = pName;
|
||||
_name = pName;
|
||||
}
|
||||
|
||||
int CCBSequenceProperty::getType()
|
||||
{
|
||||
return mType;
|
||||
return _type;
|
||||
}
|
||||
|
||||
void CCBSequenceProperty::setType(int nType)
|
||||
void CCBSequenceProperty::setType(int type)
|
||||
{
|
||||
mType = nType;
|
||||
_type = type;
|
||||
}
|
||||
|
||||
Array* CCBSequenceProperty::getKeyframes()
|
||||
{
|
||||
return mKeyframes;
|
||||
return _keyframes;
|
||||
}
|
||||
|
||||
NS_CC_EXT_END
|
||||
|
|
|
@ -9,11 +9,6 @@ NS_CC_EXT_BEGIN
|
|||
|
||||
class CCBSequenceProperty : public Object
|
||||
{
|
||||
private:
|
||||
std::string mName;
|
||||
int mType;
|
||||
Array *mKeyframes;
|
||||
|
||||
public:
|
||||
CCBSequenceProperty();
|
||||
~CCBSequenceProperty();
|
||||
|
@ -24,9 +19,14 @@ public:
|
|||
void setName(const char* pName);
|
||||
|
||||
int getType();
|
||||
void setType(int nType);
|
||||
void setType(int type);
|
||||
|
||||
Array* getKeyframes();
|
||||
|
||||
private:
|
||||
std::string _name;
|
||||
int _type;
|
||||
Array *_keyframes;
|
||||
};
|
||||
|
||||
NS_CC_EXT_END
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#include "CCBValue.h"
|
||||
|
||||
using namespace cocos2d;
|
||||
|
||||
NS_CC_EXT_BEGIN
|
||||
|
||||
// Implementation of Color3BWapper
|
||||
|
@ -14,10 +12,10 @@ Color3BWapper* Color3BWapper::create(const Color3B& color)
|
|||
ret->color.r = color.r;
|
||||
ret->color.g = color.g;
|
||||
ret->color.b = color.b;
|
||||
|
||||
|
||||
ret->autorelease();
|
||||
}
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -33,11 +31,11 @@ CCBValue* CCBValue::create(int nValue)
|
|||
CCBValue *ret = new CCBValue();
|
||||
if (ret)
|
||||
{
|
||||
ret->mValue.nValue = nValue;
|
||||
ret->mType = kIntValue;
|
||||
ret->_value.intValue = nValue;
|
||||
ret->_type = Type::INT;
|
||||
ret->autorelease();
|
||||
}
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -46,11 +44,11 @@ CCBValue* CCBValue::create(float fValue)
|
|||
CCBValue *ret = new CCBValue();
|
||||
if (ret)
|
||||
{
|
||||
ret->mValue.fValue = fValue;
|
||||
ret->mType = kFloatValue;
|
||||
ret->_value.floatValue = fValue;
|
||||
ret->_type = Type::FLOAT;
|
||||
ret->autorelease();
|
||||
}
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -59,11 +57,11 @@ CCBValue* CCBValue::create(bool vValue)
|
|||
CCBValue *ret = new CCBValue();
|
||||
if (ret)
|
||||
{
|
||||
ret->mValue.nValue = vValue ? 1 : 0;
|
||||
ret->mType = kBoolValue;
|
||||
ret->_value.intValue = vValue ? 1 : 0;
|
||||
ret->_type = Type::BOOL;
|
||||
ret->autorelease();
|
||||
}
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -72,11 +70,11 @@ CCBValue* CCBValue::create(unsigned char byte)
|
|||
CCBValue *ret = new CCBValue();
|
||||
if (ret)
|
||||
{
|
||||
ret->mValue.nValue = byte;
|
||||
ret->mType = kUnsignedCharValue;
|
||||
ret->_value.intValue = byte;
|
||||
ret->_type = Type::UNSIGNED_CHAR;
|
||||
ret->autorelease();
|
||||
}
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -85,11 +83,11 @@ CCBValue* CCBValue::create(const char *pStringValue)
|
|||
CCBValue *ret = new CCBValue();
|
||||
if (ret)
|
||||
{
|
||||
ret->_value = pStringValue;
|
||||
ret->mType = kStringValue;
|
||||
ret->_strValue = pStringValue;
|
||||
ret->_type = Type::STRING;
|
||||
ret->autorelease();
|
||||
}
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -100,59 +98,60 @@ CCBValue* CCBValue::create(Array *pArrValue)
|
|||
if (ret)
|
||||
{
|
||||
ret->_arrValue = pArrValue;
|
||||
ret->mType = kArrayValue;
|
||||
ret->_type = Type::ARRAY;
|
||||
ret->autorelease();
|
||||
}
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int CCBValue::getIntValue()
|
||||
{
|
||||
assert(mType == kIntValue);
|
||||
|
||||
return mValue.nValue;
|
||||
CCASSERT(_type == Type::INT, "The type of CCBValue isn't integer.");
|
||||
|
||||
return _value.intValue;
|
||||
}
|
||||
|
||||
float CCBValue::getFloatValue()
|
||||
{
|
||||
assert(mType == kFloatValue);
|
||||
|
||||
return mValue.fValue;
|
||||
CCASSERT(_type == Type::FLOAT, "The type of CCBValue isn't float.");
|
||||
|
||||
return _value.floatValue;
|
||||
}
|
||||
|
||||
bool CCBValue::getBoolValue()
|
||||
{
|
||||
assert(mType == kBoolValue);
|
||||
|
||||
return mValue.nValue == 1 ? true : false;
|
||||
CCASSERT(_type == Type::BOOL, "The type of CCBValue isn't boolean.");
|
||||
|
||||
return _value.intValue == 1 ? true : false;
|
||||
}
|
||||
|
||||
unsigned char CCBValue::getByteValue()
|
||||
{
|
||||
assert(mType == kUnsignedCharValue);
|
||||
|
||||
return (unsigned char)(mValue.nValue);
|
||||
CCASSERT(_type == Type::UNSIGNED_CHAR, "The type of CCBValue isn't unsigned char.");
|
||||
|
||||
return (unsigned char)(_value.intValue);
|
||||
}
|
||||
|
||||
Array* CCBValue::getArrayValue() {
|
||||
assert(mType == kArrayValue);
|
||||
|
||||
Array* CCBValue::getArrayValue()
|
||||
{
|
||||
CCASSERT(_type == Type::ARRAY, "The type of CCBValue isn't array.");
|
||||
|
||||
return _arrValue;
|
||||
}
|
||||
|
||||
|
||||
const char* CCBValue::getStringValue()
|
||||
{
|
||||
assert(mType == kStringValue);
|
||||
|
||||
return _value.c_str();
|
||||
CCASSERT(_type == Type::STRING, "The type of CCBValue isn't string.");
|
||||
|
||||
return _strValue.c_str();
|
||||
}
|
||||
|
||||
int CCBValue::getType()
|
||||
CCBValue::Type CCBValue::getType()
|
||||
{
|
||||
return mType;
|
||||
return _type;
|
||||
}
|
||||
|
||||
NS_CC_EXT_END
|
||||
|
|
|
@ -12,39 +12,31 @@ NS_CC_EXT_BEGIN
|
|||
|
||||
class Color3BWapper : public Object
|
||||
{
|
||||
private:
|
||||
Color3B color;
|
||||
|
||||
public:
|
||||
static Color3BWapper* create(const Color3B& color);
|
||||
|
||||
const Color3B& getColor() const;
|
||||
|
||||
private:
|
||||
Color3B color;
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
kIntValue,
|
||||
kFloatValue,
|
||||
kBoolValue,
|
||||
kUnsignedCharValue,
|
||||
kStringValue,
|
||||
kArrayValue
|
||||
};
|
||||
|
||||
|
||||
class CCBValue : public Object
|
||||
{
|
||||
private:
|
||||
union
|
||||
{
|
||||
int nValue;
|
||||
float fValue;
|
||||
} mValue;
|
||||
|
||||
std::string _value;
|
||||
Array* _arrValue;
|
||||
int mType;
|
||||
|
||||
public:
|
||||
|
||||
enum class Type
|
||||
{
|
||||
INT,
|
||||
FLOAT,
|
||||
BOOL,
|
||||
UNSIGNED_CHAR,
|
||||
STRING,
|
||||
ARRAY
|
||||
};
|
||||
|
||||
static CCBValue* create(int nValue);
|
||||
static CCBValue* create(bool bValue);
|
||||
static CCBValue* create(float fValue);
|
||||
|
@ -60,7 +52,18 @@ public:
|
|||
const char* getStringValue();
|
||||
Array *getArrayValue();
|
||||
|
||||
int getType();
|
||||
Type getType();
|
||||
|
||||
private:
|
||||
union
|
||||
{
|
||||
int intValue;
|
||||
float floatValue;
|
||||
} _value;
|
||||
|
||||
std::string _strValue;
|
||||
Array* _arrValue;
|
||||
Type _type;
|
||||
};
|
||||
|
||||
NS_CC_EXT_END
|
||||
|
|
|
@ -22,93 +22,93 @@ NS_CC_EXT_BEGIN;
|
|||
#define PROPERTY_BACKGROUNDSPRITEFRAME_HIGHLIGHTED "backgroundSpriteFrame|2"
|
||||
#define PROPERTY_BACKGROUNDSPRITEFRAME_DISABLED "backgroundSpriteFrame|3"
|
||||
|
||||
void ControlButtonLoader::onHandlePropTypeCheck(Node * pNode, Node * pParent, const char * pPropertyName, bool pCheck, CCBReader * pCCBReader) {
|
||||
void ControlButtonLoader::onHandlePropTypeCheck(Node * pNode, Node * pParent, const char * pPropertyName, bool pCheck, CCBReader * ccbReader) {
|
||||
if(strcmp(pPropertyName, PROPERTY_ZOOMONTOUCHDOWN) == 0) {
|
||||
((ControlButton *)pNode)->setZoomOnTouchDown(pCheck);
|
||||
} else {
|
||||
ControlLoader::onHandlePropTypeCheck(pNode, pParent, pPropertyName, pCheck, pCCBReader);
|
||||
ControlLoader::onHandlePropTypeCheck(pNode, pParent, pPropertyName, pCheck, ccbReader);
|
||||
}
|
||||
}
|
||||
|
||||
void ControlButtonLoader::onHandlePropTypeString(Node * pNode, Node * pParent, const char * pPropertyName, const char * pString, CCBReader * pCCBReader) {
|
||||
void ControlButtonLoader::onHandlePropTypeString(Node * pNode, Node * pParent, const char * pPropertyName, const char * pString, CCBReader * ccbReader) {
|
||||
if(strcmp(pPropertyName, PROPERTY_TITLE_NORMAL) == 0) {
|
||||
((ControlButton *)pNode)->setTitleForState(String::create(pString), ControlStateNormal);
|
||||
((ControlButton *)pNode)->setTitleForState(String::create(pString), Control::State::NORMAL);
|
||||
} else if(strcmp(pPropertyName, PROPERTY_TITLE_HIGHLIGHTED) == 0) {
|
||||
((ControlButton *)pNode)->setTitleForState(String::create(pString), ControlStateHighlighted);
|
||||
((ControlButton *)pNode)->setTitleForState(String::create(pString), Control::State::HIGH_LIGHTED);
|
||||
} else if(strcmp(pPropertyName, PROPERTY_TITLE_DISABLED) == 0) {
|
||||
((ControlButton *)pNode)->setTitleForState(String::create(pString), ControlStateDisabled);
|
||||
((ControlButton *)pNode)->setTitleForState(String::create(pString), Control::State::DISABLED);
|
||||
} else {
|
||||
ControlLoader::onHandlePropTypeString(pNode, pParent, pPropertyName, pString, pCCBReader);
|
||||
ControlLoader::onHandlePropTypeString(pNode, pParent, pPropertyName, pString, ccbReader);
|
||||
}
|
||||
}
|
||||
|
||||
void ControlButtonLoader::onHandlePropTypeFontTTF(Node * pNode, Node * pParent, const char * pPropertyName, const char * pFontTTF, CCBReader * pCCBReader) {
|
||||
void ControlButtonLoader::onHandlePropTypeFontTTF(Node * pNode, Node * pParent, const char * pPropertyName, const char * pFontTTF, CCBReader * ccbReader) {
|
||||
if(strcmp(pPropertyName, PROPERTY_TITLETTF_NORMAL) == 0) {
|
||||
((ControlButton *)pNode)->setTitleTTFForState(pFontTTF, ControlStateNormal);
|
||||
((ControlButton *)pNode)->setTitleTTFForState(pFontTTF, Control::State::NORMAL);
|
||||
} else if(strcmp(pPropertyName, PROPERTY_TITLETTF_HIGHLIGHTED) == 0) {
|
||||
((ControlButton *)pNode)->setTitleTTFForState(pFontTTF, ControlStateHighlighted);
|
||||
((ControlButton *)pNode)->setTitleTTFForState(pFontTTF, Control::State::HIGH_LIGHTED);
|
||||
} else if(strcmp(pPropertyName, PROPERTY_TITLETTF_DISABLED) == 0) {
|
||||
((ControlButton *)pNode)->setTitleTTFForState(pFontTTF, ControlStateDisabled);
|
||||
((ControlButton *)pNode)->setTitleTTFForState(pFontTTF, Control::State::DISABLED);
|
||||
} else {
|
||||
ControlLoader::onHandlePropTypeFontTTF(pNode, pParent, pPropertyName, pFontTTF, pCCBReader);
|
||||
ControlLoader::onHandlePropTypeFontTTF(pNode, pParent, pPropertyName, pFontTTF, ccbReader);
|
||||
}
|
||||
}
|
||||
|
||||
void ControlButtonLoader::onHandlePropTypeFloatScale(Node * pNode, Node * pParent, const char * pPropertyName, float pFloatScale, CCBReader * pCCBReader) {
|
||||
void ControlButtonLoader::onHandlePropTypeFloatScale(Node * pNode, Node * pParent, const char * pPropertyName, float pFloatScale, CCBReader * ccbReader) {
|
||||
if(strcmp(pPropertyName, PROPERTY_TITLETTFSIZE_NORMAL) == 0) {
|
||||
((ControlButton *)pNode)->setTitleTTFSizeForState(pFloatScale, ControlStateNormal);
|
||||
((ControlButton *)pNode)->setTitleTTFSizeForState(pFloatScale, Control::State::NORMAL);
|
||||
} else if(strcmp(pPropertyName, PROPERTY_TITLETTFSIZE_HIGHLIGHTED) == 0) {
|
||||
((ControlButton *)pNode)->setTitleTTFSizeForState(pFloatScale, ControlStateHighlighted);
|
||||
((ControlButton *)pNode)->setTitleTTFSizeForState(pFloatScale, Control::State::HIGH_LIGHTED);
|
||||
} else if(strcmp(pPropertyName, PROPERTY_TITLETTFSIZE_DISABLED) == 0) {
|
||||
((ControlButton *)pNode)->setTitleTTFSizeForState(pFloatScale, ControlStateDisabled);
|
||||
((ControlButton *)pNode)->setTitleTTFSizeForState(pFloatScale, Control::State::DISABLED);
|
||||
} else {
|
||||
ControlLoader::onHandlePropTypeFloatScale(pNode, pParent, pPropertyName, pFloatScale, pCCBReader);
|
||||
ControlLoader::onHandlePropTypeFloatScale(pNode, pParent, pPropertyName, pFloatScale, ccbReader);
|
||||
}
|
||||
}
|
||||
|
||||
void ControlButtonLoader::onHandlePropTypePoint(Node * pNode, Node * pParent, const char * pPropertyName, Point pPoint, CCBReader * pCCBReader) {
|
||||
void ControlButtonLoader::onHandlePropTypePoint(Node * pNode, Node * pParent, const char * pPropertyName, Point pPoint, CCBReader * ccbReader) {
|
||||
if(strcmp(pPropertyName, PROPERTY_LABELANCHORPOINT) == 0) {
|
||||
((ControlButton *)pNode)->setLabelAnchorPoint(pPoint);
|
||||
} else {
|
||||
ControlLoader::onHandlePropTypePoint(pNode, pParent, pPropertyName, pPoint, pCCBReader);
|
||||
ControlLoader::onHandlePropTypePoint(pNode, pParent, pPropertyName, pPoint, ccbReader);
|
||||
}
|
||||
}
|
||||
|
||||
void ControlButtonLoader::onHandlePropTypeSize(Node * pNode, Node * pParent, const char * pPropertyName, Size pSize, CCBReader * pCCBReader) {
|
||||
void ControlButtonLoader::onHandlePropTypeSize(Node * pNode, Node * pParent, const char * pPropertyName, Size pSize, CCBReader * ccbReader) {
|
||||
if(strcmp(pPropertyName, PROPERTY_PREFEREDSIZE) == 0) {
|
||||
((ControlButton *)pNode)->setPreferredSize(pSize);
|
||||
} else {
|
||||
ControlLoader::onHandlePropTypeSize(pNode, pParent, pPropertyName, pSize, pCCBReader);
|
||||
ControlLoader::onHandlePropTypeSize(pNode, pParent, pPropertyName, pSize, ccbReader);
|
||||
}
|
||||
}
|
||||
|
||||
void ControlButtonLoader::onHandlePropTypeSpriteFrame(Node * pNode, Node * pParent, const char * pPropertyName, SpriteFrame * pSpriteFrame, CCBReader * pCCBReader) {
|
||||
void ControlButtonLoader::onHandlePropTypeSpriteFrame(Node * pNode, Node * pParent, const char * pPropertyName, SpriteFrame * pSpriteFrame, CCBReader * ccbReader) {
|
||||
if(strcmp(pPropertyName, PROPERTY_BACKGROUNDSPRITEFRAME_NORMAL) == 0) {
|
||||
if(pSpriteFrame != NULL) {
|
||||
((ControlButton *)pNode)->setBackgroundSpriteFrameForState(pSpriteFrame, ControlStateNormal);
|
||||
((ControlButton *)pNode)->setBackgroundSpriteFrameForState(pSpriteFrame, Control::State::NORMAL);
|
||||
}
|
||||
} else if(strcmp(pPropertyName, PROPERTY_BACKGROUNDSPRITEFRAME_HIGHLIGHTED) == 0) {
|
||||
if(pSpriteFrame != NULL) {
|
||||
((ControlButton *)pNode)->setBackgroundSpriteFrameForState(pSpriteFrame, ControlStateHighlighted);
|
||||
((ControlButton *)pNode)->setBackgroundSpriteFrameForState(pSpriteFrame, Control::State::HIGH_LIGHTED);
|
||||
}
|
||||
} else if(strcmp(pPropertyName, PROPERTY_BACKGROUNDSPRITEFRAME_DISABLED) == 0) {
|
||||
if(pSpriteFrame != NULL) {
|
||||
((ControlButton *)pNode)->setBackgroundSpriteFrameForState(pSpriteFrame, ControlStateDisabled);
|
||||
((ControlButton *)pNode)->setBackgroundSpriteFrameForState(pSpriteFrame, Control::State::DISABLED);
|
||||
}
|
||||
} else {
|
||||
ControlLoader::onHandlePropTypeSpriteFrame(pNode, pParent, pPropertyName, pSpriteFrame, pCCBReader);
|
||||
ControlLoader::onHandlePropTypeSpriteFrame(pNode, pParent, pPropertyName, pSpriteFrame, ccbReader);
|
||||
}
|
||||
}
|
||||
|
||||
void ControlButtonLoader::onHandlePropTypeColor3(Node * pNode, Node * pParent, const char * pPropertyName, Color3B pColor3B, CCBReader * pCCBReader) {
|
||||
void ControlButtonLoader::onHandlePropTypeColor3(Node * pNode, Node * pParent, const char * pPropertyName, Color3B pColor3B, CCBReader * ccbReader) {
|
||||
if(strcmp(pPropertyName, PROPERTY_TITLECOLOR_NORMAL) == 0) {
|
||||
((ControlButton *)pNode)->setTitleColorForState(pColor3B, ControlStateNormal);
|
||||
((ControlButton *)pNode)->setTitleColorForState(pColor3B, Control::State::NORMAL);
|
||||
} else if(strcmp(pPropertyName, PROPERTY_TITLECOLOR_HIGHLIGHTED) == 0) {
|
||||
((ControlButton *)pNode)->setTitleColorForState(pColor3B, ControlStateHighlighted);
|
||||
((ControlButton *)pNode)->setTitleColorForState(pColor3B, Control::State::HIGH_LIGHTED);
|
||||
} else if(strcmp(pPropertyName, PROPERTY_TITLECOLOR_DISABLED) == 0) {
|
||||
((ControlButton *)pNode)->setTitleColorForState(pColor3B, ControlStateDisabled);
|
||||
((ControlButton *)pNode)->setTitleColorForState(pColor3B, Control::State::DISABLED);
|
||||
} else {
|
||||
ControlLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pColor3B, pCCBReader);
|
||||
ControlLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pColor3B, ccbReader);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,14 +17,14 @@ class ControlButtonLoader : public ControlLoader {
|
|||
protected:
|
||||
CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(ControlButton);
|
||||
|
||||
virtual void onHandlePropTypeCheck(Node * pNode, Node * pParent, const char * pPropertyName, bool pCheck, CCBReader * pCCBReader);
|
||||
virtual void onHandlePropTypeString(Node * pNode, Node * pParent, const char * pPropertyName, const char * pString, CCBReader * pCCBReader);
|
||||
virtual void onHandlePropTypeFontTTF(Node * pNode, Node * pParent, const char * pPropertyName, const char * pFontTTF, CCBReader * pCCBReader);
|
||||
virtual void onHandlePropTypeFloatScale(Node * pNode, Node * pParent, const char * pPropertyName, float pFloatScale, CCBReader * pCCBReader);
|
||||
virtual void onHandlePropTypePoint(Node * pNode, Node * pParent, const char * pPropertyName, Point pPoint, CCBReader * pCCBReader);
|
||||
virtual void onHandlePropTypeSize(Node * pNode, Node * pParent, const char * pPropertyName, Size pSize, CCBReader * pCCBReader);
|
||||
virtual void onHandlePropTypeSpriteFrame(Node * pNode, Node * pParent, const char * pPropertyName, SpriteFrame * pSpriteFrame, CCBReader * pCCBReader);
|
||||
virtual void onHandlePropTypeColor3(Node * pNode, Node * pParent, const char * pPropertyName, Color3B pColor3B, CCBReader * pCCBReader);
|
||||
virtual void onHandlePropTypeCheck(Node * pNode, Node * pParent, const char * pPropertyName, bool pCheck, CCBReader * ccbReader);
|
||||
virtual void onHandlePropTypeString(Node * pNode, Node * pParent, const char * pPropertyName, const char * pString, CCBReader * ccbReader);
|
||||
virtual void onHandlePropTypeFontTTF(Node * pNode, Node * pParent, const char * pPropertyName, const char * pFontTTF, CCBReader * ccbReader);
|
||||
virtual void onHandlePropTypeFloatScale(Node * pNode, Node * pParent, const char * pPropertyName, float pFloatScale, CCBReader * ccbReader);
|
||||
virtual void onHandlePropTypePoint(Node * pNode, Node * pParent, const char * pPropertyName, Point pPoint, CCBReader * ccbReader);
|
||||
virtual void onHandlePropTypeSize(Node * pNode, Node * pParent, const char * pPropertyName, Size pSize, CCBReader * ccbReader);
|
||||
virtual void onHandlePropTypeSpriteFrame(Node * pNode, Node * pParent, const char * pPropertyName, SpriteFrame * pSpriteFrame, CCBReader * ccbReader);
|
||||
virtual void onHandlePropTypeColor3(Node * pNode, Node * pParent, const char * pPropertyName, Color3B pColor3B, CCBReader * ccbReader);
|
||||
};
|
||||
|
||||
NS_CC_EXT_END
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue