mirror of https://github.com/axmolengine/axmol.git
Merge branch 'develop' of https://github.com/cocos2d/cocos2d-x into developCCS
This commit is contained in:
commit
4536798842
1
AUTHORS
1
AUTHORS
|
@ -628,6 +628,7 @@ Developers:
|
|||
HoGarfield (garfield_ho)
|
||||
Fixed a bug that CCBReader can't play sequence automatically in JSB.
|
||||
Could not set next animation in CCBAnimationCompleted callback.
|
||||
Fixed missing to add JSAutoCompartment when invoking JS functions from C++.
|
||||
|
||||
lite3
|
||||
Fixed a bug that Node's anchor point was changed after being added to ScrollView.
|
||||
|
|
|
@ -10,18 +10,20 @@ cocos2d-x-3.0alpha1 @??? 2013
|
|||
[FIX] Could not set next animation in CCBAnimationCompleted callback.
|
||||
[FIX] The Node's anchor point was changed after being added to ScrollView.
|
||||
[FIX] Refactored and improved EventDispatcher.
|
||||
[NEW] Added Mouse Support For Desktop Platforms.
|
||||
[FIX] EventListeners can't be removed sometimes.
|
||||
[FIX] When parsing XML using TinyXML, the data size has to be specified.
|
||||
[FIX] Parameter type: const char* -> const string&
|
||||
[FIX] Armature: many bug fixed, add more samples, add function to skip some frames when playing animation
|
||||
[NEW] Arm64 support.
|
||||
[NEW] Added Mouse Support For Desktop Platforms.
|
||||
[Android]
|
||||
[FIX] Added EGL_RENDERABLE_TYPE to OpenGL attributes
|
||||
[NEW] Added Cocos2dxHelper.runOnGLThread(Runnable) again
|
||||
[FIX] Fixed application will crash when pause and resume.
|
||||
[FIX] Clear NoSuchMethodError Exception when JniHelper fails to find method id
|
||||
[NEW] Added xlargeScreens="true" to supports-screens
|
||||
[NEW] Added build/android-build.py to build all Android samples, and remove all build_native.sh/cmd
|
||||
[NEW] Added build_native.py to build template projects, and remove build_native.sh/cmd
|
||||
[NEW] Added Cocos2dxHelper.runOnGLThread(Runnable) again
|
||||
[Mac]
|
||||
[FIX] Removed unused CCLOG() from GL initialization
|
||||
[iOS]
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
cmake_minimum_required(VERSION 2.6)
|
||||
project (Cocos2dxSamples)
|
||||
project (Cocos2dx)
|
||||
|
||||
# The version number
|
||||
set(Cocos2dxSamples_VERSION_MAJOR 3)
|
||||
|
@ -7,14 +7,45 @@ set(Cocos2dxSamples_VERSION_MINOR 0)
|
|||
|
||||
include(build/BuildHelpers.CMakeLists.txt)
|
||||
|
||||
set(CMAKE_BUILE_TYPE DEBUG)
|
||||
option(USE_CHIPMUNK "Use chipmunk for physics library" ON)
|
||||
option(USE_BOX2D "Use box2d for physics library" OFF)
|
||||
option(DEBUG_MODE "Debug or release?" ON)
|
||||
option(BUILD_LIBS_LUA "Build lua libraries" ON)
|
||||
option(BUILD_GUI "Build GUI library" ON)
|
||||
option(BUILD_NETWORK "Build network library" ON)
|
||||
option(BUILD_EXTENSIONS "Build extension library" ON)
|
||||
option(BUILD_EDITOR_SPINE "Build editor support for spine" ON)
|
||||
option(BUILD_EDITOR_COCOSTUDIO "Build editor support for cocostudio" ON)
|
||||
option(BUILD_EDITOR_COCOSBUILDER "Build editor support for cocosbuilder" ON)
|
||||
|
||||
|
||||
option(BUILD_HelloCpp "Only build HelloCpp sample" ON)
|
||||
option(BUILD_TestCpp "Only build TestCpp sample" ON)
|
||||
option(BUILD_HelloLua "Only build HelloLua sample" ON)
|
||||
option(BUILD_TestLua "Only build TestLua sample" ON)
|
||||
|
||||
|
||||
if(DEBUG_MODE)
|
||||
set(CMAKE_BUILD_TYPE DEBUG)
|
||||
else(DEBUG_MODE)
|
||||
set(CMAKE_BUILD_TYPE RELEASE)
|
||||
endif(DEBUG_MODE)
|
||||
|
||||
set(CMAKE_C_FLAGS_DEBUG "-g -Wall -DCOCOS2D_DEBUG=1")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
|
||||
|
||||
set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} "-std=c99")
|
||||
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-std=c++11")
|
||||
|
||||
add_definitions(-DLINUX -DCC_ENABLE_CHIPMUNK_INTEGRATION=1)
|
||||
if(USE_CHIPMUNK)
|
||||
message("Using chipmunk ...")
|
||||
add_definitions(-DLINUX -DCC_ENABLE_CHIPMUNK_INTEGRATION=1)
|
||||
elseif(USE_BOX2D)
|
||||
message("Using box2d ...")
|
||||
add_definitions(-DLINUX -DCC_ENABLE_BOX2D_INTEGRATION=1)
|
||||
else(USE_CHIPMUNK)
|
||||
message(FATAL_ERROR "Must choose a physics library.")
|
||||
endif(USE_CHIPMUNK)
|
||||
|
||||
# architecture
|
||||
if ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
|
||||
|
@ -58,6 +89,7 @@ link_directories(
|
|||
${CMAKE_SOURCE_DIR}/external/linux-specific/fmod/prebuilt/${ARCH_DIR}
|
||||
)
|
||||
|
||||
|
||||
# kazmath
|
||||
add_subdirectory(cocos/math/kazmath)
|
||||
|
||||
|
@ -73,8 +105,6 @@ add_subdirectory(external/unzip)
|
|||
# tinyxml2 library
|
||||
add_subdirectory(external/tinyxml2)
|
||||
|
||||
add_subdirectory(external/json)
|
||||
|
||||
# audio
|
||||
add_subdirectory(cocos/audio)
|
||||
|
||||
|
@ -84,22 +114,51 @@ add_subdirectory(cocos/base)
|
|||
# cocos 2d library
|
||||
add_subdirectory(cocos/2d)
|
||||
|
||||
if(BUILD_GUI)
|
||||
# gui
|
||||
add_subdirectory(cocos/gui)
|
||||
endif(BUILD_GUI)
|
||||
|
||||
if(BUILD_NETWORK)
|
||||
# network
|
||||
add_subdirectory(cocos/network)
|
||||
endif(BUILD_NETWORK)
|
||||
|
||||
if(BUILD_EXTENSIONS)
|
||||
# extensions
|
||||
add_subdirectory(extensions)
|
||||
endif(BUILD_EXTENSIONS)
|
||||
|
||||
## Editor Support
|
||||
|
||||
if(BUILD_EDITOR_SPINE)
|
||||
# spine
|
||||
add_subdirectory(cocos/editor-support/spine)
|
||||
endif(BUILD_EDITOR_SPINE)
|
||||
|
||||
if(BUILD_EDITOR_COCOSBUILDER)
|
||||
# cocosbuilder
|
||||
add_subdirectory(cocos/editor-support/cocosbuilder)
|
||||
endif(BUILD_EDITOR_COCOSBUILDER)
|
||||
|
||||
if(BUILD_EDITOR_COCOSTUDIO)
|
||||
# cocostudio
|
||||
add_subdirectory(cocos/editor-support/cocostudio)
|
||||
# jsoncpp library, cocostuido depends on jsoncpp
|
||||
add_subdirectory(external/json)
|
||||
endif(BUILD_EDITOR_COCOSTUDIO)
|
||||
|
||||
|
||||
if(BUILD_LIBS_LUA)
|
||||
## Scripting
|
||||
# lua
|
||||
add_subdirectory(external/lua/lua)
|
||||
|
||||
# tolua
|
||||
add_subdirectory(external/lua/tolua)
|
||||
|
||||
# luabinding
|
||||
add_subdirectory(cocos/scripting)
|
||||
endif(BUILD_LIBS_LUA)
|
||||
|
||||
# build samples
|
||||
add_subdirectory(samples)
|
||||
|
||||
|
|
11
README.md
11
README.md
|
@ -29,8 +29,8 @@ How to start a new game
|
|||
|
||||
Example:
|
||||
|
||||
$ cd cocos2d-x/tools/project-creator
|
||||
$ ./create-multi-platform-projects.py -p mygame -k com.your_company.mygame -l cpp
|
||||
$ cd cocos2d-x/tools/project-creator
|
||||
$ ./create-multi-platform-projects.py -p mygame -k com.your_company.mygame -l cpp
|
||||
$ cd ../../projects/mygame
|
||||
|
||||
|
||||
|
@ -70,7 +70,7 @@ Build Requirements
|
|||
------------------
|
||||
|
||||
* Mac OS X 10.7+, Xcode 4.6+
|
||||
* or Ubuntu 13.04+
|
||||
* or Ubuntu 12.10+, CMake 2.6+
|
||||
* or Windows 7+, VS 2012+
|
||||
|
||||
|
||||
|
@ -97,8 +97,9 @@ $ open samples.xcodeproj
|
|||
* For Linux
|
||||
|
||||
```
|
||||
$ cd cocos2d-x/build
|
||||
$ ./make-all-linux-projects.sh
|
||||
$ cd cocos2d-x
|
||||
$ cmake CMakeLists.txt
|
||||
$ make
|
||||
```
|
||||
|
||||
* For Windows
|
||||
|
|
|
@ -1,53 +1,13 @@
|
|||
# This file was copied from GamePlay
|
||||
# Copies files for the given game into the target res directory
|
||||
# GAME_NAME name of the game
|
||||
# REL_DIR to which directory these files are relative
|
||||
# SRC_FILES which files from the REL_DIR to copy (GLOB)
|
||||
macro(COPY_RES_FILES GAME_NAME GAME_RES_TARGET REL_DIR SRC_FILES)
|
||||
file( GLOB_RECURSE RES_FILES RELATIVE ${REL_DIR} ${SRC_FILES} )
|
||||
macro(pre_build TARGET_NAME)
|
||||
add_custom_target( ${TARGET_NAME}_PRE_BUILD ALL )
|
||||
|
||||
set(ALL_FILES)
|
||||
foreach(SRC_FILE ${RES_FILES})
|
||||
IF(NOT (SRC_FILE MATCHES "(^\\.\\.)"))
|
||||
add_custom_command(
|
||||
OUTPUT "${APP_BIN_DIR}/${SRC_FILE}"
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
"${REL_DIR}/${SRC_FILE}"
|
||||
"${APP_BIN_DIR}/Resources/${SRC_FILE}"
|
||||
COMMENT "Copy ${SRC_FILE}"
|
||||
)
|
||||
list(APPEND ALL_FILES "${APP_BIN_DIR}/${SRC_FILE}" )
|
||||
ENDIF(NOT (SRC_FILE MATCHES "(^\\.\\.)"))
|
||||
endforeach()
|
||||
# create target for copying these files
|
||||
add_custom_target( ${GAME_RES_TARGET} DEPENDS ${ALL_FILES} )
|
||||
endmacro()
|
||||
add_custom_command(
|
||||
TARGET ${TARGET_NAME}_PRE_BUILD
|
||||
${ARGN}
|
||||
PRE_BUILD
|
||||
COMMENT "${TARGET_NAME}_PRE_BUILD ..."
|
||||
)
|
||||
|
||||
# convenience to call above with current directory and everything in "res"
|
||||
macro(COPY_RES GAME_NAME)
|
||||
# a target for all addition asserts (will be done in default compile, but if you target the executable
|
||||
# it won't be done -- good for testing)
|
||||
add_custom_target( ${GAME_NAME}_ASSETS ALL )
|
||||
|
||||
# copy entire "res" directory and "game.config" if there is one
|
||||
set(CRG_PATTERN "*")
|
||||
COPY_RES_FILES( ${GAME_NAME} ${GAME_NAME}_CORE_RES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Resources
|
||||
"${CRG_PATTERN}"
|
||||
)
|
||||
add_dependencies( ${GAME_NAME}_ASSETS ${GAME_NAME}_CORE_RES )
|
||||
endmacro()
|
||||
|
||||
# Copies resources from an additional directory
|
||||
# GAME_NAME name of the game
|
||||
# REL_DIR from which directory
|
||||
# ARGN which patterns to copy (should include res/ in name if to be placed in the res/ output)
|
||||
macro(COPY_RES_EXTRA GAME_NAME EXTRA_RES REL_DIR)
|
||||
# convert src's to full paths (based on rel_dir)
|
||||
set(SRC_FILES)
|
||||
foreach(SRC_FILE ${ARGN} )
|
||||
list(APPEND SRC_FILES "${REL_DIR}/${SRC_FILE}")
|
||||
endforeach()
|
||||
COPY_RES_FILES( ${GAME_NAME} ${GAME_NAME}_${EXTRA_RES} ${REL_DIR} "${SRC_FILES}" )
|
||||
add_dependencies( ${GAME_NAME}_ASSETS ${GAME_NAME}_${EXTRA_RES} )
|
||||
add_custom_target( ${TARGET_NAME}_CORE_PRE_BUILD )
|
||||
add_dependencies( ${TARGET_NAME}_PRE_BUILD ${TARGET_NAME}_CORE_PRE_BUILD )
|
||||
endmacro()
|
||||
|
|
|
@ -71,22 +71,20 @@ AnimationCache::~AnimationCache()
|
|||
CC_SAFE_RELEASE(_animations);
|
||||
}
|
||||
|
||||
void AnimationCache::addAnimation(Animation *animation, const char * name)
|
||||
void AnimationCache::addAnimation(Animation *animation, const std::string& name)
|
||||
{
|
||||
_animations->setObject(animation, name);
|
||||
}
|
||||
|
||||
void AnimationCache::removeAnimation(const char* name)
|
||||
void AnimationCache::removeAnimation(const std::string& name)
|
||||
{
|
||||
if (! name)
|
||||
{
|
||||
if (name.size()==0)
|
||||
return;
|
||||
}
|
||||
|
||||
_animations->removeObjectForKey(name);
|
||||
}
|
||||
|
||||
Animation* AnimationCache::getAnimation(const char* name)
|
||||
Animation* AnimationCache::getAnimation(const std::string& name)
|
||||
{
|
||||
return (Animation*)_animations->objectForKey(name);
|
||||
}
|
||||
|
@ -95,17 +93,17 @@ void AnimationCache::parseVersion1(Dictionary* animations)
|
|||
{
|
||||
SpriteFrameCache *frameCache = SpriteFrameCache::getInstance();
|
||||
|
||||
DictElement* pElement = NULL;
|
||||
CCDICT_FOREACH(animations, pElement)
|
||||
DictElement* element = NULL;
|
||||
CCDICT_FOREACH(animations, element)
|
||||
{
|
||||
Dictionary* animationDict = static_cast<Dictionary*>(pElement->getObject());
|
||||
Dictionary* animationDict = static_cast<Dictionary*>(element->getObject());
|
||||
Array* frameNames = static_cast<Array*>(animationDict->objectForKey("frames"));
|
||||
float delay = animationDict->valueForKey("delay")->floatValue();
|
||||
Animation* animation = NULL;
|
||||
|
||||
if ( frameNames == NULL )
|
||||
{
|
||||
CCLOG("cocos2d: AnimationCache: Animation '%s' found in dictionary without any frames - cannot add to animation cache.", pElement->getStrKey());
|
||||
CCLOG("cocos2d: AnimationCache: Animation '%s' found in dictionary without any frames - cannot add to animation cache.", element->getStrKey());
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -115,11 +113,11 @@ void AnimationCache::parseVersion1(Dictionary* animations)
|
|||
Object* pObj = NULL;
|
||||
CCARRAY_FOREACH(frameNames, pObj)
|
||||
{
|
||||
const char* frameName = static_cast<String*>(pObj)->getCString();
|
||||
const std::string& frameName = static_cast<String*>(pObj)->getCString();
|
||||
SpriteFrame* spriteFrame = frameCache->getSpriteFrameByName(frameName);
|
||||
|
||||
if ( ! spriteFrame ) {
|
||||
CCLOG("cocos2d: AnimationCache: Animation '%s' refers to frame '%s' which is not currently in the SpriteFrameCache. This frame will not be added to the animation.", pElement->getStrKey(), frameName);
|
||||
CCLOG("cocos2d: AnimationCache: Animation '%s' refers to frame '%s' which is not currently in the SpriteFrameCache. This frame will not be added to the animation.", element->getStrKey(), frameName.c_str());
|
||||
|
||||
continue;
|
||||
}
|
||||
|
@ -131,15 +129,15 @@ void AnimationCache::parseVersion1(Dictionary* animations)
|
|||
}
|
||||
|
||||
if ( frames->count() == 0 ) {
|
||||
CCLOG("cocos2d: AnimationCache: None of the frames for animation '%s' were found in the SpriteFrameCache. Animation is not being added to the Animation Cache.", pElement->getStrKey());
|
||||
CCLOG("cocos2d: AnimationCache: None of the frames for animation '%s' were found in the SpriteFrameCache. Animation is not being added to the Animation Cache.", element->getStrKey());
|
||||
continue;
|
||||
} else if ( frames->count() != frameNames->count() ) {
|
||||
CCLOG("cocos2d: AnimationCache: An animation in your dictionary refers to a frame which is not in the SpriteFrameCache. Some or all of the frames for the animation '%s' may be missing.", pElement->getStrKey());
|
||||
CCLOG("cocos2d: AnimationCache: An animation in your dictionary refers to a frame which is not in the SpriteFrameCache. Some or all of the frames for the animation '%s' may be missing.", element->getStrKey());
|
||||
}
|
||||
|
||||
animation = Animation::create(frames, delay, 1);
|
||||
|
||||
AnimationCache::getInstance()->addAnimation(animation, pElement->getStrKey());
|
||||
AnimationCache::getInstance()->addAnimation(animation, element->getStrKey());
|
||||
frames->release();
|
||||
}
|
||||
}
|
||||
|
@ -148,11 +146,11 @@ void AnimationCache::parseVersion2(Dictionary* animations)
|
|||
{
|
||||
SpriteFrameCache *frameCache = SpriteFrameCache::getInstance();
|
||||
|
||||
DictElement* pElement = NULL;
|
||||
CCDICT_FOREACH(animations, pElement)
|
||||
DictElement* element = NULL;
|
||||
CCDICT_FOREACH(animations, element)
|
||||
{
|
||||
const char* name = pElement->getStrKey();
|
||||
Dictionary* animationDict = static_cast<Dictionary*>(pElement->getObject());
|
||||
const char* name = element->getStrKey();
|
||||
Dictionary* animationDict = static_cast<Dictionary*>(element->getObject());
|
||||
|
||||
const String* loops = animationDict->valueForKey("loops");
|
||||
bool restoreOriginalFrame = animationDict->valueForKey("restoreOriginalFrame")->boolValue();
|
||||
|
@ -241,9 +239,9 @@ void AnimationCache::addAnimationsWithDictionary(Dictionary* dictionary)
|
|||
}
|
||||
|
||||
/** Read an NSDictionary from a plist file and parse it automatically for animations */
|
||||
void AnimationCache::addAnimationsWithFile(const char* plist)
|
||||
void AnimationCache::addAnimationsWithFile(const std::string& plist)
|
||||
{
|
||||
CCASSERT( plist, "Invalid texture file name");
|
||||
CCASSERT( plist.size()>0, "Invalid texture file name");
|
||||
|
||||
std::string path = FileUtils::getInstance()->fullPathForFilename(plist);
|
||||
Dictionary* dict = Dictionary::createWithContentsOfFile(path.c_str());
|
||||
|
|
|
@ -76,29 +76,29 @@ public:
|
|||
|
||||
/** Adds a Animation with a name.
|
||||
*/
|
||||
void addAnimation(Animation *animation, const char * name);
|
||||
void addAnimation(Animation *animation, const std::string& name);
|
||||
|
||||
/** Deletes a Animation from the cache.
|
||||
|
||||
*/
|
||||
void removeAnimation(const char* name);
|
||||
void removeAnimation(const std::string& name);
|
||||
/** @deprecated. Use removeAnimation() instead
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
CC_DEPRECATED_ATTRIBUTE void removeAnimationByName(const char* name){ removeAnimation(name);}
|
||||
CC_DEPRECATED_ATTRIBUTE void removeAnimationByName(const std::string& name){ removeAnimation(name);}
|
||||
|
||||
/** Returns a Animation that was previously added.
|
||||
If the name is not found it will return nil.
|
||||
You should retain the returned copy if you are going to use it.
|
||||
*/
|
||||
Animation* getAnimation(const char* name);
|
||||
Animation* getAnimation(const std::string& name);
|
||||
/**
|
||||
@deprecated. Use getAnimation() instead
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
CC_DEPRECATED_ATTRIBUTE Animation* animationByName(const char* name){ return getAnimation(name); }
|
||||
CC_DEPRECATED_ATTRIBUTE Animation* animationByName(const std::string& name){ return getAnimation(name); }
|
||||
|
||||
/** Adds an animation from an NSDictionary
|
||||
Make sure that the frames were previously loaded in the SpriteFrameCache.
|
||||
|
@ -112,7 +112,7 @@ public:
|
|||
* @js addAnimations
|
||||
* @lua addAnimations
|
||||
*/
|
||||
void addAnimationsWithFile(const char* plist);
|
||||
void addAnimationsWithFile(const std::string& plist);
|
||||
|
||||
private:
|
||||
void parseVersion1(Dictionary* animations);
|
||||
|
|
|
@ -831,7 +831,7 @@ void Director::calculateMPF()
|
|||
}
|
||||
|
||||
// returns the FPS image data pointer and len
|
||||
void Director::getFPSImageData(unsigned char** datapointer, unsigned int* length)
|
||||
void Director::getFPSImageData(unsigned char** datapointer, long* length)
|
||||
{
|
||||
// XXX fixed me if it should be used
|
||||
*datapointer = cc_fps_images_png;
|
||||
|
@ -855,7 +855,7 @@ void Director::createStatsLabel()
|
|||
Texture2D::PixelFormat currentFormat = Texture2D::getDefaultAlphaPixelFormat();
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA4444);
|
||||
unsigned char *data = nullptr;
|
||||
unsigned int dataLength = 0;
|
||||
long dataLength = 0;
|
||||
getFPSImageData(&data, &dataLength);
|
||||
|
||||
Image* image = new Image();
|
||||
|
|
|
@ -376,7 +376,7 @@ protected:
|
|||
void showStats();
|
||||
void createStatsLabel();
|
||||
void calculateMPF();
|
||||
void getFPSImageData(unsigned char** datapointer, unsigned int* length);
|
||||
void getFPSImageData(unsigned char** datapointer, long* length);
|
||||
|
||||
/** calculates delta time since last time it was called */
|
||||
void calculateDeltaTime();
|
||||
|
|
|
@ -99,8 +99,8 @@ bool FontFreeType::createFontObject(const std::string &fontName, int fontSize)
|
|||
{
|
||||
FT_Face face;
|
||||
|
||||
int len = 0;
|
||||
_ttfData = FileUtils::getInstance()->getFileData(fontName.c_str(), "rb", (unsigned long *)(&len));
|
||||
long len = 0;
|
||||
_ttfData = FileUtils::getInstance()->getFileData(fontName.c_str(), "rb", &len);
|
||||
if (!_ttfData)
|
||||
return false;
|
||||
|
||||
|
|
|
@ -29,9 +29,9 @@
|
|||
|
||||
NS_CC_BEGIN
|
||||
|
||||
Label* Label::createWithTTF( const char* label, const char* fontFilePath, int fontSize, int lineSize, TextHAlignment alignment, GlyphCollection glyphs, const char *customGlyphs )
|
||||
Label* Label::createWithTTF(const std::string& label, const std::string& fontFilePath, int fontSize, int lineSize, TextHAlignment alignment, GlyphCollection glyphs, const char *customGlyphs )
|
||||
{
|
||||
FontAtlas *tmpAtlas = FontAtlasCache::getFontAtlasTTF(fontFilePath, fontSize, glyphs, customGlyphs);
|
||||
FontAtlas *tmpAtlas = FontAtlasCache::getFontAtlasTTF(fontFilePath.c_str(), fontSize, glyphs, customGlyphs);
|
||||
|
||||
if (!tmpAtlas)
|
||||
return nullptr;
|
||||
|
@ -48,10 +48,10 @@ Label* Label::createWithTTF( const char* label, const char* fontFilePath, int fo
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
Label* Label::createWithBMFont( const char* label, const char* bmfontFilePath, TextHAlignment alignment, int lineSize)
|
||||
Label* Label::createWithBMFont(const std::string& label, const std::string& bmfontFilePath, TextHAlignment alignment, int lineSize)
|
||||
{
|
||||
|
||||
FontAtlas *tmpAtlas = FontAtlasCache::getFontAtlasFNT(bmfontFilePath);
|
||||
FontAtlas *tmpAtlas = FontAtlasCache::getFontAtlasFNT(bmfontFilePath.c_str());
|
||||
|
||||
if (!tmpAtlas)
|
||||
return 0;
|
||||
|
@ -135,12 +135,12 @@ bool Label::init()
|
|||
return true;
|
||||
}
|
||||
|
||||
void Label::setString(const char *stringToRender)
|
||||
void Label::setString(const std::string &stringToRender)
|
||||
{
|
||||
setText(stringToRender, _width, TextHAlignment::CENTER, false);
|
||||
}
|
||||
|
||||
bool Label::setText(const char *stringToRender, float lineWidth, TextHAlignment alignment, bool lineBreakWithoutSpaces)
|
||||
bool Label::setText(const std::string& stringToRender, float lineWidth, TextHAlignment alignment, bool lineBreakWithoutSpaces)
|
||||
{
|
||||
if (!_fontAtlas)
|
||||
return false;
|
||||
|
@ -159,7 +159,7 @@ bool Label::setText(const char *stringToRender, float lineWidth, TextHAlignment
|
|||
return false;
|
||||
|
||||
// int numLetter = 0;
|
||||
unsigned short* utf16String = cc_utf8_to_utf16(stringToRender);
|
||||
unsigned short* utf16String = cc_utf8_to_utf16(stringToRender.c_str());
|
||||
if(!utf16String)
|
||||
return false;
|
||||
|
||||
|
|
|
@ -51,13 +51,13 @@ class CC_DLL Label : public SpriteBatchNode, public LabelProtocol, public RGBAPr
|
|||
public:
|
||||
|
||||
// static create
|
||||
static Label* createWithTTF(const char* label, const char* fontFilePath, int fontSize, int lineSize = 0, TextHAlignment alignment = TextHAlignment::CENTER, GlyphCollection glyphs = GlyphCollection::NEHE, const char *customGlyphs = 0);
|
||||
static Label* createWithTTF(const std::string& label, const std::string& fontFilePath, int fontSize, int lineSize = 0, TextHAlignment alignment = TextHAlignment::CENTER, GlyphCollection glyphs = GlyphCollection::NEHE, const char *customGlyphs = 0);
|
||||
|
||||
static Label* createWithBMFont(const char* label, const char* bmfontFilePath, TextHAlignment alignment = TextHAlignment::CENTER, int lineSize = 0);
|
||||
static Label* createWithBMFont(const std::string& label, const std::string& bmfontFilePath, TextHAlignment alignment = TextHAlignment::CENTER, int lineSize = 0);
|
||||
|
||||
bool setText(const char *stringToRender, float lineWidth, TextHAlignment alignment = TextHAlignment::LEFT, bool lineBreakWithoutSpaces = false);
|
||||
bool setText(const std::string& stringToRender, float lineWidth, TextHAlignment alignment = TextHAlignment::LEFT, bool lineBreakWithoutSpaces = false);
|
||||
|
||||
virtual void setString(const char *stringToRender) override;
|
||||
virtual void setString(const std::string &stringToRender) override;
|
||||
virtual void setAlignment(TextHAlignment alignment);
|
||||
virtual void setWidth(float width);
|
||||
virtual void setLineBreakWithoutSpace(bool breakWithoutSpace);
|
||||
|
|
|
@ -186,9 +186,9 @@ void LabelAtlas::updateAtlasValues()
|
|||
}
|
||||
|
||||
//CCLabelAtlas - LabelProtocol
|
||||
void LabelAtlas::setString(const char *label)
|
||||
void LabelAtlas::setString(const std::string &label)
|
||||
{
|
||||
size_t len = strlen(label);
|
||||
size_t len = label.size();
|
||||
if (len > _textureAtlas->getTotalQuads())
|
||||
{
|
||||
_textureAtlas->resizeCapacity(len);
|
||||
|
|
|
@ -87,7 +87,7 @@ public:
|
|||
|
||||
// super methods
|
||||
virtual void updateAtlasValues();
|
||||
virtual void setString(const char *label);
|
||||
virtual void setString(const std::string &label);
|
||||
virtual const char* getString(void) const;
|
||||
|
||||
#if CC_LABELATLAS_DEBUG_DRAW
|
||||
|
|
|
@ -62,7 +62,7 @@ static unsigned short* copyUTF16StringN(unsigned short* str)
|
|||
//
|
||||
static Dictionary* s_pConfigurations = NULL;
|
||||
|
||||
CCBMFontConfiguration* FNTConfigLoadFile( const char *fntFile)
|
||||
CCBMFontConfiguration* FNTConfigLoadFile(const std::string& fntFile)
|
||||
{
|
||||
CCBMFontConfiguration* pRet = NULL;
|
||||
|
||||
|
@ -75,7 +75,7 @@ CCBMFontConfiguration* FNTConfigLoadFile( const char *fntFile)
|
|||
pRet = static_cast<CCBMFontConfiguration*>( s_pConfigurations->objectForKey(fntFile) );
|
||||
if( pRet == NULL )
|
||||
{
|
||||
pRet = CCBMFontConfiguration::create(fntFile);
|
||||
pRet = CCBMFontConfiguration::create(fntFile.c_str());
|
||||
if (pRet)
|
||||
{
|
||||
s_pConfigurations->setObject(pRet, fntFile);
|
||||
|
@ -180,7 +180,7 @@ void CCBMFontConfiguration::purgeFontDefDictionary()
|
|||
}
|
||||
}
|
||||
|
||||
std::set<unsigned int>* CCBMFontConfiguration::parseConfigFile(const char *controlFile)
|
||||
std::set<unsigned int>* CCBMFontConfiguration::parseConfigFile(const std::string& controlFile)
|
||||
{
|
||||
std::string fullpath = FileUtils::getInstance()->fullPathForFilename(controlFile);
|
||||
String *contents = String::createWithContentsOfFile(fullpath.c_str());
|
||||
|
@ -191,7 +191,7 @@ std::set<unsigned int>* CCBMFontConfiguration::parseConfigFile(const char *contr
|
|||
|
||||
if (!contents)
|
||||
{
|
||||
CCLOG("cocos2d: Error parsing FNTfile %s", controlFile);
|
||||
CCLOG("cocos2d: Error parsing FNTfile %s", controlFile.c_str());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -259,7 +259,7 @@ std::set<unsigned int>* CCBMFontConfiguration::parseConfigFile(const char *contr
|
|||
return validCharsString;
|
||||
}
|
||||
|
||||
void CCBMFontConfiguration::parseImageFileName(std::string line, const char *fntFile)
|
||||
void CCBMFontConfiguration::parseImageFileName(std::string line, const std::string& fntFile)
|
||||
{
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// line to parse:
|
||||
|
@ -431,23 +431,23 @@ LabelBMFont * LabelBMFont::create()
|
|||
return NULL;
|
||||
}
|
||||
|
||||
LabelBMFont * LabelBMFont::create(const char *str, const char *fntFile, float width, TextHAlignment alignment)
|
||||
LabelBMFont * LabelBMFont::create(const std::string& str, const std::string& fntFile, float width, TextHAlignment alignment)
|
||||
{
|
||||
return LabelBMFont::create(str, fntFile, width, alignment, Point::ZERO);
|
||||
}
|
||||
|
||||
LabelBMFont * LabelBMFont::create(const char *str, const char *fntFile, float width)
|
||||
LabelBMFont * LabelBMFont::create(const std::string& str, const std::string& fntFile, float width)
|
||||
{
|
||||
return LabelBMFont::create(str, fntFile, width, TextHAlignment::LEFT, Point::ZERO);
|
||||
}
|
||||
|
||||
LabelBMFont * LabelBMFont::create(const char *str, const char *fntFile)
|
||||
LabelBMFont * LabelBMFont::create(const std::string& str, const std::string& fntFile)
|
||||
{
|
||||
return LabelBMFont::create(str, fntFile, kLabelAutomaticWidth, TextHAlignment::LEFT, Point::ZERO);
|
||||
}
|
||||
|
||||
//LabelBMFont - Creation & Init
|
||||
LabelBMFont *LabelBMFont::create(const char *str, const char *fntFile, float width/* = kLabelAutomaticWidth*/, TextHAlignment alignment/* = TextHAlignment::LEFT*/, Point imageOffset/* = Point::ZERO*/)
|
||||
LabelBMFont *LabelBMFont::create(const std::string& str, const std::string& fntFile, float width/* = kLabelAutomaticWidth*/, TextHAlignment alignment/* = TextHAlignment::LEFT*/, Point imageOffset/* = Point::ZERO*/)
|
||||
{
|
||||
LabelBMFont *pRet = new LabelBMFont();
|
||||
if(pRet && pRet->initWithString(str, fntFile, width, alignment, imageOffset))
|
||||
|
@ -461,22 +461,21 @@ LabelBMFont *LabelBMFont::create(const char *str, const char *fntFile, float wid
|
|||
|
||||
bool LabelBMFont::init()
|
||||
{
|
||||
return initWithString(NULL, NULL, kLabelAutomaticWidth, TextHAlignment::LEFT, Point::ZERO);
|
||||
return initWithString("", "", kLabelAutomaticWidth, TextHAlignment::LEFT, Point::ZERO);
|
||||
}
|
||||
|
||||
bool LabelBMFont::initWithString(const char *theString, const char *fntFile, float width/* = kLabelAutomaticWidth*/, TextHAlignment alignment/* = TextHAlignment::LEFT*/, Point imageOffset/* = Point::ZERO*/)
|
||||
bool LabelBMFont::initWithString(const std::string& theString, const std::string& fntFile, float width/* = kLabelAutomaticWidth*/, TextHAlignment alignment/* = TextHAlignment::LEFT*/, Point imageOffset/* = Point::ZERO*/)
|
||||
{
|
||||
CCASSERT(!_configuration, "re-init is no longer supported");
|
||||
CCASSERT( (theString && fntFile) || (theString==NULL && fntFile==NULL), "Invalid params for LabelBMFont");
|
||||
|
||||
|
||||
Texture2D *texture = NULL;
|
||||
|
||||
if (fntFile)
|
||||
if (fntFile.size() > 0 )
|
||||
{
|
||||
CCBMFontConfiguration *newConf = FNTConfigLoadFile(fntFile);
|
||||
if (!newConf)
|
||||
{
|
||||
CCLOG("cocos2d: WARNING. LabelBMFont: Impossible to create font. Please check file: '%s'", fntFile);
|
||||
CCLOG("cocos2d: WARNING. LabelBMFont: Impossible to create font. Please check file: '%s'", fntFile.c_str());
|
||||
release();
|
||||
return false;
|
||||
}
|
||||
|
@ -495,12 +494,7 @@ bool LabelBMFont::initWithString(const char *theString, const char *fntFile, flo
|
|||
texture->autorelease();
|
||||
}
|
||||
|
||||
if (theString == NULL)
|
||||
{
|
||||
theString = "";
|
||||
}
|
||||
|
||||
if (SpriteBatchNode::initWithTexture(texture, strlen(theString)))
|
||||
if (SpriteBatchNode::initWithTexture(texture, theString.size()))
|
||||
{
|
||||
_width = width;
|
||||
_alignment = alignment;
|
||||
|
@ -724,20 +718,17 @@ void LabelBMFont::createFontChars()
|
|||
}
|
||||
|
||||
//LabelBMFont - LabelProtocol protocol
|
||||
void LabelBMFont::setString(const char *newString)
|
||||
void LabelBMFont::setString(const std::string &newString)
|
||||
{
|
||||
this->setString(newString, true);
|
||||
}
|
||||
|
||||
void LabelBMFont::setString(const char *newString, bool needUpdateLabel)
|
||||
void LabelBMFont::setString(const std::string &newString, bool needUpdateLabel)
|
||||
{
|
||||
if (newString == NULL) {
|
||||
newString = "";
|
||||
}
|
||||
if (needUpdateLabel) {
|
||||
_initialStringUTF8 = newString;
|
||||
}
|
||||
unsigned short* utf16String = cc_utf8_to_utf16(newString);
|
||||
unsigned short* utf16String = cc_utf8_to_utf16(newString.c_str());
|
||||
setString(utf16String, needUpdateLabel);
|
||||
CC_SAFE_DELETE_ARRAY(utf16String);
|
||||
}
|
||||
|
|
|
@ -145,16 +145,16 @@ public:
|
|||
/** initializes a BitmapFontConfiguration with a FNT file */
|
||||
bool initWithFNTfile(const char *FNTfile);
|
||||
|
||||
inline const char* getAtlasName(){ return _atlasName.c_str(); }
|
||||
inline void setAtlasName(const char* atlasName) { _atlasName = atlasName; }
|
||||
inline const std::string& getAtlasName(){ return _atlasName; }
|
||||
inline void setAtlasName(const std::string& atlasName) { _atlasName = atlasName; }
|
||||
|
||||
std::set<unsigned int>* getCharacterSet() const;
|
||||
private:
|
||||
std::set<unsigned int>* parseConfigFile(const char *controlFile);
|
||||
std::set<unsigned int>* parseConfigFile(const std::string& controlFile);
|
||||
void parseCharacterDefinition(std::string line, ccBMFontDef *characterDefinition);
|
||||
void parseInfoArguments(std::string line);
|
||||
void parseCommonArguments(std::string line);
|
||||
void parseImageFileName(std::string line, const char *fntFile);
|
||||
void parseImageFileName(std::string line, const std::string& fntFile);
|
||||
void parseKerningEntry(std::string line);
|
||||
void purgeKerningDictionary();
|
||||
void purgeFontDefDictionary();
|
||||
|
@ -209,13 +209,13 @@ public:
|
|||
static void purgeCachedData();
|
||||
|
||||
/** creates a bitmap font atlas with an initial string and the FNT file */
|
||||
static LabelBMFont * create(const char *str, const char *fntFile, float width, TextHAlignment alignment, Point imageOffset);
|
||||
static LabelBMFont * create(const std::string& str, const std::string& fntFile, float width, TextHAlignment alignment, Point imageOffset);
|
||||
|
||||
static LabelBMFont * create(const char *str, const char *fntFile, float width, TextHAlignment alignment);
|
||||
static LabelBMFont * create(const std::string& str, const std::string& fntFile, float width, TextHAlignment alignment);
|
||||
|
||||
static LabelBMFont * create(const char *str, const char *fntFile, float width);
|
||||
static LabelBMFont * create(const std::string& str, const std::string& fntFile, float width);
|
||||
|
||||
static LabelBMFont * create(const char *str, const char *fntFile);
|
||||
static LabelBMFont * create(const std::string& str, const std::string& fntFile);
|
||||
|
||||
/** Creates an label.
|
||||
*/
|
||||
|
@ -223,15 +223,15 @@ public:
|
|||
|
||||
bool init();
|
||||
/** init a bitmap font atlas with an initial string and the FNT file */
|
||||
bool initWithString(const char *str, const char *fntFile, float width = kLabelAutomaticWidth, TextHAlignment alignment = TextHAlignment::LEFT, Point imageOffset = Point::ZERO);
|
||||
bool initWithString(const std::string& str, const std::string& fntFile, float width = kLabelAutomaticWidth, TextHAlignment alignment = TextHAlignment::LEFT, Point imageOffset = Point::ZERO);
|
||||
|
||||
/** updates the font chars based on the string to render */
|
||||
void createFontChars();
|
||||
// super method
|
||||
virtual void setString(const char *newString);
|
||||
virtual void setString(const char *newString, bool needUpdateLabel);
|
||||
virtual void setString(const std::string& newString);
|
||||
virtual void setString(const std::string& newString, bool needUpdateLabel);
|
||||
|
||||
virtual const char* getString(void) const;
|
||||
virtual const char* getString() const;
|
||||
virtual void setCString(const char *label);
|
||||
virtual void setAnchorPoint(const Point& var);
|
||||
virtual void updateLabel();
|
||||
|
@ -264,7 +264,7 @@ public:
|
|||
virtual void draw();
|
||||
#endif // CC_LABELBMFONT_DEBUG_DRAW
|
||||
private:
|
||||
char * atlasNameFromFntFile(const char *fntFile);
|
||||
char * atlasNameFromFntFile(const std::string& fntFile);
|
||||
int kerningAmountForFirst(unsigned short first, unsigned short second);
|
||||
float getLetterPosXLeft( Sprite* characterSprite );
|
||||
float getLetterPosXRight( Sprite* characterSprite );
|
||||
|
@ -309,7 +309,7 @@ protected:
|
|||
|
||||
/** Free function that parses a FNT file a place it on the cache
|
||||
*/
|
||||
CC_DLL CCBMFontConfiguration * FNTConfigLoadFile( const char *file );
|
||||
CC_DLL CCBMFontConfiguration * FNTConfigLoadFile(const std::string &file);
|
||||
/** Purges the FNT config cache
|
||||
*/
|
||||
CC_DLL void FNTConfigRemoveCache( void );
|
||||
|
|
|
@ -171,10 +171,8 @@ bool LabelTTF::initWithStringAndTextDefinition(const char *string, FontDefinitio
|
|||
}
|
||||
|
||||
|
||||
void LabelTTF::setString(const char *string)
|
||||
void LabelTTF::setString(const std::string &string)
|
||||
{
|
||||
CCASSERT(string != NULL, "Invalid string");
|
||||
|
||||
if (_string.compare(string))
|
||||
{
|
||||
_string = string;
|
||||
|
|
|
@ -144,7 +144,7 @@ public:
|
|||
/** changes the string to render
|
||||
* @warning Changing the string is as expensive as creating a new LabelTTF. To obtain better performance use LabelAtlas
|
||||
*/
|
||||
virtual void setString(const char *label);
|
||||
virtual void setString(const std::string &label);
|
||||
virtual const char* getString(void) const;
|
||||
|
||||
TextHAlignment getHorizontalAlignment() const;
|
||||
|
|
|
@ -136,7 +136,7 @@ ParticleSystem::ParticleSystem()
|
|||
}
|
||||
// implementation ParticleSystem
|
||||
|
||||
ParticleSystem * ParticleSystem::create(const char *plistFile)
|
||||
ParticleSystem * ParticleSystem::create(const std::string& plistFile)
|
||||
{
|
||||
ParticleSystem *pRet = new ParticleSystem();
|
||||
if (pRet && pRet->initWithFile(plistFile))
|
||||
|
@ -165,7 +165,7 @@ bool ParticleSystem::init()
|
|||
return initWithTotalParticles(150);
|
||||
}
|
||||
|
||||
bool ParticleSystem::initWithFile(const char *plistFile)
|
||||
bool ParticleSystem::initWithFile(const std::string& plistFile)
|
||||
{
|
||||
bool bRet = false;
|
||||
_plistFile = FileUtils::getInstance()->fullPathForFilename(plistFile);
|
||||
|
@ -195,7 +195,7 @@ bool ParticleSystem::initWithDictionary(Dictionary *dictionary)
|
|||
return initWithDictionary(dictionary, "");
|
||||
}
|
||||
|
||||
bool ParticleSystem::initWithDictionary(Dictionary *dictionary, const char *dirname)
|
||||
bool ParticleSystem::initWithDictionary(Dictionary *dictionary, const std::string& dirname)
|
||||
{
|
||||
bool bRet = false;
|
||||
unsigned char *buffer = NULL;
|
||||
|
@ -353,17 +353,17 @@ bool ParticleSystem::initWithDictionary(Dictionary *dictionary, const char *dirn
|
|||
{
|
||||
string textureDir = textureName.substr(0, rPos + 1);
|
||||
|
||||
if (dirname != NULL && textureDir != dirname)
|
||||
if (dirname.size()>0 && textureDir != dirname)
|
||||
{
|
||||
textureName = textureName.substr(rPos+1);
|
||||
textureName = string(dirname) + textureName;
|
||||
textureName = dirname + textureName;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dirname != NULL)
|
||||
if (dirname.size()>0)
|
||||
{
|
||||
textureName = string(dirname) + textureName;
|
||||
textureName = dirname + textureName;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -167,7 +167,7 @@ public:
|
|||
http://particledesigner.71squared.com/
|
||||
@since v2.0
|
||||
*/
|
||||
static ParticleSystem * create(const char *plistFile);
|
||||
static ParticleSystem * create(const std::string& plistFile);
|
||||
|
||||
//! create a system with a fixed number of particles
|
||||
static ParticleSystem* createWithTotalParticles(unsigned int numberOfParticles);
|
||||
|
@ -188,7 +188,7 @@ public:
|
|||
http://particledesigner.71squared.com/
|
||||
@since v0.99.3
|
||||
*/
|
||||
bool initWithFile(const char *plistFile);
|
||||
bool initWithFile(const std::string& plistFile);
|
||||
|
||||
/** initializes a QuadParticleSystem from a Dictionary.
|
||||
@since v0.99.3
|
||||
|
@ -198,7 +198,7 @@ public:
|
|||
/** initializes a particle system from a NSDictionary and the path from where to load the png
|
||||
@since v2.1
|
||||
*/
|
||||
bool initWithDictionary(Dictionary *dictionary, const char *dirname);
|
||||
bool initWithDictionary(Dictionary *dictionary, const std::string& dirname);
|
||||
|
||||
//! Initializes a system with a fixed number of particles
|
||||
virtual bool initWithTotalParticles(unsigned int numberOfParticles);
|
||||
|
|
|
@ -229,7 +229,7 @@ public:
|
|||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void setString(const char *label) = 0;
|
||||
virtual void setString(const std::string &label) = 0;
|
||||
|
||||
/**
|
||||
* Returns the string that is currently being used in this label
|
||||
|
|
|
@ -82,7 +82,7 @@ Sprite* Sprite::createWithTexture(Texture2D *texture, const Rect& rect)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
Sprite* Sprite::create(const char *filename)
|
||||
Sprite* Sprite::create(const std::string& filename)
|
||||
{
|
||||
Sprite *sprite = new Sprite();
|
||||
if (sprite && sprite->initWithFile(filename))
|
||||
|
@ -94,7 +94,7 @@ Sprite* Sprite::create(const char *filename)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
Sprite* Sprite::create(const char *filename, const Rect& rect)
|
||||
Sprite* Sprite::create(const std::string& filename, const Rect& rect)
|
||||
{
|
||||
Sprite *sprite = new Sprite();
|
||||
if (sprite && sprite->initWithFile(filename, rect))
|
||||
|
@ -118,13 +118,13 @@ Sprite* Sprite::createWithSpriteFrame(SpriteFrame *spriteFrame)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
Sprite* Sprite::createWithSpriteFrameName(const char *spriteFrameName)
|
||||
Sprite* Sprite::createWithSpriteFrameName(const std::string& spriteFrameName)
|
||||
{
|
||||
SpriteFrame *frame = SpriteFrameCache::getInstance()->getSpriteFrameByName(spriteFrameName);
|
||||
|
||||
#if COCOS2D_DEBUG > 0
|
||||
char msg[256] = {0};
|
||||
sprintf(msg, "Invalid spriteFrameName: %s", spriteFrameName);
|
||||
sprintf(msg, "Invalid spriteFrameName: %s", spriteFrameName.c_str());
|
||||
CCASSERT(frame != NULL, msg);
|
||||
#endif
|
||||
|
||||
|
@ -215,9 +215,9 @@ bool Sprite::initWithTexture(Texture2D *texture)
|
|||
return initWithTexture(texture, rect);
|
||||
}
|
||||
|
||||
bool Sprite::initWithFile(const char *filename)
|
||||
bool Sprite::initWithFile(const std::string& filename)
|
||||
{
|
||||
CCASSERT(filename != NULL, "Invalid filename for sprite");
|
||||
CCASSERT(filename.size()>0, "Invalid filename for sprite");
|
||||
|
||||
Texture2D *texture = TextureCache::getInstance()->addImage(filename);
|
||||
if (texture)
|
||||
|
@ -233,9 +233,9 @@ bool Sprite::initWithFile(const char *filename)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool Sprite::initWithFile(const char *filename, const Rect& rect)
|
||||
bool Sprite::initWithFile(const std::string &filename, const Rect& rect)
|
||||
{
|
||||
CCASSERT(filename != NULL, "");
|
||||
CCASSERT(filename.size()>0, "Invalid filename");
|
||||
|
||||
Texture2D *texture = TextureCache::getInstance()->addImage(filename);
|
||||
if (texture)
|
||||
|
@ -259,9 +259,9 @@ bool Sprite::initWithSpriteFrame(SpriteFrame *spriteFrame)
|
|||
return bRet;
|
||||
}
|
||||
|
||||
bool Sprite::initWithSpriteFrameName(const char *spriteFrameName)
|
||||
bool Sprite::initWithSpriteFrameName(const std::string& spriteFrameName)
|
||||
{
|
||||
CCASSERT(spriteFrameName != NULL, "");
|
||||
CCASSERT(spriteFrameName.size() > 0, "Invalid spriteFrameName");
|
||||
|
||||
SpriteFrame *frame = SpriteFrameCache::getInstance()->getSpriteFrameByName(spriteFrameName);
|
||||
return initWithSpriteFrame(frame);
|
||||
|
@ -992,9 +992,9 @@ void Sprite::setDisplayFrame(SpriteFrame *pNewFrame)
|
|||
setTextureRect(pNewFrame->getRect(), _rectRotated, pNewFrame->getOriginalSize());
|
||||
}
|
||||
|
||||
void Sprite::setDisplayFrameWithAnimationName(const char *animationName, int frameIndex)
|
||||
void Sprite::setDisplayFrameWithAnimationName(const std::string& animationName, int frameIndex)
|
||||
{
|
||||
CCASSERT(animationName, "CCSprite#setDisplayFrameWithAnimationName. animationName must not be NULL");
|
||||
CCASSERT(animationName.size()>0, "CCSprite#setDisplayFrameWithAnimationName. animationName must not be NULL");
|
||||
|
||||
Animation *a = AnimationCache::getInstance()->getAnimation(animationName);
|
||||
|
||||
|
|
|
@ -105,7 +105,7 @@ public:
|
|||
* @param filename The string which indicates a path to image file, e.g., "scene1/monster.png".
|
||||
* @return A valid sprite object that is marked as autoreleased.
|
||||
*/
|
||||
static Sprite* create(const char *filename);
|
||||
static Sprite* create(const std::string& filename);
|
||||
|
||||
/**
|
||||
* Creates a sprite with an image filename and a rect.
|
||||
|
@ -114,7 +114,7 @@ public:
|
|||
* @param rect Only the contents inside rect of filename's texture will be applied for this sprite.
|
||||
* @return A valid sprite object that is marked as autoreleased.
|
||||
*/
|
||||
static Sprite* create(const char *filename, const Rect& rect);
|
||||
static Sprite* create(const std::string& filename, const Rect& rect);
|
||||
|
||||
/**
|
||||
* Creates a sprite with an exsiting texture contained in a Texture2D object
|
||||
|
@ -154,7 +154,7 @@ public:
|
|||
* @param spriteFrameName A null terminated string which indicates the sprite frame name.
|
||||
* @return A valid sprite object that is marked as autoreleased.
|
||||
*/
|
||||
static Sprite* createWithSpriteFrameName(const char *spriteFrameName);
|
||||
static Sprite* createWithSpriteFrameName(const std::string& spriteFrameName);
|
||||
|
||||
/// @} end of creators group
|
||||
|
||||
|
@ -233,7 +233,7 @@ public:
|
|||
* @param spriteFrameName A key string that can fected a volid SpriteFrame from SpriteFrameCache
|
||||
* @return true if the sprite is initialized properly, false otherwise.
|
||||
*/
|
||||
virtual bool initWithSpriteFrameName(const char *spriteFrameName);
|
||||
virtual bool initWithSpriteFrameName(const std::string& spriteFrameName);
|
||||
|
||||
/**
|
||||
* Initializes a sprite with an image filename.
|
||||
|
@ -247,7 +247,7 @@ public:
|
|||
* @js init
|
||||
* @lua init
|
||||
*/
|
||||
virtual bool initWithFile(const char *filename);
|
||||
virtual bool initWithFile(const std::string& filename);
|
||||
|
||||
/**
|
||||
* Initializes a sprite with an image filename, and a rect.
|
||||
|
@ -262,7 +262,7 @@ public:
|
|||
* @js init
|
||||
* @lua init
|
||||
*/
|
||||
virtual bool initWithFile(const char *filename, const Rect& rect);
|
||||
virtual bool initWithFile(const std::string& filename, const Rect& rect);
|
||||
|
||||
/// @} end of initializers
|
||||
|
||||
|
@ -354,7 +354,7 @@ public:
|
|||
* Changes the display frame with animation name and index.
|
||||
* The animation name will be get from the AnimationCache
|
||||
*/
|
||||
virtual void setDisplayFrameWithAnimationName(const char *animationName, int frameIndex);
|
||||
virtual void setDisplayFrameWithAnimationName(const std::string& animationName, int frameIndex);
|
||||
/// @}
|
||||
|
||||
|
||||
|
|
|
@ -31,61 +31,61 @@ NS_CC_BEGIN
|
|||
|
||||
// implementation of SpriteFrame
|
||||
|
||||
SpriteFrame* SpriteFrame::create(const char* filename, const Rect& rect)
|
||||
SpriteFrame* SpriteFrame::create(const std::string& filename, const Rect& rect)
|
||||
{
|
||||
SpriteFrame *pSpriteFrame = new SpriteFrame();;
|
||||
SpriteFrame *pSpriteFrame = new SpriteFrame();
|
||||
pSpriteFrame->initWithTextureFilename(filename, rect);
|
||||
pSpriteFrame->autorelease();
|
||||
|
||||
return pSpriteFrame;
|
||||
}
|
||||
|
||||
SpriteFrame* SpriteFrame::createWithTexture(Texture2D *pobTexture, const Rect& rect)
|
||||
SpriteFrame* SpriteFrame::createWithTexture(Texture2D *texture, const Rect& rect)
|
||||
{
|
||||
SpriteFrame *pSpriteFrame = new SpriteFrame();;
|
||||
pSpriteFrame->initWithTexture(pobTexture, rect);
|
||||
SpriteFrame *pSpriteFrame = new SpriteFrame();
|
||||
pSpriteFrame->initWithTexture(texture, rect);
|
||||
pSpriteFrame->autorelease();
|
||||
|
||||
return pSpriteFrame;
|
||||
}
|
||||
|
||||
SpriteFrame* SpriteFrame::createWithTexture(Texture2D* pobTexture, const Rect& rect, bool rotated, const Point& offset, const Size& originalSize)
|
||||
SpriteFrame* SpriteFrame::createWithTexture(Texture2D* texture, const Rect& rect, bool rotated, const Point& offset, const Size& originalSize)
|
||||
{
|
||||
SpriteFrame *pSpriteFrame = new SpriteFrame();;
|
||||
pSpriteFrame->initWithTexture(pobTexture, rect, rotated, offset, originalSize);
|
||||
SpriteFrame *pSpriteFrame = new SpriteFrame();
|
||||
pSpriteFrame->initWithTexture(texture, rect, rotated, offset, originalSize);
|
||||
pSpriteFrame->autorelease();
|
||||
|
||||
return pSpriteFrame;
|
||||
}
|
||||
|
||||
SpriteFrame* SpriteFrame::create(const char* filename, const Rect& rect, bool rotated, const Point& offset, const Size& originalSize)
|
||||
SpriteFrame* SpriteFrame::create(const std::string& filename, const Rect& rect, bool rotated, const Point& offset, const Size& originalSize)
|
||||
{
|
||||
SpriteFrame *pSpriteFrame = new SpriteFrame();;
|
||||
SpriteFrame *pSpriteFrame = new SpriteFrame();
|
||||
pSpriteFrame->initWithTextureFilename(filename, rect, rotated, offset, originalSize);
|
||||
pSpriteFrame->autorelease();
|
||||
|
||||
return pSpriteFrame;
|
||||
}
|
||||
|
||||
bool SpriteFrame::initWithTexture(Texture2D* pobTexture, const Rect& rect)
|
||||
bool SpriteFrame::initWithTexture(Texture2D* texture, const Rect& rect)
|
||||
{
|
||||
Rect rectInPixels = CC_RECT_POINTS_TO_PIXELS(rect);
|
||||
return initWithTexture(pobTexture, rectInPixels, false, Point::ZERO, rectInPixels.size);
|
||||
return initWithTexture(texture, rectInPixels, false, Point::ZERO, rectInPixels.size);
|
||||
}
|
||||
|
||||
bool SpriteFrame::initWithTextureFilename(const char* filename, const Rect& rect)
|
||||
bool SpriteFrame::initWithTextureFilename(const std::string& filename, const Rect& rect)
|
||||
{
|
||||
Rect rectInPixels = CC_RECT_POINTS_TO_PIXELS( rect );
|
||||
return initWithTextureFilename(filename, rectInPixels, false, Point::ZERO, rectInPixels.size);
|
||||
}
|
||||
|
||||
bool SpriteFrame::initWithTexture(Texture2D* pobTexture, const Rect& rect, bool rotated, const Point& offset, const Size& originalSize)
|
||||
bool SpriteFrame::initWithTexture(Texture2D* texture, const Rect& rect, bool rotated, const Point& offset, const Size& originalSize)
|
||||
{
|
||||
_texture = pobTexture;
|
||||
_texture = texture;
|
||||
|
||||
if (pobTexture)
|
||||
if (texture)
|
||||
{
|
||||
pobTexture->retain();
|
||||
texture->retain();
|
||||
}
|
||||
|
||||
_rectInPixels = rect;
|
||||
|
@ -99,7 +99,7 @@ bool SpriteFrame::initWithTexture(Texture2D* pobTexture, const Rect& rect, bool
|
|||
return true;
|
||||
}
|
||||
|
||||
bool SpriteFrame::initWithTextureFilename(const char* filename, const Rect& rect, bool rotated, const Point& offset, const Size& originalSize)
|
||||
bool SpriteFrame::initWithTextureFilename(const std::string& filename, const Rect& rect, bool rotated, const Point& offset, const Size& originalSize)
|
||||
{
|
||||
_texture = NULL;
|
||||
_textureFilename = filename;
|
||||
|
|
|
@ -58,12 +58,12 @@ public:
|
|||
/** Create a SpriteFrame with a texture filename, rect in points.
|
||||
It is assumed that the frame was not trimmed.
|
||||
*/
|
||||
static SpriteFrame* create(const char* filename, const Rect& rect);
|
||||
static SpriteFrame* create(const std::string& filename, const Rect& rect);
|
||||
|
||||
/** Create a SpriteFrame with a texture filename, rect, rotated, offset and originalSize in pixels.
|
||||
The originalSize is the size in pixels of the frame before being trimmed.
|
||||
*/
|
||||
static SpriteFrame* create(const char* filename, const Rect& rect, bool rotated, const Point& offset, const Size& originalSize);
|
||||
static SpriteFrame* create(const std::string& filename, const Rect& rect, bool rotated, const Point& offset, const Size& originalSize);
|
||||
|
||||
/** Create a SpriteFrame with a texture, rect in points.
|
||||
It is assumed that the frame was not trimmed.
|
||||
|
@ -88,7 +88,7 @@ public:
|
|||
/** Initializes a SpriteFrame with a texture filename, rect in points;
|
||||
It is assumed that the frame was not trimmed.
|
||||
*/
|
||||
bool initWithTextureFilename(const char* filename, const Rect& rect);
|
||||
bool initWithTextureFilename(const std::string& filename, const Rect& rect);
|
||||
|
||||
/** Initializes a SpriteFrame with a texture, rect, rotated, offset and originalSize in pixels.
|
||||
The originalSize is the size in points of the frame before being trimmed.
|
||||
|
@ -100,7 +100,7 @@ public:
|
|||
|
||||
@since v1.1
|
||||
*/
|
||||
bool initWithTextureFilename(const char* filename, const Rect& rect, bool rotated, const Point& offset, const Size& originalSize);
|
||||
bool initWithTextureFilename(const std::string& filename, const Rect& rect, bool rotated, const Point& offset, const Size& originalSize);
|
||||
|
||||
|
||||
// attributes
|
||||
|
|
|
@ -102,11 +102,11 @@ void SpriteFrameCache::addSpriteFramesWithDictionary(Dictionary* dictionary, Tex
|
|||
// check the format
|
||||
CCASSERT(format >=0 && format <= 3, "format is not supported for SpriteFrameCache addSpriteFramesWithDictionary:textureFilename:");
|
||||
|
||||
DictElement* pElement = NULL;
|
||||
CCDICT_FOREACH(framesDict, pElement)
|
||||
DictElement* element = NULL;
|
||||
CCDICT_FOREACH(framesDict, element)
|
||||
{
|
||||
Dictionary* frameDict = static_cast<Dictionary*>(pElement->getObject());
|
||||
std::string spriteFrameName = pElement->getStrKey();
|
||||
Dictionary* frameDict = static_cast<Dictionary*>(element->getObject());
|
||||
std::string spriteFrameName = element->getStrKey();
|
||||
SpriteFrame* spriteFrame = static_cast<SpriteFrame*>(_spriteFrames->objectForKey(spriteFrameName));
|
||||
if (spriteFrame)
|
||||
{
|
||||
|
@ -203,7 +203,7 @@ void SpriteFrameCache::addSpriteFramesWithDictionary(Dictionary* dictionary, Tex
|
|||
}
|
||||
}
|
||||
|
||||
void SpriteFrameCache::addSpriteFramesWithFile(const char *pszPlist, Texture2D *pobTexture)
|
||||
void SpriteFrameCache::addSpriteFramesWithFile(const std::string& pszPlist, Texture2D *pobTexture)
|
||||
{
|
||||
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszPlist);
|
||||
Dictionary *dict = Dictionary::createWithContentsOfFileThreadSafe(fullPath.c_str());
|
||||
|
@ -212,9 +212,9 @@ void SpriteFrameCache::addSpriteFramesWithFile(const char *pszPlist, Texture2D *
|
|||
dict->release();
|
||||
}
|
||||
|
||||
void SpriteFrameCache::addSpriteFramesWithFile(const char* plist, const char* textureFileName)
|
||||
void SpriteFrameCache::addSpriteFramesWithFile(const std::string& plist, const std::string& textureFileName)
|
||||
{
|
||||
CCASSERT(textureFileName, "texture name should not be null");
|
||||
CCASSERT(textureFileName.size()>0, "texture name should not be null");
|
||||
Texture2D *texture = TextureCache::getInstance()->addImage(textureFileName);
|
||||
|
||||
if (texture)
|
||||
|
@ -223,13 +223,13 @@ void SpriteFrameCache::addSpriteFramesWithFile(const char* plist, const char* te
|
|||
}
|
||||
else
|
||||
{
|
||||
CCLOG("cocos2d: SpriteFrameCache: couldn't load texture file. File not found %s", textureFileName);
|
||||
CCLOG("cocos2d: SpriteFrameCache: couldn't load texture file. File not found %s", textureFileName.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void SpriteFrameCache::addSpriteFramesWithFile(const char *pszPlist)
|
||||
void SpriteFrameCache::addSpriteFramesWithFile(const std::string& pszPlist)
|
||||
{
|
||||
CCASSERT(pszPlist, "plist filename should not be NULL");
|
||||
CCASSERT(pszPlist.size()>0, "plist filename should not be NULL");
|
||||
|
||||
if (_loadedFileNames->find(pszPlist) == _loadedFileNames->end())
|
||||
{
|
||||
|
@ -280,7 +280,7 @@ void SpriteFrameCache::addSpriteFramesWithFile(const char *pszPlist)
|
|||
}
|
||||
}
|
||||
|
||||
void SpriteFrameCache::addSpriteFrame(SpriteFrame *pobFrame, const char *pszFrameName)
|
||||
void SpriteFrameCache::addSpriteFrame(SpriteFrame *pobFrame, const std::string& pszFrameName)
|
||||
{
|
||||
_spriteFrames->setObject(pobFrame, pszFrameName);
|
||||
}
|
||||
|
@ -295,14 +295,14 @@ void SpriteFrameCache::removeSpriteFrames(void)
|
|||
void SpriteFrameCache::removeUnusedSpriteFrames(void)
|
||||
{
|
||||
bool bRemoved = false;
|
||||
DictElement* pElement = NULL;
|
||||
CCDICT_FOREACH(_spriteFrames, pElement)
|
||||
DictElement* element = NULL;
|
||||
CCDICT_FOREACH(_spriteFrames, element)
|
||||
{
|
||||
SpriteFrame* spriteFrame = static_cast<SpriteFrame*>(pElement->getObject());
|
||||
SpriteFrame* spriteFrame = static_cast<SpriteFrame*>(element->getObject());
|
||||
if( spriteFrame->retainCount() == 1 )
|
||||
{
|
||||
CCLOG("cocos2d: SpriteFrameCache: removing unused frame: %s", pElement->getStrKey());
|
||||
_spriteFrames->removeObjectForElememt(pElement);
|
||||
CCLOG("cocos2d: SpriteFrameCache: removing unused frame: %s", element->getStrKey());
|
||||
_spriteFrames->removeObjectForElememt(element);
|
||||
bRemoved = true;
|
||||
}
|
||||
}
|
||||
|
@ -315,16 +315,14 @@ void SpriteFrameCache::removeUnusedSpriteFrames(void)
|
|||
}
|
||||
|
||||
|
||||
void SpriteFrameCache::removeSpriteFrameByName(const char *pszName)
|
||||
void SpriteFrameCache::removeSpriteFrameByName(const std::string& name)
|
||||
{
|
||||
// explicit nil handling
|
||||
if( ! pszName )
|
||||
{
|
||||
if( ! name.size()>0 )
|
||||
return;
|
||||
}
|
||||
|
||||
// Is this an alias ?
|
||||
String* key = (String*)_spriteFramesAliases->objectForKey(pszName);
|
||||
String* key = (String*)_spriteFramesAliases->objectForKey(name);
|
||||
|
||||
if (key)
|
||||
{
|
||||
|
@ -333,20 +331,20 @@ void SpriteFrameCache::removeSpriteFrameByName(const char *pszName)
|
|||
}
|
||||
else
|
||||
{
|
||||
_spriteFrames->removeObjectForKey(pszName);
|
||||
_spriteFrames->removeObjectForKey(name);
|
||||
}
|
||||
|
||||
// XXX. Since we don't know the .plist file that originated the frame, we must remove all .plist from the cache
|
||||
_loadedFileNames->clear();
|
||||
}
|
||||
|
||||
void SpriteFrameCache::removeSpriteFramesFromFile(const char* plist)
|
||||
void SpriteFrameCache::removeSpriteFramesFromFile(const std::string& plist)
|
||||
{
|
||||
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(plist);
|
||||
Dictionary* dict = Dictionary::createWithContentsOfFileThreadSafe(fullPath.c_str());
|
||||
if (dict == nullptr)
|
||||
{
|
||||
CCLOG("cocos2d:SpriteFrameCache:removeSpriteFramesFromFile: create dict by %s fail.",plist);
|
||||
CCLOG("cocos2d:SpriteFrameCache:removeSpriteFramesFromFile: create dict by %s fail.",plist.c_str());
|
||||
return;
|
||||
}
|
||||
removeSpriteFramesFromDictionary((Dictionary*)dict);
|
||||
|
@ -365,12 +363,12 @@ void SpriteFrameCache::removeSpriteFramesFromDictionary(Dictionary* dictionary)
|
|||
Dictionary* framesDict = static_cast<Dictionary*>(dictionary->objectForKey("frames"));
|
||||
Array* keysToRemove = Array::create();
|
||||
|
||||
DictElement* pElement = NULL;
|
||||
CCDICT_FOREACH(framesDict, pElement)
|
||||
DictElement* element = NULL;
|
||||
CCDICT_FOREACH(framesDict, element)
|
||||
{
|
||||
if (_spriteFrames->objectForKey(pElement->getStrKey()))
|
||||
if (_spriteFrames->objectForKey(element->getStrKey()))
|
||||
{
|
||||
keysToRemove->addObject(String::create(pElement->getStrKey()));
|
||||
keysToRemove->addObject(String::create(element->getStrKey()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -381,33 +379,33 @@ void SpriteFrameCache::removeSpriteFramesFromTexture(Texture2D* texture)
|
|||
{
|
||||
Array* keysToRemove = Array::create();
|
||||
|
||||
DictElement* pElement = NULL;
|
||||
CCDICT_FOREACH(_spriteFrames, pElement)
|
||||
DictElement* element = NULL;
|
||||
CCDICT_FOREACH(_spriteFrames, element)
|
||||
{
|
||||
string key = pElement->getStrKey();
|
||||
string key = element->getStrKey();
|
||||
SpriteFrame* frame = static_cast<SpriteFrame*>(_spriteFrames->objectForKey(key.c_str()));
|
||||
if (frame && (frame->getTexture() == texture))
|
||||
{
|
||||
keysToRemove->addObject(String::create(pElement->getStrKey()));
|
||||
keysToRemove->addObject(String::create(element->getStrKey()));
|
||||
}
|
||||
}
|
||||
|
||||
_spriteFrames->removeObjectsForKeys(keysToRemove);
|
||||
}
|
||||
|
||||
SpriteFrame* SpriteFrameCache::getSpriteFrameByName(const char *pszName)
|
||||
SpriteFrame* SpriteFrameCache::getSpriteFrameByName(const std::string& name)
|
||||
{
|
||||
SpriteFrame* frame = (SpriteFrame*)_spriteFrames->objectForKey(pszName);
|
||||
SpriteFrame* frame = (SpriteFrame*)_spriteFrames->objectForKey(name);
|
||||
if (!frame)
|
||||
{
|
||||
// try alias dictionary
|
||||
String *key = (String*)_spriteFramesAliases->objectForKey(pszName);
|
||||
String *key = (String*)_spriteFramesAliases->objectForKey(name);
|
||||
if (key)
|
||||
{
|
||||
frame = (SpriteFrame*)_spriteFrames->objectForKey(key->getCString());
|
||||
if (! frame)
|
||||
{
|
||||
CCLOG("cocos2d: SpriteFrameCache: Frame '%s' not found", pszName);
|
||||
CCLOG("cocos2d: SpriteFrameCache: Frame '%s' not found", name.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,29 +85,29 @@ public:
|
|||
public:
|
||||
/** Adds multiple Sprite Frames from a plist file.
|
||||
* A texture will be loaded automatically. The texture name will composed by replacing the .plist suffix with .png
|
||||
* If you want to use another texture, you should use the addSpriteFramesWithFile(const char *plist, const char *textureFileName) method.
|
||||
* If you want to use another texture, you should use the addSpriteFramesWithFile(const std::string& plist, const std::string& textureFileName) method.
|
||||
* @js addSpriteFrames
|
||||
* @lua addSpriteFrames
|
||||
*/
|
||||
void addSpriteFramesWithFile(const char *plist);
|
||||
void addSpriteFramesWithFile(const std::string& plist);
|
||||
|
||||
/** Adds multiple Sprite Frames from a plist file. The texture will be associated with the created sprite frames.
|
||||
@since v0.99.5
|
||||
* @js addSpriteFrames
|
||||
* @lua addSpriteFrames
|
||||
*/
|
||||
void addSpriteFramesWithFile(const char* plist, const char* textureFileName);
|
||||
void addSpriteFramesWithFile(const std::string& plist, const std::string& textureFileName);
|
||||
|
||||
/** Adds multiple Sprite Frames from a plist file. The texture will be associated with the created sprite frames.
|
||||
* @js addSpriteFrames
|
||||
* @lua addSpriteFrames
|
||||
*/
|
||||
void addSpriteFramesWithFile(const char *plist, Texture2D *texture);
|
||||
void addSpriteFramesWithFile(const std::string&plist, Texture2D *texture);
|
||||
|
||||
/** Adds an sprite frame with a given name.
|
||||
If the name already exists, then the contents of the old name will be replaced with the new one.
|
||||
*/
|
||||
void addSpriteFrame(SpriteFrame *frame, const char *frameName);
|
||||
void addSpriteFrame(SpriteFrame *frame, const std::string& frameName);
|
||||
|
||||
/** Purges the dictionary of loaded sprite frames.
|
||||
* Call this method if you receive the "Memory Warning".
|
||||
|
@ -124,14 +124,14 @@ public:
|
|||
void removeUnusedSpriteFrames(void);
|
||||
|
||||
/** Deletes an sprite frame from the sprite frame cache. */
|
||||
void removeSpriteFrameByName(const char *name);
|
||||
void removeSpriteFrameByName(const std::string& name);
|
||||
|
||||
/** Removes multiple Sprite Frames from a plist file.
|
||||
* Sprite Frames stored in this file will be removed.
|
||||
* It is convenient to call this method when a specific texture needs to be removed.
|
||||
* @since v0.99.5
|
||||
*/
|
||||
void removeSpriteFramesFromFile(const char* plist);
|
||||
void removeSpriteFramesFromFile(const std::string& plist);
|
||||
|
||||
/** Removes all Sprite Frames associated with the specified textures.
|
||||
* It is convenient to call this method when a specific texture needs to be removed.
|
||||
|
@ -145,10 +145,10 @@ public:
|
|||
* @js getSpriteFrame
|
||||
* @lua getSpriteFrame
|
||||
*/
|
||||
SpriteFrame* getSpriteFrameByName(const char *name);
|
||||
SpriteFrame* getSpriteFrameByName(const std::string& name);
|
||||
|
||||
/** @deprecated use getSpriteFrameByName() instead */
|
||||
CC_DEPRECATED_ATTRIBUTE SpriteFrame* spriteFrameByName(const char *name) { return getSpriteFrameByName(name); }
|
||||
CC_DEPRECATED_ATTRIBUTE SpriteFrame* spriteFrameByName(const std::string&name) { return getSpriteFrameByName(name); }
|
||||
|
||||
private:
|
||||
/*Adds multiple Sprite Frames with a dictionary. The texture will be associated with the created sprite frames.
|
||||
|
|
|
@ -614,10 +614,10 @@ void VolatileTexture::reloadAllTextures()
|
|||
case kImageFile:
|
||||
{
|
||||
Image* image = new Image();
|
||||
unsigned long nSize = 0;
|
||||
unsigned char* pBuffer = FileUtils::getInstance()->getFileData(vt->_fileName.c_str(), "rb", &nSize);
|
||||
long size = 0;
|
||||
unsigned char* pBuffer = FileUtils::getInstance()->getFileData(vt->_fileName.c_str(), "rb", &size);
|
||||
|
||||
if (image && image->initWithImageData(pBuffer, nSize))
|
||||
if (image && image->initWithImageData(pBuffer, size))
|
||||
{
|
||||
Texture2D::PixelFormat oldPixelFormat = Texture2D::getDefaultAlphaPixelFormat();
|
||||
Texture2D::setDefaultAlphaPixelFormat(vt->_pixelFormat);
|
||||
|
|
|
@ -58,7 +58,7 @@ static tinyxml2::XMLElement* getXMLNodeForKey(const char* pKey, tinyxml2::XMLEle
|
|||
tinyxml2::XMLDocument* xmlDoc = new tinyxml2::XMLDocument();
|
||||
*doc = xmlDoc;
|
||||
//CCFileData data(UserDefault::getInstance()->getXMLFilePath().c_str(),"rt");
|
||||
unsigned long nSize;
|
||||
long nSize;
|
||||
const char* pXmlBuffer = (const char*)FileUtils::getInstance()->getFileData(UserDefault::getInstance()->getXMLFilePath().c_str(), "rb", &nSize);
|
||||
//const char* pXmlBuffer = (const char*)data.getBuffer();
|
||||
if(NULL == pXmlBuffer)
|
||||
|
|
|
@ -73,8 +73,8 @@ static tinyxml2::XMLElement* getXMLNodeForKey(const char* pKey, tinyxml2::XMLDoc
|
|||
{
|
||||
tinyxml2::XMLDocument* xmlDoc = new tinyxml2::XMLDocument();
|
||||
*doc = xmlDoc;
|
||||
unsigned long nSize;
|
||||
const char* pXmlBuffer = (const char*)FileUtils::getInstance()->getFileData(UserDefault::getInstance()->getXMLFilePath().c_str(), "rb", &nSize);
|
||||
long size;
|
||||
const char* pXmlBuffer = (const char*)FileUtils::getInstance()->getFileData(UserDefault::getInstance()->getXMLFilePath().c_str(), "rb", &size);
|
||||
//const char* pXmlBuffer = (const char*)data.getBuffer();
|
||||
if(NULL == pXmlBuffer)
|
||||
{
|
||||
|
|
|
@ -134,9 +134,11 @@ target_link_libraries(cocos2d
|
|||
freetype
|
||||
fontconfig
|
||||
png
|
||||
pthread
|
||||
glfw
|
||||
GLEW
|
||||
GL
|
||||
X11
|
||||
rt
|
||||
z
|
||||
)
|
||||
|
|
|
@ -198,8 +198,8 @@ tImageTGA * tgaLoad(const char *filename)
|
|||
int mode,total;
|
||||
tImageTGA *info = NULL;
|
||||
|
||||
unsigned long nSize = 0;
|
||||
unsigned char* pBuffer = FileUtils::getInstance()->getFileData(filename, "rb", &nSize);
|
||||
long size = 0;
|
||||
unsigned char* pBuffer = FileUtils::getInstance()->getFileData(filename, "rb", &size);
|
||||
|
||||
do
|
||||
{
|
||||
|
@ -207,7 +207,7 @@ tImageTGA * tgaLoad(const char *filename)
|
|||
info = (tImageTGA *)malloc(sizeof(tImageTGA));
|
||||
|
||||
// get the file header info
|
||||
if (! tgaLoadHeader(pBuffer, nSize, info))
|
||||
if (! tgaLoadHeader(pBuffer, size, info))
|
||||
{
|
||||
info->status = TGA_ERROR_MEMORY;
|
||||
break;
|
||||
|
@ -245,11 +245,11 @@ tImageTGA * tgaLoad(const char *filename)
|
|||
// finally load the image pixels
|
||||
if ( info->type == 10 )
|
||||
{
|
||||
bLoadImage = tgaLoadRLEImageData(pBuffer, nSize, info);
|
||||
bLoadImage = tgaLoadRLEImageData(pBuffer, size, info);
|
||||
}
|
||||
else
|
||||
{
|
||||
bLoadImage = tgaLoadImageData(pBuffer, nSize, info);
|
||||
bLoadImage = tgaLoadImageData(pBuffer, size, info);
|
||||
}
|
||||
|
||||
// check for errors when reading the pixels
|
||||
|
|
|
@ -39,7 +39,7 @@ bool ZipUtils::s_bEncryptionKeyIsValid = false;
|
|||
|
||||
// --------------------- ZipUtils ---------------------
|
||||
|
||||
inline void ZipUtils::ccDecodeEncodedPvr(unsigned int *data, int len)
|
||||
inline void ZipUtils::ccDecodeEncodedPvr(unsigned int *data, long len)
|
||||
{
|
||||
const int enclen = 1024;
|
||||
const int securelen = 512;
|
||||
|
@ -108,7 +108,7 @@ inline void ZipUtils::ccDecodeEncodedPvr(unsigned int *data, int len)
|
|||
}
|
||||
}
|
||||
|
||||
inline unsigned int ZipUtils::ccChecksumPvr(const unsigned int *data, int len)
|
||||
inline unsigned int ZipUtils::ccChecksumPvr(const unsigned int *data, long len)
|
||||
{
|
||||
unsigned int cs = 0;
|
||||
const int cslen = 128;
|
||||
|
@ -127,12 +127,12 @@ inline unsigned int ZipUtils::ccChecksumPvr(const unsigned int *data, int len)
|
|||
// Should buffer factor be 1.5 instead of 2 ?
|
||||
#define BUFFER_INC_FACTOR (2)
|
||||
|
||||
int ZipUtils::ccInflateMemoryWithHint(unsigned char *in, unsigned int inLength, unsigned char **out, unsigned int *outLength, unsigned int outLenghtHint)
|
||||
int ZipUtils::ccInflateMemoryWithHint(unsigned char *in, long inLength, unsigned char **out, long *outLength, long outLenghtHint)
|
||||
{
|
||||
/* ret value */
|
||||
int err = Z_OK;
|
||||
|
||||
int bufferSize = outLenghtHint;
|
||||
long bufferSize = outLenghtHint;
|
||||
*out = new unsigned char[bufferSize];
|
||||
|
||||
z_stream d_stream; /* decompression stream */
|
||||
|
@ -192,9 +192,9 @@ int ZipUtils::ccInflateMemoryWithHint(unsigned char *in, unsigned int inLength,
|
|||
return err;
|
||||
}
|
||||
|
||||
int ZipUtils::ccInflateMemoryWithHint(unsigned char *in, unsigned int inLength, unsigned char **out, unsigned int outLengthHint)
|
||||
int ZipUtils::ccInflateMemoryWithHint(unsigned char *in, long inLength, unsigned char **out, long outLengthHint)
|
||||
{
|
||||
unsigned int outLength = 0;
|
||||
long outLength = 0;
|
||||
int err = ccInflateMemoryWithHint(in, inLength, out, &outLength, outLengthHint);
|
||||
|
||||
if (err != Z_OK || *out == NULL) {
|
||||
|
@ -223,7 +223,7 @@ int ZipUtils::ccInflateMemoryWithHint(unsigned char *in, unsigned int inLength,
|
|||
return outLength;
|
||||
}
|
||||
|
||||
int ZipUtils::ccInflateMemory(unsigned char *in, unsigned int inLength, unsigned char **out)
|
||||
int ZipUtils::ccInflateMemory(unsigned char *in, long inLength, unsigned char **out)
|
||||
{
|
||||
// 256k for hint
|
||||
return ccInflateMemoryWithHint(in, inLength, out, 256 * 1024);
|
||||
|
@ -304,7 +304,7 @@ bool ZipUtils::ccIsCCZFile(const char *path)
|
|||
// load file into memory
|
||||
unsigned char* compressed = NULL;
|
||||
|
||||
unsigned long fileLen = 0;
|
||||
long fileLen = 0;
|
||||
compressed = FileUtils::getInstance()->getFileData(path, "rb", &fileLen);
|
||||
|
||||
if(NULL == compressed || 0 == fileLen)
|
||||
|
@ -316,7 +316,7 @@ bool ZipUtils::ccIsCCZFile(const char *path)
|
|||
return ccIsCCZBuffer(compressed, fileLen);
|
||||
}
|
||||
|
||||
bool ZipUtils::ccIsCCZBuffer(const unsigned char *buffer, int len)
|
||||
bool ZipUtils::ccIsCCZBuffer(const unsigned char *buffer, long len)
|
||||
{
|
||||
if (len < sizeof(struct CCZHeader))
|
||||
{
|
||||
|
@ -333,7 +333,7 @@ bool ZipUtils::ccIsGZipFile(const char *path)
|
|||
// load file into memory
|
||||
unsigned char* compressed = NULL;
|
||||
|
||||
unsigned long fileLen = 0;
|
||||
long fileLen = 0;
|
||||
compressed = FileUtils::getInstance()->getFileData(path, "rb", &fileLen);
|
||||
|
||||
if(NULL == compressed || 0 == fileLen)
|
||||
|
@ -345,7 +345,7 @@ bool ZipUtils::ccIsGZipFile(const char *path)
|
|||
return ccIsGZipBuffer(compressed, fileLen);
|
||||
}
|
||||
|
||||
bool ZipUtils::ccIsGZipBuffer(const unsigned char *buffer, int len)
|
||||
bool ZipUtils::ccIsGZipBuffer(const unsigned char *buffer, long len)
|
||||
{
|
||||
if (len < 2)
|
||||
{
|
||||
|
@ -356,7 +356,7 @@ bool ZipUtils::ccIsGZipBuffer(const unsigned char *buffer, int len)
|
|||
}
|
||||
|
||||
|
||||
int ZipUtils::ccInflateCCZBuffer(const unsigned char *buffer, int bufferLen, unsigned char **out)
|
||||
int ZipUtils::ccInflateCCZBuffer(const unsigned char *buffer, long bufferLen, unsigned char **out)
|
||||
{
|
||||
struct CCZHeader *header = (struct CCZHeader*) buffer;
|
||||
|
||||
|
@ -454,7 +454,7 @@ int ZipUtils::ccInflateCCZFile(const char *path, unsigned char **out)
|
|||
// load file into memory
|
||||
unsigned char* compressed = NULL;
|
||||
|
||||
unsigned long fileLen = 0;
|
||||
long fileLen = 0;
|
||||
compressed = FileUtils::getInstance()->getFileData(path, "rb", &fileLen);
|
||||
|
||||
if(NULL == compressed || 0 == fileLen)
|
||||
|
@ -582,7 +582,7 @@ bool ZipFile::fileExists(const std::string &fileName) const
|
|||
return ret;
|
||||
}
|
||||
|
||||
unsigned char *ZipFile::getFileData(const std::string &fileName, unsigned long *pSize)
|
||||
unsigned char *ZipFile::getFileData(const std::string &fileName, long *pSize)
|
||||
{
|
||||
unsigned char * pBuffer = NULL;
|
||||
if (pSize)
|
||||
|
|
|
@ -64,7 +64,7 @@ namespace cocos2d
|
|||
*
|
||||
@since v0.8.1
|
||||
*/
|
||||
static int ccInflateMemory(unsigned char *in, unsigned int inLength, unsigned char **out);
|
||||
static int ccInflateMemory(unsigned char *in, long inLength, unsigned char **out);
|
||||
|
||||
/**
|
||||
* Inflates either zlib or gzip deflated memory. The inflated memory is
|
||||
|
@ -76,7 +76,7 @@ namespace cocos2d
|
|||
*
|
||||
@since v1.0.0
|
||||
*/
|
||||
static int ccInflateMemoryWithHint(unsigned char *in, unsigned int inLength, unsigned char **out, unsigned int outLenghtHint);
|
||||
static int ccInflateMemoryWithHint(unsigned char *in, long inLength, unsigned char **out, long outLenghtHint);
|
||||
|
||||
/** inflates a GZip file into memory
|
||||
*
|
||||
|
@ -100,7 +100,7 @@ namespace cocos2d
|
|||
*
|
||||
* @since v3.0
|
||||
*/
|
||||
static bool ccIsGZipBuffer(const unsigned char *buffer, int len);
|
||||
static bool ccIsGZipBuffer(const unsigned char *buffer, long len);
|
||||
|
||||
/** inflates a CCZ file into memory
|
||||
*
|
||||
|
@ -116,7 +116,7 @@ namespace cocos2d
|
|||
*
|
||||
* @since v3.0
|
||||
*/
|
||||
static int ccInflateCCZBuffer(const unsigned char *buffer, int len, unsigned char **out);
|
||||
static int ccInflateCCZBuffer(const unsigned char *buffer, long len, unsigned char **out);
|
||||
|
||||
/** test a file is a CCZ format file or not
|
||||
*
|
||||
|
@ -132,7 +132,7 @@ namespace cocos2d
|
|||
*
|
||||
* @since v3.0
|
||||
*/
|
||||
static bool ccIsCCZBuffer(const unsigned char *buffer, int len);
|
||||
static bool ccIsCCZBuffer(const unsigned char *buffer, long len);
|
||||
|
||||
/** Sets the pvr.ccz encryption key parts separately for added
|
||||
* security.
|
||||
|
@ -187,10 +187,10 @@ namespace cocos2d
|
|||
static void ccSetPvrEncryptionKey(unsigned int keyPart1, unsigned int keyPart2, unsigned int keyPart3, unsigned int keyPart4);
|
||||
|
||||
private:
|
||||
static int ccInflateMemoryWithHint(unsigned char *in, unsigned int inLength, unsigned char **out, unsigned int *outLength,
|
||||
unsigned int outLenghtHint);
|
||||
static inline void ccDecodeEncodedPvr (unsigned int *data, int len);
|
||||
static inline unsigned int ccChecksumPvr(const unsigned int *data, int len);
|
||||
static int ccInflateMemoryWithHint(unsigned char *in, long inLength, unsigned char **out, long *outLength,
|
||||
long outLenghtHint);
|
||||
static inline void ccDecodeEncodedPvr (unsigned int *data, long len);
|
||||
static inline unsigned int ccChecksumPvr(const unsigned int *data, long len);
|
||||
|
||||
static unsigned int s_uEncryptedPvrKeyParts[4];
|
||||
static unsigned int s_uEncryptionKey[1024];
|
||||
|
@ -253,7 +253,7 @@ namespace cocos2d
|
|||
*
|
||||
* @since v2.0.5
|
||||
*/
|
||||
unsigned char *getFileData(const std::string &fileName, unsigned long *pSize);
|
||||
unsigned char *getFileData(const std::string &fileName, long *size);
|
||||
|
||||
private:
|
||||
/** Internal data like zip file pointer / file list array and so on */
|
||||
|
|
|
@ -488,7 +488,7 @@ void FileUtils::purgeCachedEntries()
|
|||
_fullPathCache.clear();
|
||||
}
|
||||
|
||||
unsigned char* FileUtils::getFileData(const char* filename, const char* mode, unsigned long * size)
|
||||
unsigned char* FileUtils::getFileData(const char* filename, const char* mode, long *size)
|
||||
{
|
||||
unsigned char * buffer = NULL;
|
||||
CCASSERT(filename != NULL && size != NULL && mode != NULL, "Invalid parameters.");
|
||||
|
@ -518,7 +518,7 @@ unsigned char* FileUtils::getFileData(const char* filename, const char* mode, un
|
|||
return buffer;
|
||||
}
|
||||
|
||||
unsigned char* FileUtils::getFileDataFromZip(const char* zipFilePath, const char* filename, unsigned long * size)
|
||||
unsigned char* FileUtils::getFileDataFromZip(const char* zipFilePath, const char* filename, long *size)
|
||||
{
|
||||
unsigned char * buffer = NULL;
|
||||
unzFile pFile = NULL;
|
||||
|
|
|
@ -88,7 +88,7 @@ public:
|
|||
* @return Upon success, a pointer to the data is returned, otherwise NULL.
|
||||
* @warning Recall: you are responsible for calling delete[] on any Non-NULL pointer returned.
|
||||
*/
|
||||
virtual unsigned char* getFileData(const char* filename, const char* mode, unsigned long * size);
|
||||
virtual unsigned char* getFileData(const char* filename, const char* mode, long *size);
|
||||
|
||||
/**
|
||||
* Gets resource file data from a zip file.
|
||||
|
@ -98,7 +98,7 @@ public:
|
|||
* @return Upon success, a pointer to the data is returned, otherwise NULL.
|
||||
* @warning Recall: you are responsible for calling delete[] on any Non-NULL pointer returned.
|
||||
*/
|
||||
virtual unsigned char* getFileDataFromZip(const char* zipFilePath, const char* filename, unsigned long *size);
|
||||
virtual unsigned char* getFileDataFromZip(const char* zipFilePath, const char* filename, long *size);
|
||||
|
||||
|
||||
/** Returns the fullpath for a given filename.
|
||||
|
|
|
@ -119,10 +119,10 @@ public:
|
|||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
bool initWithImageData(const unsigned char * data, int dataLen);
|
||||
bool initWithImageData(const unsigned char * data, long dataLen);
|
||||
|
||||
// @warning kFmtRawData only support RGBA8888
|
||||
bool initWithRawData(const unsigned char * data, int dataLen, int width, int height, int bitsPerComponent, bool preMulti = false);
|
||||
bool initWithRawData(const unsigned char * data, long dataLen, long width, long height, long bitsPerComponent, bool preMulti = false);
|
||||
|
||||
/**
|
||||
@brief Create image with specified string.
|
||||
|
|
|
@ -416,7 +416,7 @@ bool Image::initWithImageFile(const char * strPath)
|
|||
|
||||
SDL_FreeSurface(iSurf);
|
||||
#else
|
||||
unsigned long bufferLen = 0;
|
||||
long bufferLen = 0;
|
||||
unsigned char* buffer = FileUtils::getInstance()->getFileData(fullPath.c_str(), "rb", &bufferLen);
|
||||
|
||||
if (buffer != nullptr && bufferLen > 0)
|
||||
|
@ -432,23 +432,23 @@ bool Image::initWithImageFile(const char * strPath)
|
|||
|
||||
bool Image::initWithImageFileThreadSafe(const char *fullpath)
|
||||
{
|
||||
bool bRet = false;
|
||||
unsigned long dataLen = 0;
|
||||
bool ret = false;
|
||||
long dataLen = 0;
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
FileUtilsAndroid *fileUitls = (FileUtilsAndroid*)FileUtils::getInstance();
|
||||
unsigned char *pBuffer = fileUitls->getFileDataForAsync(fullpath, "rb", &dataLen);
|
||||
unsigned char *buffer = fileUitls->getFileDataForAsync(fullpath, "rb", &dataLen);
|
||||
#else
|
||||
unsigned char *pBuffer = FileUtils::getInstance()->getFileData(fullpath, "rb", &dataLen);
|
||||
unsigned char *buffer = FileUtils::getInstance()->getFileData(fullpath, "rb", &dataLen);
|
||||
#endif
|
||||
if (pBuffer != NULL && dataLen > 0)
|
||||
if (buffer != NULL && dataLen > 0)
|
||||
{
|
||||
bRet = initWithImageData(pBuffer, dataLen);
|
||||
ret = initWithImageData(buffer, dataLen);
|
||||
}
|
||||
CC_SAFE_DELETE_ARRAY(pBuffer);
|
||||
return bRet;
|
||||
CC_SAFE_DELETE_ARRAY(buffer);
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool Image::initWithImageData(const unsigned char * data, int dataLen)
|
||||
bool Image::initWithImageData(const unsigned char * data, long dataLen)
|
||||
{
|
||||
bool ret = false;
|
||||
|
||||
|
@ -1190,13 +1190,13 @@ bool Image::initWithPVRv2Data(const unsigned char * data, int dataLen)
|
|||
|
||||
if (!testFormatForPvr2TCSupport(formatFlags))
|
||||
{
|
||||
CCLOG("cocos2d: WARNING: Unsupported PVR Pixel Format: 0x%02X. Re-encode it with a OpenGL pixel format variant", formatFlags);
|
||||
CCLOG("cocos2d: WARNING: Unsupported PVR Pixel Format: 0x%02X. Re-encode it with a OpenGL pixel format variant", (int)formatFlags);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (v2_pixel_formathash.find(formatFlags) == v2_pixel_formathash.end())
|
||||
{
|
||||
CCLOG("cocos2d: WARNING: Unsupported PVR Pixel Format: 0x%02X. Re-encode it with a OpenGL pixel format variant", formatFlags);
|
||||
CCLOG("cocos2d: WARNING: Unsupported PVR Pixel Format: 0x%02X. Re-encode it with a OpenGL pixel format variant", (int)formatFlags);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1204,7 +1204,7 @@ bool Image::initWithPVRv2Data(const unsigned char * data, int dataLen)
|
|||
|
||||
if (it == Texture2D::getPixelFormatInfoMap().end())
|
||||
{
|
||||
CCLOG("cocos2d: WARNING: Unsupported PVR Pixel Format: 0x%02X. Re-encode it with a OpenGL pixel format variant", formatFlags);
|
||||
CCLOG("cocos2d: WARNING: Unsupported PVR Pixel Format: 0x%02X. Re-encode it with a OpenGL pixel format variant", (int)formatFlags);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1757,7 +1757,7 @@ bool Image::initWithWebpData(const unsigned char * data, int dataLen)
|
|||
return bRet;
|
||||
}
|
||||
|
||||
bool Image::initWithRawData(const unsigned char * data, int dataLen, int width, int height, int bitsPerComponent, bool preMulti)
|
||||
bool Image::initWithRawData(const unsigned char * data, long dataLen, long width, long height, long bitsPerComponent, bool preMulti)
|
||||
{
|
||||
bool bRet = false;
|
||||
do
|
||||
|
|
|
@ -114,15 +114,15 @@ bool SAXParser::parse(const char* pXMLData, unsigned int uDataLength)
|
|||
|
||||
bool SAXParser::parse(const char *pszFile)
|
||||
{
|
||||
bool bRet = false;
|
||||
unsigned long size = 0;
|
||||
bool ret = false;
|
||||
long size = 0;
|
||||
char* pBuffer = (char*)FileUtils::getInstance()->getFileData(pszFile, "rt", &size);
|
||||
if (pBuffer != NULL && size > 0)
|
||||
{
|
||||
bRet = parse(pBuffer, size);
|
||||
ret = parse(pBuffer, size);
|
||||
}
|
||||
CC_SAFE_DELETE_ARRAY(pBuffer);
|
||||
return bRet;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void SAXParser::startElement(void *ctx, const CC_XML_CHAR *name, const CC_XML_CHAR **atts)
|
||||
|
|
|
@ -292,7 +292,7 @@ static void engine_term_display(struct engine* engine) {
|
|||
/*
|
||||
* Get X, Y positions and ID's for all pointers
|
||||
*/
|
||||
static void getTouchPos(AInputEvent *event, int ids[], float xs[], float ys[]) {
|
||||
static void getTouchPos(AInputEvent *event, long ids[], float xs[], float ys[]) {
|
||||
int pointerCount = AMotionEvent_getPointerCount(event);
|
||||
for(int i = 0; i < pointerCount; ++i) {
|
||||
ids[i] = AMotionEvent_getPointerId(event, i);
|
||||
|
@ -321,7 +321,7 @@ static int32_t handle_touch_input(AInputEvent *event) {
|
|||
|
||||
LOG_EVENTS_DEBUG("Event: Action DOWN x=%f y=%f pointerID=%d\n",
|
||||
xP, yP, pointerId);
|
||||
int pId = pointerId;
|
||||
long pId = pointerId;
|
||||
float x = xP;
|
||||
float y = yP;
|
||||
|
||||
|
@ -340,7 +340,7 @@ static int32_t handle_touch_input(AInputEvent *event) {
|
|||
|
||||
LOG_EVENTS_DEBUG("Event: Action POINTER DOWN x=%f y=%f pointerID=%d\n",
|
||||
xP, yP, pointerId);
|
||||
int pId = pointerId;
|
||||
long pId = pointerId;
|
||||
float x = xP;
|
||||
float y = yP;
|
||||
|
||||
|
@ -353,10 +353,10 @@ static int32_t handle_touch_input(AInputEvent *event) {
|
|||
{
|
||||
LOG_EVENTS_DEBUG("AMOTION_EVENT_ACTION_MOVE");
|
||||
int pointerCount = AMotionEvent_getPointerCount(event);
|
||||
int ids[pointerCount];
|
||||
long ids[pointerCount];
|
||||
float xs[pointerCount], ys[pointerCount];
|
||||
getTouchPos(event, ids, xs, ys);
|
||||
cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesMove(pointerCount, ids, xs, ys);
|
||||
cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesMove(pointerCount, ids, xs, ys);
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
|
@ -369,7 +369,7 @@ static int32_t handle_touch_input(AInputEvent *event) {
|
|||
float yP = AMotionEvent_getY(event,0);
|
||||
LOG_EVENTS_DEBUG("Event: Action UP x=%f y=%f pointerID=%d\n",
|
||||
xP, yP, pointerId);
|
||||
int pId = pointerId;
|
||||
long pId = pointerId;
|
||||
float x = xP;
|
||||
float y = yP;
|
||||
|
||||
|
@ -387,7 +387,7 @@ static int32_t handle_touch_input(AInputEvent *event) {
|
|||
float yP = AMotionEvent_getY(event,pointerIndex);
|
||||
LOG_EVENTS_DEBUG("Event: Action POINTER UP x=%f y=%f pointerID=%d\n",
|
||||
xP, yP, pointerIndex);
|
||||
int pId = pointerId;
|
||||
long pId = pointerId;
|
||||
float x = xP;
|
||||
float y = yP;
|
||||
|
||||
|
@ -400,10 +400,10 @@ static int32_t handle_touch_input(AInputEvent *event) {
|
|||
{
|
||||
LOG_EVENTS_DEBUG("AMOTION_EVENT_ACTION_CANCEL");
|
||||
int pointerCount = AMotionEvent_getPointerCount(event);
|
||||
int ids[pointerCount];
|
||||
long ids[pointerCount];
|
||||
float xs[pointerCount], ys[pointerCount];
|
||||
getTouchPos(event, ids, xs, ys);
|
||||
cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesCancel(pointerCount, ids, xs, ys);
|
||||
cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesCancel(pointerCount, ids, xs, ys);
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -7,8 +7,14 @@ add_library(audio STATIC
|
|||
${AUDIO_SRC}
|
||||
)
|
||||
|
||||
if ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
|
||||
set(FMOD_LIB "fmodex64")
|
||||
else()
|
||||
set(FMOD_LIB "fmodex")
|
||||
endif()
|
||||
|
||||
target_link_libraries(audio
|
||||
fmodex64
|
||||
${FMOD_LIB}
|
||||
)
|
||||
|
||||
set_target_properties(audio
|
||||
|
|
|
@ -216,15 +216,15 @@ bool String::isEqual(const Object* pObject)
|
|||
|
||||
String* String::create(const std::string& str)
|
||||
{
|
||||
String* pRet = new String(str);
|
||||
pRet->autorelease();
|
||||
return pRet;
|
||||
String* ret = new String(str);
|
||||
ret->autorelease();
|
||||
return ret;
|
||||
}
|
||||
|
||||
String* String::createWithData(const unsigned char* pData, unsigned long nLen)
|
||||
String* String::createWithData(const unsigned char* data, unsigned long nLen)
|
||||
{
|
||||
String* pRet = NULL;
|
||||
if (pData != NULL)
|
||||
String* ret = NULL;
|
||||
if (data != NULL)
|
||||
{
|
||||
char* pStr = (char*)malloc(nLen+1);
|
||||
if (pStr != NULL)
|
||||
|
@ -232,36 +232,36 @@ String* String::createWithData(const unsigned char* pData, unsigned long nLen)
|
|||
pStr[nLen] = '\0';
|
||||
if (nLen > 0)
|
||||
{
|
||||
memcpy(pStr, pData, nLen);
|
||||
memcpy(pStr, data, nLen);
|
||||
}
|
||||
|
||||
pRet = String::create(pStr);
|
||||
ret = String::create(pStr);
|
||||
free(pStr);
|
||||
}
|
||||
}
|
||||
return pRet;
|
||||
return ret;
|
||||
}
|
||||
|
||||
String* String::createWithFormat(const char* format, ...)
|
||||
{
|
||||
String* pRet = String::create("");
|
||||
String* ret = String::create("");
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
pRet->initWithFormatAndValist(format, ap);
|
||||
ret->initWithFormatAndValist(format, ap);
|
||||
va_end(ap);
|
||||
|
||||
return pRet;
|
||||
return ret;
|
||||
}
|
||||
|
||||
String* String::createWithContentsOfFile(const char* filename)
|
||||
{
|
||||
unsigned long size = 0;
|
||||
unsigned char* pData = 0;
|
||||
String* pRet = NULL;
|
||||
pData = FileUtils::getInstance()->getFileData(filename, "rb", &size);
|
||||
pRet = String::createWithData(pData, size);
|
||||
CC_SAFE_DELETE_ARRAY(pData);
|
||||
return pRet;
|
||||
long size = 0;
|
||||
unsigned char* data = 0;
|
||||
String* ret = NULL;
|
||||
data = FileUtils::getInstance()->getFileData(filename, "rb", &size);
|
||||
ret = String::createWithData(data, size);
|
||||
CC_SAFE_DELETE_ARRAY(data);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void String::acceptVisitor(DataVisitor &visitor)
|
||||
|
|
|
@ -244,7 +244,7 @@ Node* CCBReader::readNodeGraphFromFile(const char *pCCBFileName, Object *pOwner,
|
|||
}
|
||||
|
||||
std::string strPath = FileUtils::getInstance()->fullPathForFilename(strCCBFileName.c_str());
|
||||
unsigned long size = 0;
|
||||
long size = 0;
|
||||
|
||||
unsigned char * pBytes = FileUtils::getInstance()->getFileData(strPath.c_str(), "rb", &size);
|
||||
Data *data = new Data(pBytes, size);
|
||||
|
|
|
@ -918,7 +918,7 @@ Node * NodeLoader::parsePropTypeCCBFile(Node * pNode, Node * pParent, CCBReader
|
|||
|
||||
// Load sub file
|
||||
std::string path = FileUtils::getInstance()->fullPathForFilename(ccbFileName.c_str());
|
||||
unsigned long size = 0;
|
||||
long size = 0;
|
||||
unsigned char * pBytes = FileUtils::getInstance()->getFileData(path.c_str(), "rb", &size);
|
||||
|
||||
CCBReader * reader = new CCBReader(pCCBReader);
|
||||
|
|
|
@ -49,7 +49,7 @@ Armature *Armature::create()
|
|||
return armature;
|
||||
}
|
||||
CC_SAFE_DELETE(armature);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
@ -62,7 +62,7 @@ Armature *Armature::create(const char *name)
|
|||
return armature;
|
||||
}
|
||||
CC_SAFE_DELETE(armature);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Armature *Armature::create(const char *name, Bone *parentBone)
|
||||
|
@ -74,41 +74,43 @@ Armature *Armature::create(const char *name, Bone *parentBone)
|
|||
return armature;
|
||||
}
|
||||
CC_SAFE_DELETE(armature);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Armature::Armature()
|
||||
: _armatureData(NULL)
|
||||
, _batchNode(NULL)
|
||||
, _atlas(NULL)
|
||||
, _parentBone(NULL)
|
||||
: _armatureData(nullptr)
|
||||
, _batchNode(nullptr)
|
||||
, _atlas(nullptr)
|
||||
, _parentBone(nullptr)
|
||||
, _armatureTransformDirty(true)
|
||||
, _boneDic(NULL)
|
||||
, _topBoneList(NULL)
|
||||
, _animation(NULL)
|
||||
, _boneDic(nullptr)
|
||||
, _topBoneList(nullptr)
|
||||
, _animation(nullptr)
|
||||
, _textureAtlasDic(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Armature::~Armature(void)
|
||||
{
|
||||
if(NULL != _boneDic)
|
||||
if(nullptr != _boneDic)
|
||||
{
|
||||
_boneDic->removeAllObjects();
|
||||
CC_SAFE_DELETE(_boneDic);
|
||||
}
|
||||
if (NULL != _topBoneList)
|
||||
if (nullptr != _topBoneList)
|
||||
{
|
||||
_topBoneList->removeAllObjects();
|
||||
CC_SAFE_DELETE(_topBoneList);
|
||||
}
|
||||
CC_SAFE_DELETE(_animation);
|
||||
CC_SAFE_RELEASE_NULL(_textureAtlasDic);
|
||||
}
|
||||
|
||||
|
||||
bool Armature::init()
|
||||
{
|
||||
return init(NULL);
|
||||
return init(nullptr);
|
||||
}
|
||||
|
||||
|
||||
|
@ -130,12 +132,14 @@ bool Armature::init(const char *name)
|
|||
_topBoneList = new Array();
|
||||
_topBoneList->init();
|
||||
|
||||
CC_SAFE_DELETE(_textureAtlasDic);
|
||||
_textureAtlasDic = new Dictionary();
|
||||
|
||||
_blendFunc.src = CC_BLEND_SRC;
|
||||
_blendFunc.dst = CC_BLEND_DST;
|
||||
|
||||
|
||||
_name = name == NULL ? "" : name;
|
||||
_name = name == nullptr ? "" : name;
|
||||
|
||||
ArmatureDataManager *armatureDataManager = ArmatureDataManager::getInstance();
|
||||
|
||||
|
@ -155,7 +159,7 @@ bool Armature::init(const char *name)
|
|||
_armatureData = armatureData;
|
||||
|
||||
|
||||
DictElement *_element = NULL;
|
||||
DictElement *_element = nullptr;
|
||||
Dictionary *boneDataDic = &armatureData->boneDataDic;
|
||||
CCDICT_FOREACH(boneDataDic, _element)
|
||||
{
|
||||
|
@ -224,13 +228,13 @@ bool Armature::init(const char *name, Bone *parentBone)
|
|||
Bone *Armature::createBone(const char *boneName)
|
||||
{
|
||||
Bone *existedBone = getBone(boneName);
|
||||
if(existedBone != NULL)
|
||||
if(existedBone != nullptr)
|
||||
return existedBone;
|
||||
|
||||
BoneData *boneData = (BoneData *)_armatureData->getBoneData(boneName);
|
||||
std::string parentName = boneData->parentName;
|
||||
|
||||
Bone *bone = NULL;
|
||||
Bone *bone = nullptr;
|
||||
|
||||
if( parentName.length() != 0 )
|
||||
{
|
||||
|
@ -253,10 +257,10 @@ Bone *Armature::createBone(const char *boneName)
|
|||
|
||||
void Armature::addBone(Bone *bone, const char *parentName)
|
||||
{
|
||||
CCASSERT( bone != NULL, "Argument must be non-nil");
|
||||
CCASSERT(_boneDic->objectForKey(bone->getName()) == NULL, "bone already added. It can't be added again");
|
||||
CCASSERT( bone != nullptr, "Argument must be non-nil");
|
||||
CCASSERT(_boneDic->objectForKey(bone->getName()) == nullptr, "bone already added. It can't be added again");
|
||||
|
||||
if (NULL != parentName)
|
||||
if (nullptr != parentName)
|
||||
{
|
||||
Bone *boneParent = (Bone *)_boneDic->objectForKey(parentName);
|
||||
if (boneParent)
|
||||
|
@ -265,18 +269,12 @@ void Armature::addBone(Bone *bone, const char *parentName)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (_parentBone)
|
||||
_parentBone->addChildBone(bone);
|
||||
else
|
||||
_topBoneList->addObject(bone);
|
||||
_topBoneList->addObject(bone);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_parentBone)
|
||||
_parentBone->addChildBone(bone);
|
||||
else
|
||||
_topBoneList->addObject(bone);
|
||||
_topBoneList->addObject(bone);
|
||||
}
|
||||
|
||||
bone->setArmature(this);
|
||||
|
@ -288,9 +286,9 @@ void Armature::addBone(Bone *bone, const char *parentName)
|
|||
|
||||
void Armature::removeBone(Bone *bone, bool recursion)
|
||||
{
|
||||
CCASSERT(bone != NULL, "bone must be added to the bone dictionary!");
|
||||
CCASSERT(bone != nullptr, "bone must be added to the bone dictionary!");
|
||||
|
||||
bone->setArmature(NULL);
|
||||
bone->setArmature(nullptr);
|
||||
bone->removeFromParent(recursion);
|
||||
|
||||
if (_topBoneList->containsObject(bone))
|
||||
|
@ -310,15 +308,15 @@ Bone *Armature::getBone(const char *name) const
|
|||
|
||||
void Armature::changeBoneParent(Bone *bone, const char *parentName)
|
||||
{
|
||||
CCASSERT(bone != NULL, "bone must be added to the bone dictionary!");
|
||||
CCASSERT(bone != nullptr, "bone must be added to the bone dictionary!");
|
||||
|
||||
if(bone->getParentBone())
|
||||
{
|
||||
bone->getParentBone()->getChildren()->removeObject(bone);
|
||||
bone->setParentBone(NULL);
|
||||
bone->setParentBone(nullptr);
|
||||
}
|
||||
|
||||
if (parentName != NULL)
|
||||
if (parentName != nullptr)
|
||||
{
|
||||
Bone *boneParent = (Bone *)_boneDic->objectForKey(parentName);
|
||||
|
||||
|
@ -337,7 +335,7 @@ void Armature::changeBoneParent(Bone *bone, const char *parentName)
|
|||
}
|
||||
}
|
||||
|
||||
Dictionary *Armature::getBoneDic()
|
||||
Dictionary *Armature::getBoneDic() const
|
||||
{
|
||||
return _boneDic;
|
||||
}
|
||||
|
@ -439,12 +437,12 @@ void Armature::setAnimation(ArmatureAnimation *animation)
|
|||
_animation = animation;
|
||||
}
|
||||
|
||||
ArmatureAnimation *Armature::getAnimation()
|
||||
ArmatureAnimation *Armature::getAnimation() const
|
||||
{
|
||||
return _animation;
|
||||
}
|
||||
|
||||
bool Armature::getArmatureTransformDirty()
|
||||
bool Armature::getArmatureTransformDirty() const
|
||||
{
|
||||
return _armatureTransformDirty;
|
||||
}
|
||||
|
@ -453,8 +451,7 @@ void Armature::update(float dt)
|
|||
{
|
||||
_animation->update(dt);
|
||||
|
||||
Object *object = NULL;
|
||||
CCARRAY_FOREACH(_topBoneList, object)
|
||||
for (auto object : *_topBoneList)
|
||||
{
|
||||
static_cast<Bone*>(object)->update(dt);
|
||||
}
|
||||
|
@ -464,24 +461,22 @@ void Armature::update(float dt)
|
|||
|
||||
void Armature::draw()
|
||||
{
|
||||
if (_parentBone == NULL)
|
||||
if (_parentBone == nullptr && _batchNode == nullptr)
|
||||
{
|
||||
CC_NODE_DRAW_SETUP();
|
||||
GL::blendFunc(_blendFunc.src, _blendFunc.dst);
|
||||
}
|
||||
|
||||
Object *object = NULL;
|
||||
CCARRAY_FOREACH(_children, object)
|
||||
for (auto object : *_children)
|
||||
{
|
||||
if (Bone *bone = dynamic_cast<Bone *>(object))
|
||||
{
|
||||
DisplayManager *displayManager = bone->getDisplayManager();
|
||||
Node *node = displayManager->getDisplayRenderNode();
|
||||
Node *node = bone->getDisplayRenderNode();
|
||||
|
||||
if (NULL == node)
|
||||
if (nullptr == node)
|
||||
continue;
|
||||
|
||||
switch (displayManager->getCurrentDecorativeDisplay()->getDisplayData()->displayType)
|
||||
switch (bone->getDisplayRenderNodeType())
|
||||
{
|
||||
case CS_DISPLAY_SPRITE:
|
||||
{
|
||||
|
@ -527,6 +522,7 @@ void Armature::draw()
|
|||
}
|
||||
}
|
||||
armature->draw();
|
||||
_atlas = armature->getTextureAtlas();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -558,7 +554,7 @@ void Armature::draw()
|
|||
}
|
||||
}
|
||||
|
||||
if(_atlas && !_batchNode && _parentBone == NULL)
|
||||
if(_atlas && !_batchNode && _parentBone == nullptr)
|
||||
{
|
||||
_atlas->drawQuads();
|
||||
_atlas->removeAllQuads();
|
||||
|
@ -644,8 +640,7 @@ Rect Armature::getBoundingBox() const
|
|||
|
||||
Rect boundingBox = Rect(0, 0, 0, 0);
|
||||
|
||||
Object *object = NULL;
|
||||
CCARRAY_FOREACH(_children, object)
|
||||
for(auto object : *_children)
|
||||
{
|
||||
if (Bone *bone = dynamic_cast<Bone *>(object))
|
||||
{
|
||||
|
@ -672,10 +667,10 @@ Rect Armature::getBoundingBox() const
|
|||
}
|
||||
}
|
||||
|
||||
return boundingBox;
|
||||
return RectApplyAffineTransform(boundingBox, getNodeToParentTransform());
|
||||
}
|
||||
|
||||
Bone *Armature::getBoneAtPoint(float x, float y)
|
||||
Bone *Armature::getBoneAtPoint(float x, float y) const
|
||||
{
|
||||
int length = _children->count();
|
||||
Bone *bs;
|
||||
|
@ -688,11 +683,60 @@ Bone *Armature::getBoneAtPoint(float x, float y)
|
|||
return bs;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
TextureAtlas *Armature::getTexureAtlasWithTexture(Texture2D *texture) const
|
||||
{
|
||||
int key = texture->getName();
|
||||
|
||||
if (_parentBone && _parentBone->getArmature())
|
||||
{
|
||||
return _parentBone->getArmature()->getTexureAtlasWithTexture(texture);
|
||||
}
|
||||
else if (_batchNode)
|
||||
{
|
||||
_batchNode->getTexureAtlasWithTexture(texture);
|
||||
}
|
||||
|
||||
TextureAtlas *atlas = static_cast<TextureAtlas *>(_textureAtlasDic->objectForKey(key));
|
||||
if (atlas == nullptr)
|
||||
{
|
||||
atlas = TextureAtlas::createWithTexture(texture, 4);
|
||||
_textureAtlasDic->setObject(atlas, key);
|
||||
}
|
||||
return atlas;
|
||||
}
|
||||
|
||||
void Armature::setParentBone(Bone *parentBone)
|
||||
{
|
||||
_parentBone = parentBone;
|
||||
|
||||
DictElement *element = nullptr;
|
||||
CCDICT_FOREACH(_boneDic, element)
|
||||
{
|
||||
Bone *bone = static_cast<Bone*>(element->getObject());
|
||||
bone->setArmature(this);
|
||||
}
|
||||
}
|
||||
|
||||
Bone *Armature::getParentBone() const
|
||||
{
|
||||
return _parentBone;
|
||||
}
|
||||
|
||||
void CCArmature::setColliderFilter(ColliderFilter *filter)
|
||||
{
|
||||
DictElement *element = nullptr;
|
||||
CCDICT_FOREACH(_boneDic, element)
|
||||
{
|
||||
Bone *bone = static_cast<Bone*>(element->getObject());
|
||||
bone->setColliderFilter(filter);
|
||||
}
|
||||
}
|
||||
|
||||
#if ENABLE_PHYSICS_BOX2D_DETECT
|
||||
b2Body *Armature::getBody()
|
||||
b2Body *Armature::getBody() const
|
||||
{
|
||||
return _body;
|
||||
}
|
||||
|
@ -707,18 +751,16 @@ void Armature::setBody(b2Body *body)
|
|||
_body = body;
|
||||
_body->SetUserData(this);
|
||||
|
||||
Object *object = NULL;
|
||||
CCARRAY_FOREACH(_children, object)
|
||||
for(auto object : *_children)
|
||||
{
|
||||
if (Bone *bone = dynamic_cast<Bone *>(object))
|
||||
{
|
||||
Array *displayList = bone->getDisplayManager()->getDecorativeDisplayList();
|
||||
|
||||
Object *displayObject = NULL;
|
||||
CCARRAY_FOREACH(displayList, displayObject)
|
||||
for(auto displayObject : displayList)
|
||||
{
|
||||
ColliderDetector *detector = ((DecorativeDisplay *)displayObject)->getColliderDetector();
|
||||
if (detector != NULL)
|
||||
ColliderDetector *detector = static_cast<DecorativeDisplay *>(displayObject)->getColliderDetector();
|
||||
if (detector != nullptr)
|
||||
{
|
||||
detector->setBody(_body);
|
||||
}
|
||||
|
@ -735,12 +777,12 @@ b2Fixture *Armature::getShapeList()
|
|||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
#elif ENABLE_PHYSICS_CHIPMUNK_DETECT
|
||||
cpBody *Armature::getBody()
|
||||
cpBody *Armature::getBody() const
|
||||
{
|
||||
return _body;
|
||||
}
|
||||
|
@ -755,18 +797,16 @@ void Armature::setBody(cpBody *body)
|
|||
_body = body;
|
||||
_body->data = this;
|
||||
|
||||
Object *object = NULL;
|
||||
CCARRAY_FOREACH(_children, object)
|
||||
for(auto object: *_children)
|
||||
{
|
||||
if (Bone *bone = dynamic_cast<Bone *>(object))
|
||||
{
|
||||
Array *displayList = bone->getDisplayManager()->getDecorativeDisplayList();
|
||||
|
||||
Object *displayObject = NULL;
|
||||
CCARRAY_FOREACH(displayList, displayObject)
|
||||
for(auto displayObject: *displayList)
|
||||
{
|
||||
ColliderDetector *detector = ((DecorativeDisplay *)displayObject)->getColliderDetector();
|
||||
if (detector != NULL)
|
||||
ColliderDetector *detector = static_cast<DecorativeDisplay *>(displayObject)->getColliderDetector();
|
||||
if (detector != nullptr)
|
||||
{
|
||||
detector->setBody(_body);
|
||||
}
|
||||
|
@ -783,7 +823,7 @@ cpShape *Armature::getShapeList()
|
|||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -65,6 +65,7 @@ CC_DEPRECATED_ATTRIBUTE typedef Bone CCBone;
|
|||
CC_DEPRECATED_ATTRIBUTE typedef ArmatureAnimation CCArmatureAnimation;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef Armature CCArmature;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef ArmatureDataManager CCArmatureDataManager;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef TweenType CCTweenType;
|
||||
|
||||
class Armature : public cocos2d::NodeRGBA, public cocos2d::BlendProtocol
|
||||
{
|
||||
|
@ -93,12 +94,12 @@ public:
|
|||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
~Armature(void);
|
||||
virtual ~Armature(void);
|
||||
|
||||
/**
|
||||
* Init the empty armature
|
||||
*/
|
||||
virtual bool init();
|
||||
virtual bool init() override;
|
||||
|
||||
/**
|
||||
* Init an armature with specified name
|
||||
|
@ -111,7 +112,7 @@ public:
|
|||
* Add a Bone to this Armature,
|
||||
*
|
||||
* @param bone The Bone you want to add to Armature
|
||||
* @param parentName The parent Bone's name you want to add to . If it's NULL, then set Armature to its parent
|
||||
* @param parentName The parent Bone's name you want to add to . If it's nullptr, then set Armature to its parent
|
||||
*/
|
||||
virtual void addBone(Bone *bone, const char *parentName);
|
||||
/**
|
||||
|
@ -139,14 +140,14 @@ public:
|
|||
* Get Armature's bone dictionary
|
||||
* @return Armature's bone dictionary
|
||||
*/
|
||||
cocos2d::Dictionary *getBoneDic();
|
||||
cocos2d::Dictionary *getBoneDic() const;
|
||||
|
||||
/**
|
||||
* This boundingBox will calculate all bones' boundingBox every time
|
||||
*/
|
||||
virtual cocos2d::Rect getBoundingBox() const;
|
||||
virtual cocos2d::Rect getBoundingBox() const override;
|
||||
|
||||
Bone *getBoneAtPoint(float x, float y);
|
||||
Bone *getBoneAtPoint(float x, float y) const;
|
||||
|
||||
// overrides
|
||||
/**
|
||||
|
@ -169,14 +170,43 @@ public:
|
|||
virtual void updateOffsetPoint();
|
||||
|
||||
virtual void setAnimation(ArmatureAnimation *animation);
|
||||
virtual ArmatureAnimation *getAnimation();
|
||||
virtual ArmatureAnimation *getAnimation() const;
|
||||
|
||||
virtual bool getArmatureTransformDirty();
|
||||
virtual bool getArmatureTransformDirty() const;
|
||||
|
||||
virtual cocos2d::TextureAtlas *getTexureAtlasWithTexture(cocos2d::Texture2D *texture) const;
|
||||
|
||||
virtual void setColliderFilter(ColliderFilter *filter);
|
||||
|
||||
|
||||
virtual void setArmatureData(ArmatureData *armatureData) { _armatureData = armatureData; }
|
||||
virtual ArmatureData *getArmatureData() const { return _armatureData; }
|
||||
|
||||
virtual void setBatchNode(BatchNode *batchNode) { _batchNode = batchNode; }
|
||||
virtual BatchNode *getBatchNode() const { return _batchNode; }
|
||||
|
||||
virtual void setName(const std::string &name) { _name = name; }
|
||||
virtual const std::string &getName() const { return _name; }
|
||||
|
||||
virtual void setTextureAtlas(cocos2d::TextureAtlas *atlas) { _atlas = atlas; }
|
||||
virtual cocos2d::TextureAtlas *getTextureAtlas() const { return _atlas; }
|
||||
|
||||
virtual void setParentBone(Bone *parentBone);
|
||||
virtual Bone *getParentBone() const;
|
||||
|
||||
virtual void setVersion(float version) { _version = version; }
|
||||
virtual float getVersion() const { return _version; }
|
||||
|
||||
#if ENABLE_PHYSICS_BOX2D_DETECT
|
||||
virtual b2Fixture *getShapeList();
|
||||
|
||||
virtual void setBody(b2Body *body);
|
||||
virtual b2Body *getBody() const;
|
||||
#elif ENABLE_PHYSICS_CHIPMUNK_DETECT
|
||||
virtual cpShape *getShapeList();
|
||||
|
||||
virtual void setBody(cpBody *body);
|
||||
virtual cpBody *getBody() const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
@ -189,19 +219,14 @@ protected:
|
|||
//! Update blend function
|
||||
void updateBlendType(BlendType blendType);
|
||||
|
||||
CC_SYNTHESIZE(ArmatureData *, _armatureData, ArmatureData);
|
||||
|
||||
CC_SYNTHESIZE(BatchNode *, _batchNode, BatchNode);
|
||||
|
||||
CC_SYNTHESIZE(std::string, _name, Name);
|
||||
|
||||
CC_SYNTHESIZE(cocos2d::TextureAtlas *, _atlas, TextureAtlas);
|
||||
|
||||
CC_SYNTHESIZE(Bone *, _parentBone, ParentBone);
|
||||
|
||||
CC_SYNTHESIZE(float, _version, Version);
|
||||
|
||||
protected:
|
||||
ArmatureData *_armatureData;
|
||||
BatchNode *_batchNode;
|
||||
std::string _name;
|
||||
cocos2d::TextureAtlas *_atlas;
|
||||
Bone *_parentBone;
|
||||
float _version;
|
||||
|
||||
mutable bool _armatureTransformDirty;
|
||||
|
||||
cocos2d::Dictionary *_boneDic; //! The dictionary of the bones, include all bones in the armature, no matter it is the direct bone or the indirect bone. It is different from m_pChindren.
|
||||
|
@ -214,10 +239,12 @@ protected:
|
|||
|
||||
ArmatureAnimation *_animation;
|
||||
|
||||
cocos2d::Dictionary *_textureAtlasDic;
|
||||
|
||||
#if ENABLE_PHYSICS_BOX2D_DETECT
|
||||
CC_PROPERTY(b2Body *, _body, Body);
|
||||
b2Body *_body;
|
||||
#elif ENABLE_PHYSICS_CHIPMUNK_DETECT
|
||||
CC_PROPERTY(cpBody *, _body, Body);
|
||||
cpBody *_body;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
|
@ -43,22 +43,24 @@ ArmatureAnimation *ArmatureAnimation::create(Armature *armature)
|
|||
return pArmatureAnimation;
|
||||
}
|
||||
CC_SAFE_DELETE(pArmatureAnimation);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
ArmatureAnimation::ArmatureAnimation()
|
||||
: _animationData(NULL)
|
||||
: _animationData(nullptr)
|
||||
, _speedScale(1)
|
||||
, _movementData(NULL)
|
||||
, _armature(NULL)
|
||||
, _movementData(nullptr)
|
||||
, _armature(nullptr)
|
||||
, _movementID("")
|
||||
, _toIndex(0)
|
||||
, _tweenList(nullptr)
|
||||
, _ignoreFrameEvent(false)
|
||||
|
||||
, _movementEventCallFunc(NULL)
|
||||
, _frameEventCallFunc(NULL)
|
||||
, _movementEventTarget(NULL)
|
||||
, _frameEventTarget(NULL)
|
||||
, _movementEventCallFunc(nullptr)
|
||||
, _frameEventCallFunc(nullptr)
|
||||
, _movementEventTarget(nullptr)
|
||||
, _frameEventTarget(nullptr)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -92,8 +94,7 @@ bool ArmatureAnimation::init(Armature *armature)
|
|||
|
||||
void ArmatureAnimation:: pause()
|
||||
{
|
||||
Object *object = NULL;
|
||||
CCARRAY_FOREACH(_tweenList, object)
|
||||
for(auto object : *_tweenList)
|
||||
{
|
||||
static_cast<Tween*>(object)->pause();
|
||||
}
|
||||
|
@ -102,8 +103,7 @@ void ArmatureAnimation:: pause()
|
|||
|
||||
void ArmatureAnimation::resume()
|
||||
{
|
||||
Object *object = NULL;
|
||||
CCARRAY_FOREACH(_tweenList, object)
|
||||
for(auto object : *_tweenList)
|
||||
{
|
||||
static_cast<Tween*>(object)->resume();
|
||||
}
|
||||
|
@ -112,8 +112,7 @@ void ArmatureAnimation::resume()
|
|||
|
||||
void ArmatureAnimation::stop()
|
||||
{
|
||||
Object *object = NULL;
|
||||
CCARRAY_FOREACH(_tweenList, object)
|
||||
for(auto object : *_tweenList)
|
||||
{
|
||||
static_cast<Tween*>(object)->stop();
|
||||
}
|
||||
|
@ -143,8 +142,8 @@ void ArmatureAnimation::setSpeedScale(float speedScale)
|
|||
|
||||
_processScale = !_movementData ? _speedScale : _speedScale * _movementData->scale;
|
||||
|
||||
DictElement *element = NULL;
|
||||
Dictionary *dict = _armature->getBoneDic();
|
||||
DictElement *element = nullptr;
|
||||
const Dictionary *dict = _armature->getBoneDic();
|
||||
CCDICT_FOREACH(dict, element)
|
||||
{
|
||||
Bone *bone = static_cast<Bone*>(element->getObject());
|
||||
|
@ -171,8 +170,8 @@ void ArmatureAnimation::setAnimationInternal(float animationInternal)
|
|||
|
||||
_animationInternal = animationInternal;
|
||||
|
||||
DictElement *element = NULL;
|
||||
Dictionary *dict = _armature->getBoneDic();
|
||||
DictElement *element = nullptr;
|
||||
const Dictionary *dict = _armature->getBoneDic();
|
||||
CCDICT_FOREACH(dict, element)
|
||||
{
|
||||
Bone *bone = static_cast<Bone*>(element->getObject());
|
||||
|
@ -230,11 +229,11 @@ void ArmatureAnimation::play(const char *animationName, int durationTo, int dura
|
|||
_durationTween = durationTween;
|
||||
}
|
||||
|
||||
MovementBoneData *movementBoneData = NULL;
|
||||
MovementBoneData *movementBoneData = nullptr;
|
||||
_tweenList->removeAllObjects();
|
||||
|
||||
DictElement *element = NULL;
|
||||
Dictionary *dict = _armature->getBoneDic();
|
||||
DictElement *element = nullptr;
|
||||
const Dictionary *dict = _armature->getBoneDic();
|
||||
|
||||
CCDICT_FOREACH(dict, element)
|
||||
{
|
||||
|
@ -259,7 +258,7 @@ void ArmatureAnimation::play(const char *animationName, int durationTo, int dura
|
|||
}
|
||||
else
|
||||
{
|
||||
if(!bone->getIgnoreMovementBoneData())
|
||||
if(!bone->isIgnoreMovementBoneData())
|
||||
{
|
||||
//! this bone is not include in this movement, so hide it
|
||||
bone->getDisplayManager()->changeDisplayByIndex(-1, false);
|
||||
|
@ -268,6 +267,8 @@ void ArmatureAnimation::play(const char *animationName, int durationTo, int dura
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
_armature->update(0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -280,9 +281,41 @@ void ArmatureAnimation::playByIndex(int animationIndex, int durationTo, int dura
|
|||
play(animationName.c_str(), durationTo, durationTween, loop, tweenEasing);
|
||||
}
|
||||
|
||||
void ArmatureAnimation::gotoAndPlay(int frameIndex)
|
||||
{
|
||||
if (!_movementData || frameIndex < 0 || frameIndex >= _movementData->duration)
|
||||
{
|
||||
CCLOG("Please ensure you have played a movement, and the frameIndex is in the range.");
|
||||
return;
|
||||
}
|
||||
|
||||
bool ignoreFrameEvent = _ignoreFrameEvent;
|
||||
_ignoreFrameEvent = true;
|
||||
|
||||
int ArmatureAnimation::getMovementCount()
|
||||
_isPlaying = true;
|
||||
_isComplete = _isPause = false;
|
||||
|
||||
ProcessBase::gotoFrame(frameIndex);
|
||||
_currentPercent = (float)_curFrameIndex / (float)_movementData->duration;
|
||||
_currentFrame = _nextFrameIndex * _currentPercent;
|
||||
|
||||
for(auto object : *_tweenList)
|
||||
{
|
||||
static_cast<Tween *>(object)->gotoAndPlay(frameIndex);
|
||||
}
|
||||
|
||||
_armature->update(0);
|
||||
|
||||
_ignoreFrameEvent = ignoreFrameEvent;
|
||||
}
|
||||
|
||||
void ArmatureAnimation::gotoAndPause(int frameIndex)
|
||||
{
|
||||
gotoAndPlay(frameIndex);
|
||||
pause();
|
||||
}
|
||||
|
||||
int ArmatureAnimation::getMovementCount() const
|
||||
{
|
||||
return _animationData->getMovementCount();
|
||||
}
|
||||
|
@ -290,11 +323,23 @@ int ArmatureAnimation::getMovementCount()
|
|||
void ArmatureAnimation::update(float dt)
|
||||
{
|
||||
ProcessBase::update(dt);
|
||||
Object *object = NULL;
|
||||
CCARRAY_FOREACH(_tweenList, object)
|
||||
|
||||
for(auto object : *_tweenList)
|
||||
{
|
||||
static_cast<Tween *>(object)->update(dt);
|
||||
}
|
||||
|
||||
while (_frameEventQueue.size() > 0)
|
||||
{
|
||||
FrameEvent *frameEvent = _frameEventQueue.front();
|
||||
_frameEventQueue.pop();
|
||||
|
||||
_ignoreFrameEvent = true;
|
||||
(_frameEventTarget->*_frameEventCallFunc)(frameEvent->bone, frameEvent->frameEventName, frameEvent->originFrameIndex, frameEvent->currentFrameIndex);
|
||||
_ignoreFrameEvent = false;
|
||||
|
||||
CC_SAFE_DELETE(frameEvent);
|
||||
}
|
||||
}
|
||||
|
||||
void ArmatureAnimation::updateHandler()
|
||||
|
@ -367,7 +412,7 @@ void ArmatureAnimation::updateHandler()
|
|||
}
|
||||
}
|
||||
|
||||
std::string ArmatureAnimation::getCurrentMovementID()
|
||||
std::string ArmatureAnimation::getCurrentMovementID() const
|
||||
{
|
||||
if (_isComplete)
|
||||
{
|
||||
|
@ -402,7 +447,13 @@ void ArmatureAnimation::frameEvent(Bone *bone, const char *frameEventName, int o
|
|||
{
|
||||
if (_frameEventTarget && _frameEventCallFunc)
|
||||
{
|
||||
(_frameEventTarget->*_frameEventCallFunc)(bone, frameEventName, originFrameIndex, currentFrameIndex);
|
||||
FrameEvent *frameEvent = new FrameEvent();
|
||||
frameEvent->bone = bone;
|
||||
frameEvent->frameEventName = frameEventName;
|
||||
frameEvent->originFrameIndex = originFrameIndex;
|
||||
frameEvent->currentFrameIndex = currentFrameIndex;
|
||||
|
||||
_frameEventQueue.push(frameEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ THE SOFTWARE.
|
|||
#define __CCANIMATION_H__
|
||||
|
||||
#include "cocostudio/CCProcessBase.h"
|
||||
#include <queue>
|
||||
|
||||
namespace cocostudio {
|
||||
|
||||
|
@ -48,6 +49,13 @@ typedef void (cocos2d::Object::*SEL_FrameEventCallFunc)(Bone *, const char *, in
|
|||
#define movementEvent_selector(_SELECTOR) (cocostudio::SEL_MovementEventCallFunc)(&_SELECTOR)
|
||||
#define frameEvent_selector(_SELECTOR) (cocostudio::SEL_FrameEventCallFunc)(&_SELECTOR)
|
||||
|
||||
struct FrameEvent
|
||||
{
|
||||
Bone *bone;
|
||||
const char *frameEventName;
|
||||
int originFrameIndex;
|
||||
int currentFrameIndex;
|
||||
};
|
||||
|
||||
class ArmatureAnimation : public ProcessBase
|
||||
{
|
||||
|
@ -76,10 +84,11 @@ public:
|
|||
|
||||
/**
|
||||
* Scale animation play speed.
|
||||
* This method is deprecated, please use setSpeedScale.
|
||||
* @param animationScale Scale value
|
||||
*/
|
||||
virtual void setAnimationScale(float animationScale);
|
||||
virtual float getAnimationScale() const;
|
||||
CC_DEPRECATED_ATTRIBUTE virtual void setAnimationScale(float animationScale);
|
||||
CC_DEPRECATED_ATTRIBUTE virtual float getAnimationScale() const;
|
||||
|
||||
/**
|
||||
* Scale animation play speed.
|
||||
|
@ -123,10 +132,27 @@ public:
|
|||
|
||||
/**
|
||||
* Play animation by index, the other param is the same to play.
|
||||
* @param _animationIndex the animation index you want to play
|
||||
* @param animationIndex the animation index you want to play
|
||||
*/
|
||||
void playByIndex(int animationIndex, int durationTo = -1, int durationTween = -1, int loop = -1, int tweenEasing = TWEEN_EASING_MAX);
|
||||
|
||||
/**
|
||||
* Go to specified frame and play current movement.
|
||||
* You need first switch to the movement you want to play, then call this function.
|
||||
*
|
||||
* example : playByIndex(0);
|
||||
* gotoAndPlay(0);
|
||||
* playByIndex(1);
|
||||
* gotoAndPlay(0);
|
||||
* gotoAndPlay(15);
|
||||
*/
|
||||
virtual void gotoAndPlay(int frameIndex);
|
||||
|
||||
/**
|
||||
* Go to specified frame and pause current movement.
|
||||
*/
|
||||
virtual void gotoAndPause(int frameIndex);
|
||||
|
||||
/**
|
||||
* Pause the Process
|
||||
*/
|
||||
|
@ -144,7 +170,7 @@ public:
|
|||
/**
|
||||
* Get movement count
|
||||
*/
|
||||
int getMovementCount();
|
||||
int getMovementCount() const;
|
||||
|
||||
void update(float dt);
|
||||
|
||||
|
@ -152,20 +178,30 @@ public:
|
|||
* Get current movementID
|
||||
* @return The name of current movement
|
||||
*/
|
||||
std::string getCurrentMovementID();
|
||||
std::string getCurrentMovementID() const;
|
||||
|
||||
/**
|
||||
* Set armature's movement event callback function
|
||||
* To disconnect this event, just setMovementEventCallFunc(NULL, NULL);
|
||||
* To disconnect this event, just setMovementEventCallFunc(nullptr, nullptr);
|
||||
*/
|
||||
void setMovementEventCallFunc(cocos2d::Object *target, SEL_MovementEventCallFunc callFunc);
|
||||
|
||||
/**
|
||||
* Set armature's frame event callback function
|
||||
* To disconnect this event, just setFrameEventCallFunc(NULL, NULL);
|
||||
* To disconnect this event, just setFrameEventCallFunc(nullptr, nullptr);
|
||||
*/
|
||||
void setFrameEventCallFunc(cocos2d::Object *target, SEL_FrameEventCallFunc callFunc);
|
||||
|
||||
virtual void setAnimationData(AnimationData *data)
|
||||
{
|
||||
if (_animationData != data)
|
||||
{
|
||||
CC_SAFE_RETAIN(data);
|
||||
CC_SAFE_RELEASE(_animationData);
|
||||
_animationData = data;
|
||||
}
|
||||
}
|
||||
virtual AnimationData *getAnimationData() const { return _animationData; }
|
||||
protected:
|
||||
|
||||
/**
|
||||
|
@ -183,10 +219,12 @@ protected:
|
|||
*/
|
||||
void frameEvent(Bone *bone, const char *frameEventName, int originFrameIndex, int currentFrameIndex);
|
||||
|
||||
bool isIgnoreFrameEvent() const { return _ignoreFrameEvent; }
|
||||
|
||||
friend class Tween;
|
||||
protected:
|
||||
//! AnimationData save all MovementDatas this animation used.
|
||||
CC_SYNTHESIZE_RETAIN(AnimationData *, _animationData, AnimationData);
|
||||
AnimationData *_animationData;
|
||||
|
||||
//! Scale the animation speed
|
||||
float _speedScale;
|
||||
|
@ -201,6 +239,9 @@ protected:
|
|||
|
||||
cocos2d::Array *_tweenList;
|
||||
|
||||
bool _ignoreFrameEvent;
|
||||
|
||||
std::queue<FrameEvent*> _frameEventQueue;
|
||||
protected:
|
||||
/**
|
||||
* MovementEvent CallFunc.
|
||||
|
|
|
@ -32,11 +32,11 @@ using namespace cocos2d;
|
|||
|
||||
namespace cocostudio {
|
||||
|
||||
static ArmatureDataManager *s_sharedArmatureDataManager = NULL;
|
||||
static ArmatureDataManager *s_sharedArmatureDataManager = nullptr;
|
||||
|
||||
ArmatureDataManager *ArmatureDataManager::getInstance()
|
||||
{
|
||||
if (s_sharedArmatureDataManager == NULL)
|
||||
if (s_sharedArmatureDataManager == nullptr)
|
||||
{
|
||||
s_sharedArmatureDataManager = new ArmatureDataManager();
|
||||
if (!s_sharedArmatureDataManager || !s_sharedArmatureDataManager->init())
|
||||
|
@ -56,16 +56,30 @@ void ArmatureDataManager::destoryInstance()
|
|||
|
||||
ArmatureDataManager::ArmatureDataManager(void)
|
||||
{
|
||||
_armarureDatas = NULL;
|
||||
_animationDatas = NULL;
|
||||
_textureDatas = NULL;
|
||||
_armarureDatas = nullptr;
|
||||
_animationDatas = nullptr;
|
||||
_textureDatas = nullptr;
|
||||
_autoLoadSpriteFile = false;
|
||||
}
|
||||
|
||||
|
||||
ArmatureDataManager::~ArmatureDataManager(void)
|
||||
{
|
||||
removeAll();
|
||||
if( _animationDatas )
|
||||
{
|
||||
_animationDatas->removeAllObjects();
|
||||
}
|
||||
if( _armarureDatas )
|
||||
{
|
||||
_armarureDatas->removeAllObjects();
|
||||
}
|
||||
|
||||
if( _textureDatas )
|
||||
{
|
||||
_textureDatas->removeAllObjects();
|
||||
}
|
||||
|
||||
_relativeDatas.clear();
|
||||
|
||||
CC_SAFE_DELETE(_animationDatas);
|
||||
CC_SAFE_DELETE(_armarureDatas);
|
||||
|
@ -97,17 +111,52 @@ bool ArmatureDataManager::init()
|
|||
return bRet;
|
||||
}
|
||||
|
||||
void ArmatureDataManager::addArmatureData(const char *id, ArmatureData *armatureData)
|
||||
void ArmatureDataManager::removeArmatureFileInfo(const char *configFilePath)
|
||||
{
|
||||
if (RelativeData *data = getRelativeData(configFilePath))
|
||||
{
|
||||
for (std::string str : data->armatures)
|
||||
{
|
||||
removeArmatureData(str.c_str());
|
||||
}
|
||||
|
||||
for (std::string str : data->animations)
|
||||
{
|
||||
removeAnimationData(str.c_str());
|
||||
}
|
||||
|
||||
for (std::string str : data->textures)
|
||||
{
|
||||
removeTextureData(str.c_str());
|
||||
}
|
||||
|
||||
for (std::string str : data->plistFiles)
|
||||
{
|
||||
SpriteFrameCache::getInstance()->removeSpriteFramesFromFile(str.c_str());
|
||||
}
|
||||
|
||||
_relativeDatas.erase(configFilePath);
|
||||
DataReaderHelper::getInstance()->removeConfigFile(configFilePath);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ArmatureDataManager::addArmatureData(const char *id, ArmatureData *armatureData, const char *configFilePath)
|
||||
{
|
||||
if(_armarureDatas)
|
||||
{
|
||||
if (RelativeData *data = getRelativeData(configFilePath))
|
||||
{
|
||||
data->armatures.push_back(id);
|
||||
}
|
||||
|
||||
_armarureDatas->setObject(armatureData, id);
|
||||
}
|
||||
}
|
||||
|
||||
ArmatureData *ArmatureDataManager::getArmatureData(const char *id)
|
||||
{
|
||||
ArmatureData *armatureData = NULL;
|
||||
ArmatureData *armatureData = nullptr;
|
||||
if (_armarureDatas)
|
||||
{
|
||||
armatureData = (ArmatureData *)_armarureDatas->objectForKey(id);
|
||||
|
@ -123,17 +172,22 @@ void ArmatureDataManager::removeArmatureData(const char *id)
|
|||
}
|
||||
}
|
||||
|
||||
void ArmatureDataManager::addAnimationData(const char *id, AnimationData *animationData)
|
||||
void ArmatureDataManager::addAnimationData(const char *id, AnimationData *animationData, const char *configFilePath)
|
||||
{
|
||||
if(_animationDatas)
|
||||
{
|
||||
if (RelativeData *data = getRelativeData(configFilePath))
|
||||
{
|
||||
data->animations.push_back(id);
|
||||
}
|
||||
|
||||
_animationDatas->setObject(animationData, id);
|
||||
}
|
||||
}
|
||||
|
||||
AnimationData *ArmatureDataManager::getAnimationData(const char *id)
|
||||
{
|
||||
AnimationData *animationData = NULL;
|
||||
AnimationData *animationData = nullptr;
|
||||
if (_animationDatas)
|
||||
{
|
||||
animationData = (AnimationData *)_animationDatas->objectForKey(id);
|
||||
|
@ -149,10 +203,15 @@ void ArmatureDataManager::removeAnimationData(const char *id)
|
|||
}
|
||||
}
|
||||
|
||||
void ArmatureDataManager::addTextureData(const char *id, TextureData *textureData)
|
||||
void ArmatureDataManager::addTextureData(const char *id, TextureData *textureData, const char *configFilePath)
|
||||
{
|
||||
if(_textureDatas)
|
||||
{
|
||||
if (RelativeData *data = getRelativeData(configFilePath))
|
||||
{
|
||||
data->textures.push_back(id);
|
||||
}
|
||||
|
||||
_textureDatas->setObject(textureData, id);
|
||||
}
|
||||
}
|
||||
|
@ -160,7 +219,7 @@ void ArmatureDataManager::addTextureData(const char *id, TextureData *textureDat
|
|||
|
||||
TextureData *ArmatureDataManager::getTextureData(const char *id)
|
||||
{
|
||||
TextureData *textureData = NULL;
|
||||
TextureData *textureData = nullptr;
|
||||
if (_textureDatas)
|
||||
{
|
||||
textureData = (TextureData *)_textureDatas->objectForKey(id);
|
||||
|
@ -179,18 +238,24 @@ void ArmatureDataManager::removeTextureData(const char *id)
|
|||
|
||||
void ArmatureDataManager::addArmatureFileInfo(const char *configFilePath)
|
||||
{
|
||||
addRelativeData(configFilePath);
|
||||
|
||||
_autoLoadSpriteFile = true;
|
||||
DataReaderHelper::getInstance()->addDataFromFile(configFilePath);
|
||||
}
|
||||
|
||||
void ArmatureDataManager::addArmatureFileInfoAsync(const char *configFilePath, Object *target, SEL_SCHEDULE selector)
|
||||
{
|
||||
addRelativeData(configFilePath);
|
||||
|
||||
_autoLoadSpriteFile = true;
|
||||
DataReaderHelper::getInstance()->addDataFromFileAsync(configFilePath, target, selector);
|
||||
DataReaderHelper::getInstance()->addDataFromFileAsync("", "", configFilePath, target, selector);
|
||||
}
|
||||
|
||||
void ArmatureDataManager::addArmatureFileInfo(const char *imagePath, const char *plistPath, const char *configFilePath)
|
||||
{
|
||||
addRelativeData(configFilePath);
|
||||
|
||||
_autoLoadSpriteFile = false;
|
||||
DataReaderHelper::getInstance()->addDataFromFile(configFilePath);
|
||||
addSpriteFrameFromFile(plistPath, imagePath);
|
||||
|
@ -198,36 +263,23 @@ void ArmatureDataManager::addArmatureFileInfo(const char *imagePath, const char
|
|||
|
||||
void ArmatureDataManager::addArmatureFileInfoAsync(const char *imagePath, const char *plistPath, const char *configFilePath, Object *target, SEL_SCHEDULE selector)
|
||||
{
|
||||
addRelativeData(configFilePath);
|
||||
|
||||
_autoLoadSpriteFile = false;
|
||||
DataReaderHelper::getInstance()->addDataFromFileAsync(configFilePath, target, selector);
|
||||
DataReaderHelper::getInstance()->addDataFromFileAsync(imagePath, plistPath, configFilePath, target, selector);
|
||||
addSpriteFrameFromFile(plistPath, imagePath);
|
||||
}
|
||||
|
||||
void ArmatureDataManager::addSpriteFrameFromFile(const char *plistPath, const char *imagePath)
|
||||
void ArmatureDataManager::addSpriteFrameFromFile(const char *plistPath, const char *imagePath, const char *configFilePath)
|
||||
{
|
||||
if (RelativeData *data = getRelativeData(configFilePath))
|
||||
{
|
||||
data->plistFiles.push_back(plistPath);
|
||||
}
|
||||
SpriteFrameCacheHelper::getInstance()->addSpriteFrameFromFile(plistPath, imagePath);
|
||||
}
|
||||
|
||||
|
||||
void ArmatureDataManager::removeAll()
|
||||
{
|
||||
if( _animationDatas )
|
||||
{
|
||||
_animationDatas->removeAllObjects();
|
||||
}
|
||||
if( _armarureDatas )
|
||||
{
|
||||
_armarureDatas->removeAllObjects();
|
||||
}
|
||||
|
||||
if( _textureDatas )
|
||||
{
|
||||
_textureDatas->removeAllObjects();
|
||||
}
|
||||
|
||||
DataReaderHelper::clear();
|
||||
}
|
||||
|
||||
bool ArmatureDataManager::isAutoLoadSpriteFile()
|
||||
{
|
||||
return _autoLoadSpriteFile;
|
||||
|
@ -246,4 +298,17 @@ Dictionary *ArmatureDataManager::getTextureDatas() const
|
|||
return _textureDatas;
|
||||
}
|
||||
|
||||
void CCArmatureDataManager::addRelativeData(const char *configFilePath)
|
||||
{
|
||||
if (_relativeDatas.find(configFilePath) == _relativeDatas.end())
|
||||
{
|
||||
_relativeDatas[configFilePath] = RelativeData();
|
||||
}
|
||||
}
|
||||
|
||||
RelativeData *CCArmatureDataManager::getRelativeData(const char* configFilePath)
|
||||
{
|
||||
return &_relativeDatas[configFilePath];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -31,6 +31,14 @@ THE SOFTWARE.
|
|||
|
||||
namespace cocostudio {
|
||||
|
||||
struct RelativeData
|
||||
{
|
||||
std::vector<std::string> plistFiles;
|
||||
std::vector<std::string> armatures;
|
||||
std::vector<std::string> animations;
|
||||
std::vector<std::string> textures;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief format and manage armature configuration and armature animation
|
||||
*/
|
||||
|
@ -69,7 +77,7 @@ public:
|
|||
* @param id The id of the armature data
|
||||
* @param armatureData ArmatureData *
|
||||
*/
|
||||
void addArmatureData(const char *id, ArmatureData *armatureData);
|
||||
void addArmatureData(const char *id, ArmatureData *armatureData, const char *configFilePath = "");
|
||||
|
||||
/**
|
||||
* @brief get armature data
|
||||
|
@ -89,7 +97,7 @@ public:
|
|||
* @param id the id of the animation data
|
||||
* @return AnimationData *
|
||||
*/
|
||||
void addAnimationData(const char *id, AnimationData *animationData);
|
||||
void addAnimationData(const char *id, AnimationData *animationData, const char *configFilePath = "");
|
||||
|
||||
/**
|
||||
* @brief get animation data from _animationDatas(Dictionary)
|
||||
|
@ -109,7 +117,7 @@ public:
|
|||
* @param id the id of the texture data
|
||||
* @return TextureData *
|
||||
*/
|
||||
void addTextureData(const char *id, TextureData *textureData);
|
||||
void addTextureData(const char *id, TextureData *textureData, const char *configFilePath = "");
|
||||
|
||||
/**
|
||||
* @brief get texture data
|
||||
|
@ -149,13 +157,10 @@ public:
|
|||
/**
|
||||
* @brief Add sprite frame to CCSpriteFrameCache, it will save display name and it's relative image name
|
||||
*/
|
||||
void addSpriteFrameFromFile(const char *plistPath, const char *imagePath);
|
||||
void addSpriteFrameFromFile(const char *plistPath, const char *imagePath, const char *configFilePath = "");
|
||||
|
||||
virtual void removeArmatureFileInfo(const char *configFilePath);
|
||||
|
||||
/**
|
||||
* @brief Clear the data in the _armarureDatas and _animationDatas, and set _armarureDatas and _animationDatas to NULL
|
||||
*/
|
||||
void removeAll();
|
||||
|
||||
/**
|
||||
* @brief Juge whether or not need auto load sprite file
|
||||
|
@ -166,6 +171,10 @@ public:
|
|||
cocos2d::Dictionary *getArmatureDatas() const;
|
||||
cocos2d::Dictionary *getAnimationDatas() const;
|
||||
cocos2d::Dictionary *getTextureDatas() const;
|
||||
|
||||
protected:
|
||||
void addRelativeData(const char* configFilePath);
|
||||
RelativeData *getRelativeData(const char* configFilePath);
|
||||
private:
|
||||
/**
|
||||
* @brief save amature datas
|
||||
|
@ -189,6 +198,8 @@ private:
|
|||
cocos2d::Dictionary *_textureDatas;
|
||||
|
||||
bool _autoLoadSpriteFile;
|
||||
|
||||
std::map<std::string, RelativeData> _relativeDatas;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace cocostudio {
|
|||
|
||||
const char *armatureVersion()
|
||||
{
|
||||
return "0.4.0.0";
|
||||
return "1.0.0.0";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ THE SOFTWARE.
|
|||
|
||||
#define VERSION_COMBINED 0.30f
|
||||
#define VERSION_CHANGE_ROTATION_RANGE 1.0f
|
||||
#define VERSION_COLOR_READING 1.1f
|
||||
|
||||
#ifndef AUTO_ADD_SPRITE_FRAME_NAME_PREFIX
|
||||
#define AUTO_ADD_SPRITE_FRAME_NAME_PREFIX 0
|
||||
|
@ -44,8 +45,12 @@ THE SOFTWARE.
|
|||
#define ENABLE_PHYSICS_CHIPMUNK_DETECT 1
|
||||
#endif
|
||||
|
||||
#ifndef ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX
|
||||
#define ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX 0
|
||||
#endif
|
||||
|
||||
#define CS_RETURN_IF(cond) if (cond) return
|
||||
#define CS_RETURN_NULL_IF(cond) if (cond) return NULL;
|
||||
#define CS_RETURN_NULL_IF(cond) if (cond) return nullptr;
|
||||
|
||||
namespace cocostudio {
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ THE SOFTWARE.
|
|||
#include "cocostudio/CCBatchNode.h"
|
||||
#include "cocostudio/CCArmatureDefine.h"
|
||||
#include "cocostudio/CCArmature.h"
|
||||
#include "cocostudio/CCSkin.h"
|
||||
|
||||
using namespace cocos2d;
|
||||
|
||||
|
@ -39,31 +40,98 @@ BatchNode *BatchNode::create()
|
|||
return batchNode;
|
||||
}
|
||||
CC_SAFE_DELETE(batchNode);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BatchNode::BatchNode()
|
||||
: _atlas(NULL)
|
||||
: _atlas(nullptr)
|
||||
, _textureAtlasDic(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
BatchNode::~BatchNode()
|
||||
{
|
||||
CC_SAFE_RELEASE_NULL(_textureAtlasDic);
|
||||
}
|
||||
|
||||
bool BatchNode::init()
|
||||
{
|
||||
bool ret = Node::init();
|
||||
setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR));
|
||||
|
||||
CC_SAFE_DELETE(_textureAtlasDic);
|
||||
_textureAtlasDic = new Dictionary();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void BatchNode::addChild(Node *pChild)
|
||||
{
|
||||
Node::addChild(pChild);
|
||||
}
|
||||
|
||||
void BatchNode::addChild(Node *child, int zOrder)
|
||||
{
|
||||
Node::addChild(child, zOrder);
|
||||
}
|
||||
|
||||
void BatchNode::addChild(Node *child, int zOrder, int tag)
|
||||
{
|
||||
Node::addChild(child, zOrder, tag);
|
||||
Armature *armature = dynamic_cast<Armature *>(child);
|
||||
if (armature != NULL)
|
||||
if (armature != nullptr)
|
||||
{
|
||||
armature->setBatchNode(this);
|
||||
|
||||
const Dictionary *dict = armature->getBoneDic();
|
||||
DictElement *element = nullptr;
|
||||
CCDICT_FOREACH(dict, element)
|
||||
{
|
||||
Bone *bone = static_cast<Bone*>(element->getObject());
|
||||
|
||||
Array *displayList = bone->getDisplayManager()->getDecorativeDisplayList();
|
||||
for(auto object : *displayList)
|
||||
{
|
||||
DecorativeDisplay *display = static_cast<DecorativeDisplay*>(object);
|
||||
|
||||
if (Skin *skin = dynamic_cast<Skin*>(display->getDisplay()))
|
||||
{
|
||||
skin->setTextureAtlas(getTexureAtlasWithTexture(skin->getTexture()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BatchNode::removeChild(Node* child, bool cleanup)
|
||||
{
|
||||
Armature *armature = dynamic_cast<Armature *>(child);
|
||||
if (armature != nullptr)
|
||||
{
|
||||
armature->setBatchNode(nullptr);
|
||||
|
||||
const Dictionary *dict = armature->getBoneDic();
|
||||
DictElement *element = nullptr;
|
||||
CCDICT_FOREACH(dict, element)
|
||||
{
|
||||
Bone *bone = static_cast<Bone*>(element->getObject());
|
||||
|
||||
Array *displayList = bone->getDisplayManager()->getDecorativeDisplayList();
|
||||
for(auto object : *displayList)
|
||||
{
|
||||
DecorativeDisplay *display = static_cast<DecorativeDisplay*>(object);
|
||||
|
||||
if (Skin *skin = dynamic_cast<Skin*>(display->getDisplay()))
|
||||
{
|
||||
skin->setTextureAtlas(armature->getTexureAtlasWithTexture(skin->getTexture()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Node::removeChild(child, cleanup);
|
||||
}
|
||||
|
||||
void BatchNode::visit()
|
||||
{
|
||||
// quick return if not visible. children won't be drawn.
|
||||
|
@ -96,8 +164,8 @@ void BatchNode::visit()
|
|||
void BatchNode::draw()
|
||||
{
|
||||
CC_NODE_DRAW_SETUP();
|
||||
Object *object = NULL;
|
||||
CCARRAY_FOREACH(_children, object)
|
||||
|
||||
for(auto object : *_children)
|
||||
{
|
||||
Armature *armature = dynamic_cast<Armature *>(object);
|
||||
if (armature)
|
||||
|
@ -118,4 +186,17 @@ void BatchNode::draw()
|
|||
}
|
||||
}
|
||||
|
||||
TextureAtlas *BatchNode::getTexureAtlasWithTexture(Texture2D *texture) const
|
||||
{
|
||||
int key = texture->getName();
|
||||
|
||||
TextureAtlas *atlas = static_cast<TextureAtlas *>(_textureAtlasDic->objectForKey(key));
|
||||
if (atlas == nullptr)
|
||||
{
|
||||
atlas = CCTextureAtlas::createWithTexture(texture, 4);
|
||||
_textureAtlasDic->setObject(atlas, key);
|
||||
}
|
||||
return atlas;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -38,14 +38,20 @@ public:
|
|||
* @js ctor
|
||||
*/
|
||||
BatchNode();
|
||||
~BatchNode();
|
||||
|
||||
virtual bool init();
|
||||
virtual void addChild(cocos2d::Node *child, int zOrder, int tag);
|
||||
virtual void visit();
|
||||
void draw();
|
||||
virtual bool init() override;
|
||||
virtual void addChild(cocos2d::Node *pChild) override;
|
||||
virtual void addChild(cocos2d::Node *pChild, int zOrder) override;
|
||||
virtual void addChild(cocos2d::Node *pChild, int zOrder, int tag) override;
|
||||
virtual void removeChild(cocos2d::Node* child, bool cleanup) override;
|
||||
virtual void visit() override;
|
||||
void draw() override;
|
||||
|
||||
virtual cocos2d::TextureAtlas *getTexureAtlasWithTexture(cocos2d::Texture2D *texture) const;
|
||||
protected:
|
||||
cocos2d::TextureAtlas *_atlas;
|
||||
cocos2d::Dictionary *_textureAtlasDic;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ Bone *Bone::create()
|
|||
return pBone;
|
||||
}
|
||||
CC_SAFE_DELETE(pBone);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
}
|
||||
|
||||
|
@ -57,24 +57,28 @@ Bone *Bone::create(const char *name)
|
|||
return pBone;
|
||||
}
|
||||
CC_SAFE_DELETE(pBone);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Bone::Bone()
|
||||
{
|
||||
_tweenData = NULL;
|
||||
_parentBone = NULL;
|
||||
_armature = NULL;
|
||||
_childArmature = NULL;
|
||||
_boneData = NULL;
|
||||
_tween = NULL;
|
||||
_tween = NULL;
|
||||
_children = NULL;
|
||||
_displayManager = NULL;
|
||||
_tweenData = nullptr;
|
||||
_parentBone = nullptr;
|
||||
_armature = nullptr;
|
||||
_childArmature = nullptr;
|
||||
_boneData = nullptr;
|
||||
_tween = nullptr;
|
||||
_tween = nullptr;
|
||||
_children = nullptr;
|
||||
_displayManager = nullptr;
|
||||
_ignoreMovementBoneData = false;
|
||||
_worldTransform = AffineTransformMake(1, 0, 0, 1, 0, 0);
|
||||
_boneTransformDirty = true;
|
||||
_blendType = BLEND_NORMAL;
|
||||
_worldInfo = nullptr;
|
||||
|
||||
_armatureParentBone = nullptr;
|
||||
_dataVersion = 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -84,18 +88,16 @@ Bone::~Bone(void)
|
|||
CC_SAFE_DELETE(_children);
|
||||
CC_SAFE_DELETE(_tween);
|
||||
CC_SAFE_DELETE(_displayManager);
|
||||
CC_SAFE_DELETE(_worldInfo);
|
||||
|
||||
if(_boneData)
|
||||
{
|
||||
_boneData->release();
|
||||
}
|
||||
CC_SAFE_RELEASE_NULL(_boneData);
|
||||
|
||||
CC_SAFE_RELEASE(_childArmature);
|
||||
}
|
||||
|
||||
bool Bone::init()
|
||||
{
|
||||
return Bone::init(NULL);
|
||||
return Bone::init(nullptr);
|
||||
}
|
||||
|
||||
|
||||
|
@ -105,7 +107,7 @@ bool Bone::init(const char *name)
|
|||
do
|
||||
{
|
||||
|
||||
if(NULL != name)
|
||||
if(nullptr != name)
|
||||
{
|
||||
_name = name;
|
||||
}
|
||||
|
@ -121,6 +123,11 @@ bool Bone::init(const char *name)
|
|||
_displayManager = new DisplayManager();
|
||||
_displayManager->init(this);
|
||||
|
||||
CC_SAFE_DELETE(_worldInfo);
|
||||
_worldInfo = new BaseData();
|
||||
|
||||
CC_SAFE_DELETE(_boneData);
|
||||
_boneData = new BoneData();
|
||||
|
||||
bRet = true;
|
||||
}
|
||||
|
@ -131,10 +138,14 @@ bool Bone::init(const char *name)
|
|||
|
||||
void Bone::setBoneData(BoneData *boneData)
|
||||
{
|
||||
CCASSERT(NULL != boneData, "_boneData must not be NULL");
|
||||
CCASSERT(nullptr != boneData, "_boneData must not be nullptr");
|
||||
|
||||
_boneData = boneData;
|
||||
_boneData->retain();
|
||||
if (_boneData != boneData)
|
||||
{
|
||||
CC_SAFE_RETAIN(boneData);
|
||||
CC_SAFE_RELEASE(_boneData);
|
||||
_boneData = boneData;
|
||||
}
|
||||
|
||||
_name = _boneData->name;
|
||||
_ZOrder = _boneData->zOrder;
|
||||
|
@ -142,7 +153,7 @@ void Bone::setBoneData(BoneData *boneData)
|
|||
_displayManager->initDisplayList(boneData);
|
||||
}
|
||||
|
||||
BoneData *Bone::getBoneData()
|
||||
BoneData *Bone::getBoneData() const
|
||||
{
|
||||
return _boneData;
|
||||
}
|
||||
|
@ -153,11 +164,17 @@ void Bone::setArmature(Armature *armature)
|
|||
if (_armature)
|
||||
{
|
||||
_tween->setAnimation(_armature->getAnimation());
|
||||
_dataVersion = _armature->getArmatureData()->dataVersion;
|
||||
_armatureParentBone = _armature->getParentBone();
|
||||
}
|
||||
else
|
||||
{
|
||||
_armatureParentBone = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Armature *Bone::getArmature()
|
||||
Armature *Bone::getArmature() const
|
||||
{
|
||||
return _armature;
|
||||
}
|
||||
|
@ -167,37 +184,75 @@ void Bone::update(float delta)
|
|||
if (_parentBone)
|
||||
_boneTransformDirty = _boneTransformDirty || _parentBone->isTransformDirty();
|
||||
|
||||
if (_armatureParentBone && !_boneTransformDirty)
|
||||
{
|
||||
_boneTransformDirty = _armatureParentBone->isTransformDirty();
|
||||
}
|
||||
|
||||
if (_boneTransformDirty)
|
||||
{
|
||||
if (_armature->getArmatureData()->dataVersion >= VERSION_COMBINED)
|
||||
if (_dataVersion >= VERSION_COMBINED)
|
||||
{
|
||||
TransformHelp::nodeConcat(*_tweenData, *_boneData);
|
||||
_tweenData->scaleX -= 1;
|
||||
_tweenData->scaleY -= 1;
|
||||
}
|
||||
|
||||
TransformHelp::nodeToMatrix(*_tweenData, _worldTransform);
|
||||
_worldInfo->copy(_tweenData);
|
||||
|
||||
_worldTransform = AffineTransformConcat(getNodeToParentTransform(), _worldTransform);
|
||||
_worldInfo->x = _tweenData->x + _position.x;
|
||||
_worldInfo->y = _tweenData->y + _position.y;
|
||||
_worldInfo->scaleX = _tweenData->scaleX * _scaleX;
|
||||
_worldInfo->scaleY = _tweenData->scaleY * _scaleY;
|
||||
_worldInfo->skewX = _tweenData->skewX + _skewX + _rotationX;
|
||||
_worldInfo->skewY = _tweenData->skewY + _skewY - _rotationY;
|
||||
|
||||
if(_parentBone)
|
||||
{
|
||||
_worldTransform = AffineTransformConcat(_worldTransform, _parentBone->_worldTransform);
|
||||
applyParentTransform(_parentBone);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_armatureParentBone)
|
||||
{
|
||||
applyParentTransform(_armatureParentBone);
|
||||
}
|
||||
}
|
||||
|
||||
TransformHelp::nodeToMatrix(*_worldInfo, _worldTransform);
|
||||
|
||||
if (_armatureParentBone)
|
||||
{
|
||||
_worldTransform = AffineTransformConcat(_worldTransform, _armature->getNodeToParentTransform());
|
||||
}
|
||||
}
|
||||
|
||||
DisplayFactory::updateDisplay(this, _displayManager->getCurrentDecorativeDisplay(), delta, _boneTransformDirty || _armature->getArmatureTransformDirty());
|
||||
DisplayFactory::updateDisplay(this, delta, _boneTransformDirty || _armature->getArmatureTransformDirty());
|
||||
|
||||
Object *object = NULL;
|
||||
CCARRAY_FOREACH(_children, object)
|
||||
if (_children)
|
||||
{
|
||||
Bone *childBone = (Bone *)object;
|
||||
childBone->update(delta);
|
||||
for(auto object : *_children)
|
||||
{
|
||||
Bone *childBone = (Bone *)object;
|
||||
childBone->update(delta);
|
||||
}
|
||||
}
|
||||
|
||||
_boneTransformDirty = false;
|
||||
}
|
||||
|
||||
void Bone::applyParentTransform(Bone *parent)
|
||||
{
|
||||
float x = _worldInfo->x;
|
||||
float y = _worldInfo->y;
|
||||
_worldInfo->x = x * parent->_worldTransform.a + y * parent->_worldTransform.c + parent->_worldInfo->x;
|
||||
_worldInfo->y = x * parent->_worldTransform.b + y * parent->_worldTransform.d + parent->_worldInfo->y;
|
||||
_worldInfo->scaleX = _worldInfo->scaleX * parent->_worldInfo->scaleX;
|
||||
_worldInfo->scaleY = _worldInfo->scaleY * parent->_worldInfo->scaleY;
|
||||
_worldInfo->skewX = _worldInfo->skewX + parent->_worldInfo->skewX;
|
||||
_worldInfo->skewY = _worldInfo->skewY + parent->_worldInfo->skewY;
|
||||
}
|
||||
|
||||
|
||||
void Bone::updateDisplayedColor(const Color3B &parentColor)
|
||||
{
|
||||
|
@ -213,11 +268,23 @@ void Bone::updateDisplayedOpacity(GLubyte parentOpacity)
|
|||
updateColor();
|
||||
}
|
||||
|
||||
void Bone::setColor(const Color3B& color)
|
||||
{
|
||||
NodeRGBA::setColor(color);
|
||||
updateColor();
|
||||
}
|
||||
|
||||
void Bone::setOpacity(GLubyte opacity)
|
||||
{
|
||||
NodeRGBA::setOpacity(opacity);
|
||||
updateColor();
|
||||
}
|
||||
|
||||
void Bone::updateColor()
|
||||
{
|
||||
Node *display = _displayManager->getDisplayRenderNode();
|
||||
RGBAProtocol *protocol = dynamic_cast<RGBAProtocol *>(display);
|
||||
if(protocol != NULL)
|
||||
if(protocol != nullptr)
|
||||
{
|
||||
protocol->setColor(Color3B(_displayedColor.r * _tweenData->r / 255, _displayedColor.g * _tweenData->g / 255, _displayedColor.b * _tweenData->b / 255));
|
||||
protocol->setOpacity(_displayedOpacity * _tweenData->a / 255);
|
||||
|
@ -226,7 +293,7 @@ void Bone::updateColor()
|
|||
|
||||
void Bone::updateZOrder()
|
||||
{
|
||||
if (_armature->getArmatureData()->dataVersion >= VERSION_COMBINED)
|
||||
if (_dataVersion >= VERSION_COMBINED)
|
||||
{
|
||||
int zorder = _tweenData->zOrder + _boneData->zOrder;
|
||||
setZOrder(zorder);
|
||||
|
@ -239,8 +306,8 @@ void Bone::updateZOrder()
|
|||
|
||||
void Bone::addChildBone(Bone *child)
|
||||
{
|
||||
CCASSERT( NULL != child, "Argument must be non-nil");
|
||||
CCASSERT( NULL == child->_parentBone, "child already added. It can't be added again");
|
||||
CCASSERT( nullptr != child, "Argument must be non-nil");
|
||||
CCASSERT( nullptr == child->_parentBone, "child already added. It can't be added again");
|
||||
|
||||
if(!_children)
|
||||
{
|
||||
|
@ -257,22 +324,22 @@ void Bone::addChildBone(Bone *child)
|
|||
|
||||
void Bone::removeChildBone(Bone *bone, bool recursion)
|
||||
{
|
||||
if ( _children->getIndexOfObject(bone) != UINT_MAX )
|
||||
if (_children && _children->getIndexOfObject(bone) != UINT_MAX )
|
||||
{
|
||||
if(recursion)
|
||||
{
|
||||
Array *_ccbones = bone->_children;
|
||||
Object *_object = NULL;
|
||||
CCARRAY_FOREACH(_ccbones, _object)
|
||||
Array *ccbones = bone->_children;
|
||||
|
||||
for(auto object : *ccbones)
|
||||
{
|
||||
Bone *_ccBone = (Bone *)_object;
|
||||
bone->removeChildBone(_ccBone, recursion);
|
||||
Bone *ccBone = (Bone *)object;
|
||||
bone->removeChildBone(ccBone, recursion);
|
||||
}
|
||||
}
|
||||
|
||||
bone->setParentBone(NULL);
|
||||
bone->setParentBone(nullptr);
|
||||
|
||||
bone->getDisplayManager()->setCurrentDecorativeDisplay(NULL);
|
||||
bone->getDisplayManager()->setCurrentDecorativeDisplay(nullptr);
|
||||
|
||||
_children->removeObject(bone);
|
||||
}
|
||||
|
@ -280,7 +347,7 @@ void Bone::removeChildBone(Bone *bone, bool recursion)
|
|||
|
||||
void Bone::removeFromParent(bool recursion)
|
||||
{
|
||||
if (NULL != _parentBone)
|
||||
if (nullptr != _parentBone)
|
||||
{
|
||||
_parentBone->removeChildBone(this, recursion);
|
||||
}
|
||||
|
@ -300,13 +367,18 @@ void Bone::setChildArmature(Armature *armature)
|
|||
{
|
||||
if (_childArmature != armature)
|
||||
{
|
||||
if (armature == nullptr && _childArmature)
|
||||
{
|
||||
_childArmature->setParentBone(nullptr);
|
||||
}
|
||||
|
||||
CC_SAFE_RETAIN(armature);
|
||||
CC_SAFE_RELEASE(_childArmature);
|
||||
_childArmature = armature;
|
||||
}
|
||||
}
|
||||
|
||||
Armature *Bone::getChildArmature()
|
||||
Armature *Bone::getChildArmature() const
|
||||
{
|
||||
return _childArmature;
|
||||
}
|
||||
|
@ -322,16 +394,6 @@ void Bone::setZOrder(int zOrder)
|
|||
Node::setZOrder(zOrder);
|
||||
}
|
||||
|
||||
void Bone::setTransformDirty(bool dirty)
|
||||
{
|
||||
_boneTransformDirty = dirty;
|
||||
}
|
||||
|
||||
bool Bone::isTransformDirty()
|
||||
{
|
||||
return _boneTransformDirty;
|
||||
}
|
||||
|
||||
AffineTransform Bone::getNodeToArmatureTransform() const
|
||||
{
|
||||
return _worldTransform;
|
||||
|
@ -347,6 +409,12 @@ Node *Bone::getDisplayRenderNode()
|
|||
return _displayManager->getDisplayRenderNode();
|
||||
}
|
||||
|
||||
DisplayType Bone::getDisplayRenderNodeType()
|
||||
{
|
||||
return _displayManager->getDisplayRenderNodeType();
|
||||
}
|
||||
|
||||
|
||||
void Bone::addDisplay(DisplayData *displayData, int index)
|
||||
{
|
||||
_displayManager->addDisplay(displayData, index);
|
||||
|
@ -357,6 +425,11 @@ void Bone::addDisplay(Node *display, int index)
|
|||
_displayManager->addDisplay(display, index);
|
||||
}
|
||||
|
||||
void Bone::removeDisplay(int index)
|
||||
{
|
||||
_displayManager->removeDisplay(index);
|
||||
}
|
||||
|
||||
void Bone::changeDisplayByIndex(int index, bool force)
|
||||
{
|
||||
_displayManager->changeDisplayByIndex(index, force);
|
||||
|
@ -371,7 +444,34 @@ Array *Bone::getColliderBodyList()
|
|||
return detector->getColliderBodyList();
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Bone::setColliderFilter(ColliderFilter *filter)
|
||||
{
|
||||
Array *array = _displayManager->getDecorativeDisplayList();
|
||||
|
||||
for(auto object : *array)
|
||||
{
|
||||
DecorativeDisplay *decoDisplay = static_cast<DecorativeDisplay *>(object);
|
||||
if (ColliderDetector *detector = decoDisplay->getColliderDetector())
|
||||
{
|
||||
detector->setColliderFilter(filter);
|
||||
}
|
||||
}
|
||||
}
|
||||
ColliderFilter *Bone::getColliderFilter()
|
||||
{
|
||||
if (DecorativeDisplay *decoDisplay = _displayManager->getCurrentDecorativeDisplay())
|
||||
{
|
||||
if (ColliderDetector *detector = decoDisplay->getColliderDetector())
|
||||
{
|
||||
return detector->getColliderFilter();
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ public:
|
|||
/**
|
||||
* Initializes an empty Bone with nothing init.
|
||||
*/
|
||||
virtual bool init();
|
||||
virtual bool init() override;
|
||||
|
||||
/**
|
||||
* Initializes a Bone with the specified name
|
||||
|
@ -86,6 +86,8 @@ public:
|
|||
|
||||
void addDisplay(cocos2d::Node *display, int index);
|
||||
|
||||
void removeDisplay(int index);
|
||||
|
||||
void changeDisplayByIndex(int index, bool force);
|
||||
|
||||
/**
|
||||
|
@ -100,7 +102,7 @@ public:
|
|||
* It will not set the Armature, if you want to add the bone to a Armature, you should use Armature::addBone(Bone *bone, const char* parentName).
|
||||
*
|
||||
* @param parent the parent bone.
|
||||
* NULL : remove this bone from armature
|
||||
* nullptr : remove this bone from armature
|
||||
*/
|
||||
void setParentBone(Bone *parent);
|
||||
|
||||
|
@ -122,10 +124,13 @@ public:
|
|||
*/
|
||||
void removeChildBone(Bone *bone, bool recursion);
|
||||
|
||||
void update(float delta);
|
||||
void update(float delta) override;
|
||||
|
||||
void updateDisplayedColor(const cocos2d::Color3B &parentColor);
|
||||
void updateDisplayedOpacity(GLubyte parentOpacity);
|
||||
void updateDisplayedColor(const cocos2d::Color3B &parentColor) override;
|
||||
void updateDisplayedOpacity(GLubyte parentOpacity) override;
|
||||
|
||||
virtual void setColor(const cocos2d::Color3B& color) override;
|
||||
virtual void setOpacity(GLubyte opacity) override;
|
||||
|
||||
//! Update color to render display
|
||||
void updateColor();
|
||||
|
@ -133,62 +138,103 @@ public:
|
|||
//! Update zorder
|
||||
void updateZOrder();
|
||||
|
||||
virtual void setZOrder(int zOrder);
|
||||
virtual void setZOrder(int zOrder) override;
|
||||
|
||||
Tween *getTween();
|
||||
|
||||
/*
|
||||
* Whether or not the bone's transform property changed. if true, the bone will update the transform.
|
||||
*/
|
||||
virtual void setTransformDirty(bool dirty);
|
||||
|
||||
virtual bool isTransformDirty();
|
||||
virtual void setTransformDirty(bool dirty) { _boneTransformDirty = dirty; }
|
||||
virtual bool isTransformDirty() { return _boneTransformDirty; }
|
||||
|
||||
virtual cocos2d::AffineTransform getNodeToArmatureTransform() const;
|
||||
virtual cocos2d::AffineTransform getNodeToWorldTransform() const override;
|
||||
|
||||
Node *getDisplayRenderNode();
|
||||
DisplayType getDisplayRenderNodeType();
|
||||
|
||||
/*
|
||||
* Get the ColliderBody list in this bone. The object in the Array is ColliderBody.
|
||||
*/
|
||||
virtual cocos2d::Array *getColliderBodyList();
|
||||
|
||||
public:
|
||||
virtual void setColliderFilter(ColliderFilter *filter);
|
||||
virtual ColliderFilter *getColliderFilter();
|
||||
|
||||
virtual void setBoneData(BoneData *boneData);
|
||||
virtual BoneData *getBoneData() const;
|
||||
|
||||
virtual void setArmature(Armature *armature);
|
||||
virtual Armature *getArmature() const;
|
||||
|
||||
virtual void setChildArmature(Armature *childArmature);
|
||||
virtual Armature *getChildArmature() const;
|
||||
|
||||
virtual DisplayManager *getDisplayManager() const { return _displayManager; }
|
||||
|
||||
virtual void setIgnoreMovementBoneData(bool ignore) { _ignoreMovementBoneData = ignore; }
|
||||
virtual bool isIgnoreMovementBoneData() const { return _ignoreMovementBoneData; }
|
||||
|
||||
/*
|
||||
* This function is deprecated, please use isIgnoreMovementBoneData()
|
||||
*/
|
||||
CC_DEPRECATED_ATTRIBUTE virtual bool getIgnoreMovementBoneData() const { return isIgnoreMovementBoneData(); }
|
||||
|
||||
virtual void setBlendType(BlendType type) { _blendType = type; }
|
||||
virtual BlendType getBlendType() const { return _blendType; }
|
||||
|
||||
virtual FrameData *getTweenData() const { return _tweenData; }
|
||||
|
||||
virtual void setName(const std::string &name) { _name = name; }
|
||||
virtual const std::string getName() const { return _name; }
|
||||
|
||||
virtual BaseData *getWorldInfo() const { return _worldInfo; }
|
||||
protected:
|
||||
void applyParentTransform(Bone *parent);
|
||||
|
||||
/*
|
||||
* The origin state of the Bone. Display's state is effected by _boneData, m_pNode, _tweenData
|
||||
* when call setData function, it will copy from the BoneData.
|
||||
*/
|
||||
CC_PROPERTY(BoneData *, _boneData, BoneData);
|
||||
BoneData *_boneData;
|
||||
|
||||
//! A weak reference to the Armature
|
||||
CC_PROPERTY(Armature *, _armature, Armature);
|
||||
Armature *_armature;
|
||||
|
||||
//! A weak reference to the child Armature
|
||||
CC_PROPERTY(Armature *, _childArmature, ChildArmature);
|
||||
Armature *_childArmature;
|
||||
|
||||
CC_SYNTHESIZE(DisplayManager *, _displayManager, DisplayManager)
|
||||
DisplayManager *_displayManager;
|
||||
|
||||
/*
|
||||
* When Armature play an animation, if there is not a MovementBoneData of this bone in this MovementData, this bone will be hidden.
|
||||
* Set IgnoreMovementBoneData to true, then this bone will also be shown.
|
||||
*/
|
||||
CC_SYNTHESIZE(bool, _ignoreMovementBoneData, IgnoreMovementBoneData)
|
||||
bool _ignoreMovementBoneData;
|
||||
|
||||
BlendType _blendType;
|
||||
|
||||
CC_SYNTHESIZE(BlendType, _blendType, BlendType)
|
||||
protected:
|
||||
Tween *_tween; //! Calculate tween effect
|
||||
|
||||
//! Used for making tween effect in every frame
|
||||
CC_SYNTHESIZE_READONLY(FrameData *, _tweenData, TweenData);
|
||||
FrameData *_tweenData;
|
||||
|
||||
CC_SYNTHESIZE(std::string, _name, Name);
|
||||
std::string _name;
|
||||
|
||||
Bone *_parentBone; //! A weak reference to its parent
|
||||
Bone *_parentBone; //! A weak reference to its parent
|
||||
bool _boneTransformDirty; //! Whether or not transform dirty
|
||||
|
||||
//! self Transform, use this to change display's state
|
||||
cocos2d::AffineTransform _worldTransform;
|
||||
|
||||
BaseData *_worldInfo;
|
||||
|
||||
//! Armature's parent bone
|
||||
Bone *_armatureParentBone;
|
||||
|
||||
//! Data version
|
||||
float _dataVersion;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -37,33 +37,85 @@ using namespace cocos2d;
|
|||
namespace cocostudio {
|
||||
|
||||
|
||||
#if ENABLE_PHYSICS_BOX2D_DETECT
|
||||
ColliderFilter::ColliderFilter(unsigned short categoryBits, unsigned short maskBits, signed short groupIndex)
|
||||
: _categoryBits(categoryBits)
|
||||
, _maskBits(maskBits)
|
||||
, _groupIndex(groupIndex)
|
||||
{
|
||||
}
|
||||
|
||||
void ColliderFilter::updateShape(b2Fixture *fixture)
|
||||
{
|
||||
b2Filter filter;
|
||||
filter.categoryBits = _categoryBits;
|
||||
filter.groupIndex = _groupIndex;
|
||||
filter.maskBits = _maskBits;
|
||||
|
||||
fixture->SetFilterData(filter);
|
||||
}
|
||||
|
||||
#elif ENABLE_PHYSICS_CHIPMUNK_DETECT
|
||||
ColliderFilter::ColliderFilter(uintptr_t collisionType, uintptr_t group)
|
||||
: _collisionType(collisionType)
|
||||
, _group(group)
|
||||
{
|
||||
}
|
||||
void ColliderFilter::updateShape(cpShape *shape)
|
||||
{
|
||||
shape->collision_type = _collisionType;
|
||||
shape->group = _group;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ENABLE_PHYSICS_BOX2D_DETECT
|
||||
ColliderBody::ColliderBody(ContourData *contourData)
|
||||
: _fixture(NULL)
|
||||
, _filter(NULL)
|
||||
: _fixture(nullptr)
|
||||
, _contourData(contourData)
|
||||
{
|
||||
CC_SAFE_RETAIN(_contourData);
|
||||
_filter = new ColliderFilter();
|
||||
|
||||
#if ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX
|
||||
_calculatedVertexList = Array::create();
|
||||
CC_SAFE_RETAIN(_calculatedVertexList);
|
||||
#endif
|
||||
}
|
||||
#elif ENABLE_PHYSICS_CHIPMUNK_DETECT
|
||||
|
||||
ColliderBody::ColliderBody(ContourData *contourData)
|
||||
: _shape(NULL)
|
||||
: _shape(nullptr)
|
||||
, _contourData(contourData)
|
||||
{
|
||||
CC_SAFE_RETAIN(_contourData);
|
||||
_filter = new ColliderFilter();
|
||||
|
||||
#if ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX
|
||||
_calculatedVertexList = Array::create();
|
||||
CC_SAFE_RETAIN(_calculatedVertexList);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
ColliderBody::~ColliderBody()
|
||||
{
|
||||
CC_SAFE_RELEASE(_contourData);
|
||||
|
||||
#if ENABLE_PHYSICS_BOX2D_DETECT
|
||||
CC_SAFE_DELETE(_filter);
|
||||
|
||||
#if ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX
|
||||
CC_SAFE_RELEASE(_calculatedVertexList);
|
||||
#endif
|
||||
}
|
||||
|
||||
void ColliderBody::setColliderFilter(ColliderFilter *filter)
|
||||
{
|
||||
*_filter = *filter;
|
||||
}
|
||||
ColliderFilter *ColliderBody::getColliderFilter()
|
||||
{
|
||||
return _filter;
|
||||
}
|
||||
|
||||
|
||||
|
||||
ColliderDetector *ColliderDetector::create()
|
||||
|
@ -75,7 +127,7 @@ ColliderDetector *ColliderDetector::create()
|
|||
return pColliderDetector;
|
||||
}
|
||||
CC_SAFE_DELETE(pColliderDetector);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ColliderDetector *ColliderDetector::create(Bone *bone)
|
||||
|
@ -87,20 +139,22 @@ ColliderDetector *ColliderDetector::create(Bone *bone)
|
|||
return pColliderDetector;
|
||||
}
|
||||
CC_SAFE_DELETE(pColliderDetector);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ColliderDetector::ColliderDetector()
|
||||
: _colliderBodyList(NULL)
|
||||
: _colliderBodyList(nullptr)
|
||||
, _filter(nullptr)
|
||||
, _active(false)
|
||||
{
|
||||
_body = NULL;
|
||||
_body = nullptr;
|
||||
}
|
||||
|
||||
ColliderDetector::~ColliderDetector()
|
||||
{
|
||||
_colliderBodyList->removeAllObjects();
|
||||
CC_SAFE_DELETE(_colliderBodyList);
|
||||
CC_SAFE_DELETE(_filter);
|
||||
}
|
||||
|
||||
bool ColliderDetector::init()
|
||||
|
@ -109,6 +163,8 @@ bool ColliderDetector::init()
|
|||
CCASSERT(_colliderBodyList, "create _colliderBodyList failed!");
|
||||
_colliderBodyList->retain();
|
||||
|
||||
_filter = new ColliderFilter();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -125,12 +181,24 @@ void ColliderDetector::addContourData(ContourData *contourData)
|
|||
ColliderBody *colliderBody = new ColliderBody(contourData);
|
||||
_colliderBodyList->addObject(colliderBody);
|
||||
colliderBody->release();
|
||||
|
||||
|
||||
#if ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX
|
||||
CCArray *calculatedVertexList = colliderBody->getCalculatedVertexList();
|
||||
|
||||
int num = contourData->vertexList.count();
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
ContourVertex2 *newVertex = new ContourVertex2(0, 0);
|
||||
calculatedVertexList->addObject(newVertex);
|
||||
newVertex->release();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void ColliderDetector::addContourDataList(Array *contourDataList)
|
||||
{
|
||||
Object *object = NULL;
|
||||
CCARRAY_FOREACH(contourDataList, object)
|
||||
for(auto object : *contourDataList)
|
||||
{
|
||||
addContourData((ContourData *)object);
|
||||
}
|
||||
|
@ -138,8 +206,7 @@ void ColliderDetector::addContourDataList(Array *contourDataList)
|
|||
|
||||
void ColliderDetector::removeContourData(ContourData *contourData)
|
||||
{
|
||||
Object *object = NULL;
|
||||
CCARRAY_FOREACH(_colliderBodyList, object)
|
||||
for(auto object : *_colliderBodyList)
|
||||
{
|
||||
ColliderBody *body = (ColliderBody*)object;
|
||||
if (body && body->getContourData() == contourData)
|
||||
|
@ -173,40 +240,41 @@ void ColliderDetector::setActive(bool active)
|
|||
}
|
||||
else
|
||||
{
|
||||
Object *object = NULL;
|
||||
CCARRAY_FOREACH(_colliderBodyList, object)
|
||||
for(auto object : *_colliderBodyList)
|
||||
{
|
||||
ColliderBody *colliderBody = (ColliderBody *)object;
|
||||
b2Fixture *fixture = colliderBody->getB2Fixture();
|
||||
|
||||
b2Filter *filter = colliderBody->getB2Filter();
|
||||
*filter = fixture->GetFilterData();
|
||||
|
||||
_body->DestroyFixture(fixture);
|
||||
colliderBody->setB2Fixture(NULL);
|
||||
colliderBody->setB2Fixture(nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
#elif ENABLE_PHYSICS_CHIPMUNK_DETECT
|
||||
if (_body)
|
||||
{
|
||||
Object *object = NULL;
|
||||
if (_active)
|
||||
{
|
||||
CCARRAY_FOREACH(_colliderBodyList, object)
|
||||
for(auto object : *_colliderBodyList)
|
||||
{
|
||||
ColliderBody *colliderBody = (ColliderBody *)object;
|
||||
cpShape *shape = colliderBody->getShape();
|
||||
cpSpaceAddShape(_body->space_private, shape);
|
||||
if(shape->space_private == nullptr)
|
||||
{
|
||||
cpSpaceAddShape(_body->space_private, shape);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CCARRAY_FOREACH(_colliderBodyList, object)
|
||||
for(auto object : *_colliderBodyList)
|
||||
{
|
||||
ColliderBody *colliderBody = (ColliderBody *)object;
|
||||
cpShape *shape = colliderBody->getShape();
|
||||
cpSpaceRemoveShape(_body->space_private, shape);
|
||||
if (shape->space_private != nullptr)
|
||||
{
|
||||
cpSpaceRemoveShape(_body->space_private, shape);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -223,6 +291,33 @@ Array *ColliderDetector::getColliderBodyList()
|
|||
return _colliderBodyList;
|
||||
}
|
||||
|
||||
void ColliderDetector::setColliderFilter(ColliderFilter *filter)
|
||||
{
|
||||
*_filter = *filter;
|
||||
|
||||
for(auto object : *_colliderBodyList)
|
||||
{
|
||||
ColliderBody *colliderBody = (ColliderBody *)object;
|
||||
colliderBody->setColliderFilter(filter);
|
||||
|
||||
#if ENABLE_PHYSICS_BOX2D_DETECT
|
||||
if (colliderBody->getB2Fixture())
|
||||
{
|
||||
colliderBody->getColliderFilter()->updateShape(colliderBody->getB2Fixture());
|
||||
}
|
||||
#elif ENABLE_PHYSICS_CHIPMUNK_DETECT
|
||||
if (colliderBody->getShape())
|
||||
{
|
||||
colliderBody->getColliderFilter()->updateShape(colliderBody->getShape());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
ColliderFilter *ColliderDetector::getColliderFilter()
|
||||
{
|
||||
return _filter;
|
||||
}
|
||||
|
||||
|
||||
Point helpPoint;
|
||||
|
||||
|
@ -233,21 +328,20 @@ void ColliderDetector::updateTransform(AffineTransform &t)
|
|||
return;
|
||||
}
|
||||
|
||||
Object *object = NULL;
|
||||
CCARRAY_FOREACH(_colliderBodyList, object)
|
||||
for(auto object : *_colliderBodyList)
|
||||
{
|
||||
ColliderBody *colliderBody = (ColliderBody *)object;
|
||||
ContourData *contourData = colliderBody->getContourData();
|
||||
|
||||
#if ENABLE_PHYSICS_BOX2D_DETECT
|
||||
b2PolygonShape *shape = NULL;
|
||||
if (_body != NULL)
|
||||
b2PolygonShape *shape = nullptr;
|
||||
if (_body != nullptr)
|
||||
{
|
||||
shape = (b2PolygonShape *)colliderBody->getB2Fixture()->GetShape();
|
||||
}
|
||||
#elif ENABLE_PHYSICS_CHIPMUNK_DETECT
|
||||
cpPolyShape *shape = NULL;
|
||||
if (_body != NULL)
|
||||
cpPolyShape *shape = nullptr;
|
||||
if (_body != nullptr)
|
||||
{
|
||||
shape = (cpPolyShape *)colliderBody->getShape();
|
||||
}
|
||||
|
@ -256,20 +350,29 @@ void ColliderDetector::updateTransform(AffineTransform &t)
|
|||
int num = contourData->vertexList.count();
|
||||
ContourVertex2 **vs = (ContourVertex2 **)contourData->vertexList.data->arr;
|
||||
|
||||
#if ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX
|
||||
ContourVertex2 **cvs = (ContourVertex2 **)colliderBody->getCalculatedVertexList()->data->arr;
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
helpPoint.setPoint( vs[i]->x, vs[i]->y);
|
||||
helpPoint = PointApplyAffineTransform(helpPoint, t);
|
||||
|
||||
|
||||
#if ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX
|
||||
cvs[i]->x = helpPoint.x;
|
||||
cvs[i]->y = helpPoint.y;
|
||||
#endif
|
||||
|
||||
#if ENABLE_PHYSICS_BOX2D_DETECT
|
||||
if (shape != NULL)
|
||||
if (shape != nullptr)
|
||||
{
|
||||
b2Vec2 &bv = shape->m_vertices[i];
|
||||
bv.Set(helpPoint.x / PT_RATIO, helpPoint.y / PT_RATIO);
|
||||
}
|
||||
#elif ENABLE_PHYSICS_CHIPMUNK_DETECT
|
||||
if (shape != NULL)
|
||||
if (shape != nullptr)
|
||||
{
|
||||
cpVect v ;
|
||||
v.x = helpPoint.x;
|
||||
|
@ -280,7 +383,7 @@ void ColliderDetector::updateTransform(AffineTransform &t)
|
|||
}
|
||||
|
||||
#if ENABLE_PHYSICS_CHIPMUNK_DETECT
|
||||
cpConvexHull(num, shape->verts, NULL, NULL, 0);
|
||||
cpConvexHull(num, shape->verts, nullptr, nullptr, 0);
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
cpVect b = shape->verts[(i + 1) % shape->numVerts];
|
||||
|
@ -299,19 +402,18 @@ void ColliderDetector::setBody(b2Body *pBody)
|
|||
{
|
||||
_body = pBody;
|
||||
|
||||
Object *object = NULL;
|
||||
CCARRAY_FOREACH(_colliderBodyList, object)
|
||||
for(auto object : *_colliderBodyList)
|
||||
{
|
||||
ColliderBody *colliderBody = (ColliderBody *)object;
|
||||
|
||||
ContourData *contourData = colliderBody->getContourData();
|
||||
const Array *array = &contourData->vertexList;
|
||||
Object *object = NULL;
|
||||
Object *object = nullptr;
|
||||
|
||||
b2Vec2 *b2bv = new b2Vec2[contourData->vertexList.count()];
|
||||
|
||||
int i = 0;
|
||||
CCARRAY_FOREACH(array, object)
|
||||
for(auto object : *array)
|
||||
{
|
||||
ContourVertex2 *v = (ContourVertex2 *)object;
|
||||
b2bv[i].Set(v->x / PT_RATIO, v->y / PT_RATIO);
|
||||
|
@ -330,25 +432,17 @@ void ColliderDetector::setBody(b2Body *pBody)
|
|||
b2Fixture *fixture = _body->CreateFixture(&fixtureDef);
|
||||
fixture->SetUserData(_bone);
|
||||
|
||||
if (colliderBody->getB2Fixture() != NULL)
|
||||
if (colliderBody->getB2Fixture() != nullptr)
|
||||
{
|
||||
_body->DestroyFixture(colliderBody->getB2Fixture());
|
||||
}
|
||||
colliderBody->setB2Fixture(fixture);
|
||||
|
||||
if (colliderBody->getB2Filter() == NULL)
|
||||
{
|
||||
b2Filter *filter = new b2Filter;
|
||||
colliderBody->setB2Filter(filter);
|
||||
}
|
||||
else
|
||||
{
|
||||
fixture->SetFilterData(*colliderBody->getB2Filter());
|
||||
}
|
||||
colliderBody->getColliderFilter()->updateShape(fixture);
|
||||
}
|
||||
}
|
||||
|
||||
b2Body *ColliderDetector::getBody()
|
||||
b2Body *ColliderDetector::getBody() const
|
||||
{
|
||||
return _body;
|
||||
}
|
||||
|
@ -358,8 +452,7 @@ void ColliderDetector::setBody(cpBody *pBody)
|
|||
{
|
||||
_body = pBody;
|
||||
|
||||
Object *object = NULL;
|
||||
CCARRAY_FOREACH(_colliderBodyList, object)
|
||||
for(auto object : *_colliderBodyList)
|
||||
{
|
||||
ColliderBody *colliderBody = (ColliderBody *)object;
|
||||
|
||||
|
@ -378,15 +471,20 @@ void ColliderDetector::setBody(cpBody *pBody)
|
|||
|
||||
shape->sensor = true;
|
||||
shape->data = _bone;
|
||||
cpSpaceAddShape(_body->space_private, shape);
|
||||
|
||||
if (_active)
|
||||
{
|
||||
cpSpaceAddShape(_body->space_private, shape);
|
||||
}
|
||||
|
||||
colliderBody->setShape(shape);
|
||||
colliderBody->getColliderFilter()->updateShape(shape);
|
||||
|
||||
delete []verts;
|
||||
}
|
||||
}
|
||||
|
||||
cpBody *ColliderDetector::getBody()
|
||||
cpBody *ColliderDetector::getBody() const
|
||||
{
|
||||
return _body;
|
||||
}
|
||||
|
|
|
@ -33,38 +33,93 @@ THE SOFTWARE.
|
|||
#endif
|
||||
|
||||
|
||||
#if ENABLE_PHYSICS_CHIPMUNK_DETECT
|
||||
struct cpBody;
|
||||
struct cpShape;
|
||||
#elif ENABLE_PHYSICS_BOX2D_DETECT
|
||||
class b2Body;
|
||||
class b2Fixture;
|
||||
struct b2Filter;
|
||||
|
||||
struct cpBody;
|
||||
struct cpShape;
|
||||
#endif
|
||||
|
||||
namespace cocostudio {
|
||||
|
||||
class Bone;
|
||||
|
||||
class ColliderBody : public cocos2d::Object
|
||||
|
||||
class ColliderFilter
|
||||
{
|
||||
public:
|
||||
~ColliderFilter() { }
|
||||
#if ENABLE_PHYSICS_BOX2D_DETECT
|
||||
CC_SYNTHESIZE(b2Fixture *, _fixture, B2Fixture)
|
||||
CC_SYNTHESIZE(b2Filter *, _filter, B2Filter)
|
||||
public:
|
||||
ColliderFilter(unsigned short categoryBits = 0x0001, unsigned short maskBits = 0xFFFF, signed short groupIndex = 0);
|
||||
void updateShape(b2Fixture *fixture);
|
||||
|
||||
virtual void setCategoryBits(unsigned short categoryBits) { _categoryBits = categoryBits; }
|
||||
virtual unsigned short getCategoryBits() const { return _categoryBits; }
|
||||
|
||||
virtual void setMaskBits(unsigned short maskBits) { _maskBits = maskBits; }
|
||||
virtual unsigned short getMaskBits() const { return _maskBits; }
|
||||
|
||||
virtual void setGroupIndex(signed short groupIndex) { _groupIndex = groupIndex; }
|
||||
virtual signed short getGroupIndex() const { return _groupIndex; }
|
||||
protected:
|
||||
unsigned short _categoryBits;
|
||||
unsigned short _maskBits;
|
||||
signed short _groupIndex;
|
||||
#elif ENABLE_PHYSICS_CHIPMUNK_DETECT
|
||||
CC_SYNTHESIZE(cpShape *, _shape, Shape)
|
||||
#endif
|
||||
public:
|
||||
ColliderFilter(uintptr_t collisionType = 0, uintptr_t group = 0);
|
||||
void updateShape(cpShape *shape);
|
||||
|
||||
virtual void setCollisionType(uintptr_t collisionType) { _collisionType = collisionType; }
|
||||
virtual uintptr_t getCollisionType() const { return _collisionType; }
|
||||
|
||||
virtual void setGroup(uintptr_t group) { _group = group; }
|
||||
virtual uintptr_t getGroup() const { return _group; }
|
||||
protected:
|
||||
uintptr_t _collisionType;
|
||||
uintptr_t _group;
|
||||
#endif
|
||||
};
|
||||
|
||||
class ColliderBody : public cocos2d::Object
|
||||
{
|
||||
public:
|
||||
ColliderBody(ContourData *contourData);
|
||||
~ColliderBody();
|
||||
|
||||
inline ContourData *getContourData()
|
||||
{
|
||||
return _contourData;
|
||||
}
|
||||
inline ContourData *getContourData() { return _contourData; }
|
||||
|
||||
void setColliderFilter(ColliderFilter *filter);
|
||||
ColliderFilter *getColliderFilter();
|
||||
|
||||
#if ENABLE_PHYSICS_BOX2D_DETECT
|
||||
virtual void setB2Fixture(b2Fixture *fixture) { _fixture = fixture; }
|
||||
virtual b2Fixture *getB2Fixture() const { return _fixture; }
|
||||
#elif ENABLE_PHYSICS_CHIPMUNK_DETECT
|
||||
virtual void setShape(cpShape *shape) { _shape = shape; }
|
||||
virtual cpShape *getShape() const { return _shape; }
|
||||
#endif
|
||||
|
||||
#if ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX
|
||||
virtual const cocos2d::Array *getCalculatedVertexList() const { return _calculatedVertexList; }
|
||||
#endif
|
||||
private:
|
||||
|
||||
#if ENABLE_PHYSICS_BOX2D_DETECT
|
||||
b2Fixture *_fixture;
|
||||
#elif ENABLE_PHYSICS_CHIPMUNK_DETECT
|
||||
cpShape *_shape;
|
||||
#endif
|
||||
|
||||
ContourData *_contourData;
|
||||
ColliderFilter *_filter;
|
||||
|
||||
#if ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX
|
||||
cocos2d::Array *_calculatedVertexList;
|
||||
#endif
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -102,14 +157,29 @@ public:
|
|||
|
||||
cocos2d::Array *getColliderBodyList();
|
||||
|
||||
protected:
|
||||
cocos2d::Array *_colliderBodyList;
|
||||
CC_SYNTHESIZE(Bone *, _bone, Bone);
|
||||
virtual void setColliderFilter(ColliderFilter *filter);
|
||||
virtual ColliderFilter *getColliderFilter();
|
||||
|
||||
virtual void setBone(Bone *bone) { _bone = bone; }
|
||||
virtual Bone *getBone() const { return _bone; }
|
||||
|
||||
#if ENABLE_PHYSICS_BOX2D_DETECT
|
||||
CC_PROPERTY(b2Body *, _body, Body);
|
||||
virtual void setBody(b2Body *body);
|
||||
virtual b2Body *getBody() const;
|
||||
#elif ENABLE_PHYSICS_CHIPMUNK_DETECT
|
||||
CC_PROPERTY(cpBody *, _body, Body);
|
||||
virtual void setBody(cpBody *body);
|
||||
virtual cpBody *getBody() const;
|
||||
#endif
|
||||
protected:
|
||||
cocos2d::Array *_colliderBodyList;
|
||||
ColliderFilter *_filter;
|
||||
|
||||
Bone *_bone;
|
||||
|
||||
#if ENABLE_PHYSICS_BOX2D_DETECT
|
||||
b2Body *_body;
|
||||
#elif ENABLE_PHYSICS_CHIPMUNK_DETECT
|
||||
cpBody *_body;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
|
|
@ -133,26 +133,24 @@ static const char *VERTEX_POINT = "vertex";
|
|||
static const char *COLOR_INFO = "color";
|
||||
|
||||
static const char *CONFIG_FILE_PATH = "config_file_path";
|
||||
|
||||
static const char *CONTENT_SCALE = "content_scale";
|
||||
|
||||
namespace cocostudio {
|
||||
|
||||
|
||||
std::vector<std::string> s_arrConfigFileList;
|
||||
|
||||
float s_PositionReadScale = 1;
|
||||
static float s_FlashToolVersion = VERSION_2_0;
|
||||
static float s_CocoStudioVersion = VERSION_COMBINED;
|
||||
|
||||
static std::string s_BasefilePath = "";
|
||||
std::vector<std::string> DataReaderHelper::_configFileList;
|
||||
|
||||
DataReaderHelper *DataReaderHelper::_dataReaderHelper = NULL;
|
||||
DataReaderHelper *DataReaderHelper::_dataReaderHelper = nullptr;
|
||||
|
||||
|
||||
|
||||
//! Async load
|
||||
void DataReaderHelper::loadData()
|
||||
{
|
||||
AsyncStruct *pAsyncStruct = NULL;
|
||||
AsyncStruct *pAsyncStruct = nullptr;
|
||||
|
||||
while (true)
|
||||
{
|
||||
|
@ -183,9 +181,11 @@ void DataReaderHelper::loadData()
|
|||
_asyncStructQueueMutex.unlock();
|
||||
}
|
||||
|
||||
// generate image info
|
||||
// generate data info
|
||||
DataInfo *pDataInfo = new DataInfo();
|
||||
pDataInfo->asyncStruct = pAsyncStruct;
|
||||
pDataInfo->filename = pAsyncStruct->filename;
|
||||
pDataInfo->baseFilePath = pAsyncStruct->baseFilePath;
|
||||
|
||||
if (pAsyncStruct->configType == DragonBone_XML)
|
||||
{
|
||||
|
@ -202,12 +202,12 @@ void DataReaderHelper::loadData()
|
|||
_dataInfoMutex.unlock();
|
||||
}
|
||||
|
||||
if( _asyncStructQueue != NULL )
|
||||
if( _asyncStructQueue != nullptr )
|
||||
{
|
||||
delete _asyncStructQueue;
|
||||
_asyncStructQueue = NULL;
|
||||
_asyncStructQueue = nullptr;
|
||||
delete _dataQueue;
|
||||
_dataQueue = NULL;
|
||||
_dataQueue = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -235,14 +235,10 @@ float DataReaderHelper::getPositionReadScale()
|
|||
|
||||
void DataReaderHelper::purge()
|
||||
{
|
||||
DataReaderHelper::clear();
|
||||
_configFileList.clear();
|
||||
CC_SAFE_RELEASE_NULL(_dataReaderHelper);
|
||||
}
|
||||
|
||||
void DataReaderHelper::clear()
|
||||
{
|
||||
s_arrConfigFileList.clear();
|
||||
}
|
||||
|
||||
DataReaderHelper::DataReaderHelper()
|
||||
: _loadingThread(nullptr)
|
||||
|
@ -263,7 +259,7 @@ DataReaderHelper::~DataReaderHelper()
|
|||
if (_loadingThread) _loadingThread->join();
|
||||
|
||||
CC_SAFE_DELETE(_loadingThread);
|
||||
_dataReaderHelper = NULL;
|
||||
_dataReaderHelper = nullptr;
|
||||
}
|
||||
|
||||
void DataReaderHelper::addDataFromFile(const char *filePath)
|
||||
|
@ -271,26 +267,27 @@ void DataReaderHelper::addDataFromFile(const char *filePath)
|
|||
/*
|
||||
* Check if file is already added to ArmatureDataManager, if then return.
|
||||
*/
|
||||
for(unsigned int i = 0; i < s_arrConfigFileList.size(); i++)
|
||||
for(unsigned int i = 0; i < _configFileList.size(); i++)
|
||||
{
|
||||
if (s_arrConfigFileList[i].compare(filePath) == 0)
|
||||
if (_configFileList[i].compare(filePath) == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
s_arrConfigFileList.push_back(filePath);
|
||||
_configFileList.push_back(filePath);
|
||||
|
||||
|
||||
//! find the base file path
|
||||
s_BasefilePath = filePath;
|
||||
size_t pos = s_BasefilePath.find_last_of("/");
|
||||
std::string basefilePath = filePath;
|
||||
size_t pos = basefilePath.find_last_of("/");
|
||||
|
||||
if (pos != std::string::npos)
|
||||
{
|
||||
s_BasefilePath = s_BasefilePath.substr(0, pos + 1);
|
||||
basefilePath = basefilePath.substr(0, pos + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
s_BasefilePath = "";
|
||||
basefilePath = "";
|
||||
}
|
||||
|
||||
|
||||
|
@ -298,28 +295,33 @@ void DataReaderHelper::addDataFromFile(const char *filePath)
|
|||
size_t startPos = filePathStr.find_last_of(".");
|
||||
std::string str = &filePathStr[startPos];
|
||||
|
||||
unsigned long size;
|
||||
long size;
|
||||
std::string fullPath = CCFileUtils::getInstance()->fullPathForFilename(filePath);
|
||||
const char *pFileContent = (char *)CCFileUtils::getInstance()->getFileData(fullPath.c_str() , "r", &size);
|
||||
|
||||
DataInfo dataInfo;
|
||||
dataInfo.filename = filePathStr;
|
||||
dataInfo.asyncStruct = nullptr;
|
||||
dataInfo.baseFilePath = basefilePath;
|
||||
|
||||
if (str.compare(".xml") == 0)
|
||||
{
|
||||
DataReaderHelper::addDataFromCache(pFileContent);
|
||||
DataReaderHelper::addDataFromCache(pFileContent, &dataInfo);
|
||||
}
|
||||
else if(str.compare(".json") == 0 || str.compare(".ExportJson") == 0)
|
||||
{
|
||||
DataReaderHelper::addDataFromJsonCache(pFileContent);
|
||||
DataReaderHelper::addDataFromJsonCache(pFileContent, &dataInfo);
|
||||
}
|
||||
}
|
||||
|
||||
void DataReaderHelper::addDataFromFileAsync(const char *filePath, Object *target, SEL_SCHEDULE selector)
|
||||
void DataReaderHelper::addDataFromFileAsync(const char *imagePath, const char *plistPath, const char *filePath, Object *target, SEL_SCHEDULE selector)
|
||||
{
|
||||
/*
|
||||
* Check if file is already added to ArmatureDataManager, if then return.
|
||||
*/
|
||||
for(unsigned int i = 0; i < s_arrConfigFileList.size(); i++)
|
||||
for(unsigned int i = 0; i < _configFileList.size(); i++)
|
||||
{
|
||||
if (s_arrConfigFileList[i].compare(filePath) == 0)
|
||||
if (_configFileList[i].compare(filePath) == 0)
|
||||
{
|
||||
if (target && selector)
|
||||
{
|
||||
|
@ -335,23 +337,24 @@ void DataReaderHelper::addDataFromFileAsync(const char *filePath, Object *target
|
|||
return;
|
||||
}
|
||||
}
|
||||
s_arrConfigFileList.push_back(filePath);
|
||||
_configFileList.push_back(filePath);
|
||||
|
||||
//! find the base file path
|
||||
s_BasefilePath = filePath;
|
||||
size_t pos = s_BasefilePath.find_last_of("/");
|
||||
std::string basefilePath = filePath;
|
||||
size_t pos = basefilePath.find_last_of("/");
|
||||
|
||||
if (pos != std::string::npos)
|
||||
{
|
||||
s_BasefilePath = s_BasefilePath.substr(0, pos + 1);
|
||||
basefilePath = basefilePath.substr(0, pos + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
s_BasefilePath = "";
|
||||
basefilePath = "";
|
||||
}
|
||||
|
||||
|
||||
// lazy init
|
||||
if (_asyncStructQueue == NULL)
|
||||
if (_asyncStructQueue == nullptr)
|
||||
{
|
||||
_asyncStructQueue = new std::queue<AsyncStruct *>();
|
||||
_dataQueue = new std::queue<DataInfo *>();
|
||||
|
@ -378,18 +381,20 @@ void DataReaderHelper::addDataFromFileAsync(const char *filePath, Object *target
|
|||
// generate async struct
|
||||
AsyncStruct *data = new AsyncStruct();
|
||||
data->filename = filePath;
|
||||
data->baseFilePath = s_BasefilePath;
|
||||
data->baseFilePath = basefilePath;
|
||||
data->target = target;
|
||||
data->selector = selector;
|
||||
data->autoLoadSpriteFile = ArmatureDataManager::getInstance()->isAutoLoadSpriteFile();
|
||||
|
||||
data->imagePath = imagePath;
|
||||
data->plistPath = plistPath;
|
||||
|
||||
std::string filePathStr = filePath;
|
||||
size_t startPos = filePathStr.find_last_of(".");
|
||||
std::string str = &filePathStr[startPos];
|
||||
|
||||
std::string fullPath = CCFileUtils::getInstance()->fullPathForFilename(filePath);
|
||||
unsigned long size;
|
||||
long size;
|
||||
data->fileContent = (char *)CCFileUtils::getInstance()->getFileData(fullPath.c_str() , "r", &size);
|
||||
|
||||
if (str.compare(".xml") == 0)
|
||||
|
@ -428,10 +433,20 @@ void DataReaderHelper::addDataAsyncCallBack(float dt)
|
|||
|
||||
AsyncStruct *pAsyncStruct = pDataInfo->asyncStruct;
|
||||
|
||||
|
||||
if (pAsyncStruct->imagePath != "" && pAsyncStruct->plistPath != "")
|
||||
{
|
||||
_getFileMutex.lock();
|
||||
ArmatureDataManager::getInstance()->addSpriteFrameFromFile(pAsyncStruct->plistPath.c_str(), pAsyncStruct->imagePath.c_str());
|
||||
_getFileMutex.unlock();
|
||||
}
|
||||
|
||||
while (!pDataInfo->configFileQueue.empty())
|
||||
{
|
||||
std::string configPath = pDataInfo->configFileQueue.front();
|
||||
_getFileMutex.lock();
|
||||
ArmatureDataManager::getInstance()->addSpriteFrameFromFile((pAsyncStruct->baseFilePath + configPath + ".plist").c_str(), (pAsyncStruct->baseFilePath + configPath + ".png").c_str());
|
||||
_getFileMutex.unlock();
|
||||
pDataInfo->configFileQueue.pop();
|
||||
}
|
||||
|
||||
|
@ -460,7 +475,22 @@ void DataReaderHelper::addDataAsyncCallBack(float dt)
|
|||
}
|
||||
|
||||
|
||||
void DataReaderHelper::removeConfigFile(const char *configFile)
|
||||
{
|
||||
std::vector<std::string>::iterator it = _configFileList.end();
|
||||
for (std::vector<std::string>::iterator i = _configFileList.begin(); i != _configFileList.end(); i++)
|
||||
{
|
||||
if (*i == configFile)
|
||||
{
|
||||
it = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (it != _configFileList.end())
|
||||
{
|
||||
_configFileList.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -472,7 +502,7 @@ void DataReaderHelper::addDataFromCache(const char *pFileContent, DataInfo *data
|
|||
tinyxml2::XMLElement *root = document.RootElement();
|
||||
CCASSERT(root, "XML error or XML is empty.");
|
||||
|
||||
root->QueryFloatAttribute(VERSION, &s_FlashToolVersion);
|
||||
root->QueryFloatAttribute(VERSION, &dataInfo->flashToolVersion);
|
||||
|
||||
|
||||
/*
|
||||
|
@ -482,15 +512,15 @@ void DataReaderHelper::addDataFromCache(const char *pFileContent, DataInfo *data
|
|||
tinyxml2::XMLElement *armatureXML = armaturesXML->FirstChildElement(ARMATURE);
|
||||
while(armatureXML)
|
||||
{
|
||||
ArmatureData *armatureData = DataReaderHelper::decodeArmature(armatureXML);
|
||||
ArmatureData *armatureData = DataReaderHelper::decodeArmature(armatureXML, dataInfo);
|
||||
|
||||
if (dataInfo)
|
||||
if (dataInfo->asyncStruct)
|
||||
{
|
||||
_dataReaderHelper->_addDataMutex.lock();
|
||||
}
|
||||
ArmatureDataManager::getInstance()->addArmatureData(armatureData->name.c_str(), armatureData);
|
||||
ArmatureDataManager::getInstance()->addArmatureData(armatureData->name.c_str(), armatureData, dataInfo->filename.c_str());
|
||||
armatureData->release();
|
||||
if (dataInfo)
|
||||
if (dataInfo->asyncStruct)
|
||||
{
|
||||
_dataReaderHelper->_addDataMutex.unlock();
|
||||
}
|
||||
|
@ -506,14 +536,14 @@ void DataReaderHelper::addDataFromCache(const char *pFileContent, DataInfo *data
|
|||
tinyxml2::XMLElement *animationXML = animationsXML->FirstChildElement(ANIMATION);
|
||||
while(animationXML)
|
||||
{
|
||||
AnimationData *animationData = DataReaderHelper::decodeAnimation(animationXML);
|
||||
if (dataInfo)
|
||||
AnimationData *animationData = DataReaderHelper::decodeAnimation(animationXML, dataInfo);
|
||||
if (dataInfo->asyncStruct)
|
||||
{
|
||||
_dataReaderHelper->_addDataMutex.lock();
|
||||
}
|
||||
ArmatureDataManager::getInstance()->addAnimationData(animationData->name.c_str(), animationData);
|
||||
ArmatureDataManager::getInstance()->addAnimationData(animationData->name.c_str(), animationData, dataInfo->filename.c_str());
|
||||
animationData->release();
|
||||
if (dataInfo)
|
||||
if (dataInfo->asyncStruct)
|
||||
{
|
||||
_dataReaderHelper->_addDataMutex.unlock();
|
||||
}
|
||||
|
@ -528,15 +558,15 @@ void DataReaderHelper::addDataFromCache(const char *pFileContent, DataInfo *data
|
|||
tinyxml2::XMLElement *textureXML = texturesXML->FirstChildElement(SUB_TEXTURE);
|
||||
while(textureXML)
|
||||
{
|
||||
TextureData *textureData = DataReaderHelper::decodeTexture(textureXML);
|
||||
TextureData *textureData = DataReaderHelper::decodeTexture(textureXML, dataInfo);
|
||||
|
||||
if (dataInfo)
|
||||
if (dataInfo->asyncStruct)
|
||||
{
|
||||
_dataReaderHelper->_addDataMutex.lock();
|
||||
}
|
||||
ArmatureDataManager::getInstance()->addTextureData(textureData->name.c_str(), textureData);
|
||||
ArmatureDataManager::getInstance()->addTextureData(textureData->name.c_str(), textureData, dataInfo->filename.c_str());
|
||||
textureData->release();
|
||||
if (dataInfo)
|
||||
if (dataInfo->asyncStruct)
|
||||
{
|
||||
_dataReaderHelper->_addDataMutex.unlock();
|
||||
}
|
||||
|
@ -544,7 +574,7 @@ void DataReaderHelper::addDataFromCache(const char *pFileContent, DataInfo *data
|
|||
}
|
||||
}
|
||||
|
||||
ArmatureData *DataReaderHelper::decodeArmature(tinyxml2::XMLElement *armatureXML)
|
||||
ArmatureData *DataReaderHelper::decodeArmature(tinyxml2::XMLElement *armatureXML, DataInfo *dataInfo)
|
||||
{
|
||||
ArmatureData *armatureData = new ArmatureData();
|
||||
armatureData->init();
|
||||
|
@ -561,7 +591,7 @@ ArmatureData *DataReaderHelper::decodeArmature(tinyxml2::XMLElement *armatureXML
|
|||
* If this bone have parent, then get the parent bone xml
|
||||
*/
|
||||
const char *parentName = boneXML->Attribute(A_PARENT);
|
||||
tinyxml2::XMLElement *parentXML = NULL;
|
||||
tinyxml2::XMLElement *parentXML = nullptr;
|
||||
if (parentName)
|
||||
{
|
||||
parentXML = armatureXML->FirstChildElement(BONE);
|
||||
|
@ -576,7 +606,7 @@ ArmatureData *DataReaderHelper::decodeArmature(tinyxml2::XMLElement *armatureXML
|
|||
}
|
||||
}
|
||||
|
||||
BoneData *boneData = decodeBone(boneXML, parentXML);
|
||||
BoneData *boneData = decodeBone(boneXML, parentXML, dataInfo);
|
||||
armatureData->addBoneData(boneData);
|
||||
boneData->release();
|
||||
|
||||
|
@ -586,7 +616,7 @@ ArmatureData *DataReaderHelper::decodeArmature(tinyxml2::XMLElement *armatureXML
|
|||
return armatureData;
|
||||
}
|
||||
|
||||
BoneData *DataReaderHelper::decodeBone(tinyxml2::XMLElement *boneXML, tinyxml2::XMLElement *parentXml)
|
||||
BoneData *DataReaderHelper::decodeBone(tinyxml2::XMLElement *boneXML, tinyxml2::XMLElement *parentXml, DataInfo *dataInfo)
|
||||
{
|
||||
BoneData *boneData = new BoneData();
|
||||
boneData->init();
|
||||
|
@ -594,7 +624,7 @@ BoneData *DataReaderHelper::decodeBone(tinyxml2::XMLElement *boneXML, tinyxml2::
|
|||
std::string name = boneXML->Attribute(A_NAME);
|
||||
boneData->name = name;
|
||||
|
||||
if( boneXML->Attribute(A_PARENT) != NULL )
|
||||
if( boneXML->Attribute(A_PARENT) != nullptr )
|
||||
{
|
||||
boneData->parentName = boneXML->Attribute(A_PARENT);
|
||||
}
|
||||
|
@ -604,7 +634,7 @@ BoneData *DataReaderHelper::decodeBone(tinyxml2::XMLElement *boneXML, tinyxml2::
|
|||
tinyxml2::XMLElement *displayXML = boneXML->FirstChildElement(DISPLAY);
|
||||
while(displayXML)
|
||||
{
|
||||
DisplayData *displayData = decodeBoneDisplay(displayXML);
|
||||
DisplayData *displayData = decodeBoneDisplay(displayXML, dataInfo);
|
||||
boneData->addDisplayData(displayData);
|
||||
displayData->release();
|
||||
|
||||
|
@ -614,7 +644,7 @@ BoneData *DataReaderHelper::decodeBone(tinyxml2::XMLElement *boneXML, tinyxml2::
|
|||
return boneData;
|
||||
}
|
||||
|
||||
DisplayData *DataReaderHelper::decodeBoneDisplay(tinyxml2::XMLElement *displayXML)
|
||||
DisplayData *DataReaderHelper::decodeBoneDisplay(tinyxml2::XMLElement *displayXML, DataInfo *dataInfo)
|
||||
{
|
||||
int _isArmature = 0;
|
||||
|
||||
|
@ -641,7 +671,7 @@ DisplayData *DataReaderHelper::decodeBoneDisplay(tinyxml2::XMLElement *displayXM
|
|||
}
|
||||
|
||||
|
||||
if(displayXML->Attribute(A_NAME) != NULL )
|
||||
if(displayXML->Attribute(A_NAME) != nullptr )
|
||||
{
|
||||
if(!_isArmature)
|
||||
{
|
||||
|
@ -657,7 +687,7 @@ DisplayData *DataReaderHelper::decodeBoneDisplay(tinyxml2::XMLElement *displayXM
|
|||
return displayData;
|
||||
}
|
||||
|
||||
AnimationData *DataReaderHelper::decodeAnimation(tinyxml2::XMLElement *animationXML)
|
||||
AnimationData *DataReaderHelper::decodeAnimation(tinyxml2::XMLElement *animationXML, DataInfo *dataInfo)
|
||||
{
|
||||
AnimationData *aniData = new AnimationData();
|
||||
|
||||
|
@ -671,7 +701,7 @@ AnimationData *DataReaderHelper::decodeAnimation(tinyxml2::XMLElement *animation
|
|||
|
||||
while( movementXML )
|
||||
{
|
||||
MovementData *movementData = decodeMovement(movementXML, armatureData);
|
||||
MovementData *movementData = decodeMovement(movementXML, armatureData, dataInfo);
|
||||
aniData->addMovement(movementData);
|
||||
movementData->release();
|
||||
|
||||
|
@ -682,7 +712,7 @@ AnimationData *DataReaderHelper::decodeAnimation(tinyxml2::XMLElement *animation
|
|||
return aniData;
|
||||
}
|
||||
|
||||
MovementData *DataReaderHelper::decodeMovement(tinyxml2::XMLElement *movementXML, ArmatureData *armatureData)
|
||||
MovementData *DataReaderHelper::decodeMovement(tinyxml2::XMLElement *movementXML, ArmatureData *armatureData, DataInfo *dataInfo)
|
||||
{
|
||||
MovementData *movementData = new MovementData();
|
||||
|
||||
|
@ -710,19 +740,19 @@ MovementData *DataReaderHelper::decodeMovement(tinyxml2::XMLElement *movementXML
|
|||
}
|
||||
|
||||
const char *_easing = movementXML->Attribute(A_TWEEN_EASING);
|
||||
if(_easing != NULL)
|
||||
if(_easing != nullptr)
|
||||
{
|
||||
std::string str = _easing;
|
||||
if(str.compare(FL_NAN) != 0)
|
||||
{
|
||||
if( movementXML->QueryIntAttribute(A_TWEEN_EASING, &(tweenEasing)) == tinyxml2::XML_SUCCESS)
|
||||
{
|
||||
movementData->tweenEasing = (CCTweenType)tweenEasing;
|
||||
movementData->tweenEasing = tweenEasing == 2 ? Sine_EaseInOut : (TweenType)tweenEasing;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
movementData->tweenEasing = TWEEN_EASING_MAX;
|
||||
movementData->tweenEasing = Linear;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -743,7 +773,7 @@ MovementData *DataReaderHelper::decodeMovement(tinyxml2::XMLElement *movementXML
|
|||
std::string parentName = boneData->parentName;
|
||||
|
||||
|
||||
tinyxml2::XMLElement *parentXml = NULL;
|
||||
tinyxml2::XMLElement *parentXml = nullptr;
|
||||
if (parentName.length() != 0)
|
||||
{
|
||||
parentXml = movementXML->FirstChildElement(BONE);
|
||||
|
@ -758,7 +788,7 @@ MovementData *DataReaderHelper::decodeMovement(tinyxml2::XMLElement *movementXML
|
|||
}
|
||||
}
|
||||
|
||||
MovementBoneData *moveBoneData = decodeMovementBone(movBoneXml, parentXml, boneData);
|
||||
MovementBoneData *moveBoneData = decodeMovementBone(movBoneXml, parentXml, boneData, dataInfo);
|
||||
movementData->addMovementBoneData(moveBoneData);
|
||||
moveBoneData->release();
|
||||
|
||||
|
@ -769,7 +799,7 @@ MovementData *DataReaderHelper::decodeMovement(tinyxml2::XMLElement *movementXML
|
|||
}
|
||||
|
||||
|
||||
MovementBoneData *DataReaderHelper::decodeMovementBone(tinyxml2::XMLElement *movBoneXml, tinyxml2::XMLElement *parentXml, BoneData *boneData)
|
||||
MovementBoneData *DataReaderHelper::decodeMovementBone(tinyxml2::XMLElement *movBoneXml, tinyxml2::XMLElement *parentXml, BoneData *boneData, DataInfo *dataInfo)
|
||||
{
|
||||
MovementBoneData *movBoneData = new MovementBoneData();
|
||||
movBoneData->init();
|
||||
|
@ -797,14 +827,14 @@ MovementBoneData *DataReaderHelper::decodeMovementBone(tinyxml2::XMLElement *mov
|
|||
int parentTotalDuration = 0;
|
||||
int currentDuration = 0;
|
||||
|
||||
tinyxml2::XMLElement *parentFrameXML = NULL;
|
||||
tinyxml2::XMLElement *parentFrameXML = nullptr;
|
||||
|
||||
std::vector<tinyxml2::XMLElement *> parentXmlList;
|
||||
|
||||
/*
|
||||
* get the parent frame xml list, we need get the origin data
|
||||
*/
|
||||
if( parentXml != NULL )
|
||||
if( parentXml != nullptr )
|
||||
{
|
||||
parentFrameXML = parentXml->FirstChildElement(FRAME);
|
||||
while (parentFrameXML)
|
||||
|
@ -813,7 +843,7 @@ MovementBoneData *DataReaderHelper::decodeMovementBone(tinyxml2::XMLElement *mov
|
|||
parentFrameXML = parentFrameXML->NextSiblingElement(FRAME);
|
||||
}
|
||||
|
||||
parentFrameXML = NULL;
|
||||
parentFrameXML = nullptr;
|
||||
|
||||
length = parentXmlList.size();
|
||||
}
|
||||
|
@ -844,7 +874,7 @@ MovementBoneData *DataReaderHelper::decodeMovementBone(tinyxml2::XMLElement *mov
|
|||
}
|
||||
}
|
||||
|
||||
FrameData *frameData = decodeFrame( frameXML, parentFrameXML, boneData);
|
||||
FrameData *frameData = decodeFrame( frameXML, parentFrameXML, boneData, dataInfo);
|
||||
movBoneData->addFrameData(frameData);
|
||||
frameData->release();
|
||||
|
||||
|
@ -888,33 +918,33 @@ MovementBoneData *DataReaderHelper::decodeMovementBone(tinyxml2::XMLElement *mov
|
|||
return movBoneData;
|
||||
}
|
||||
|
||||
FrameData *DataReaderHelper::decodeFrame(tinyxml2::XMLElement *frameXML, tinyxml2::XMLElement *parentFrameXml, BoneData *boneData)
|
||||
FrameData *DataReaderHelper::decodeFrame(tinyxml2::XMLElement *frameXML, tinyxml2::XMLElement *parentFrameXml, BoneData *boneData, DataInfo *dataInfo)
|
||||
{
|
||||
float x, y, scale_x, scale_y, skew_x, skew_y = 0;
|
||||
int duration, displayIndex, zOrder, tweenEasing, blendType = 0;
|
||||
|
||||
FrameData *frameData = new FrameData();
|
||||
|
||||
if(frameXML->Attribute(A_MOVEMENT) != NULL)
|
||||
if(frameXML->Attribute(A_MOVEMENT) != nullptr)
|
||||
{
|
||||
frameData->strMovement = frameXML->Attribute(A_MOVEMENT);
|
||||
}
|
||||
if(frameXML->Attribute(A_EVENT) != NULL)
|
||||
if(frameXML->Attribute(A_EVENT) != nullptr)
|
||||
{
|
||||
frameData->strEvent = frameXML->Attribute(A_EVENT);
|
||||
}
|
||||
if(frameXML->Attribute(A_SOUND) != NULL)
|
||||
if(frameXML->Attribute(A_SOUND) != nullptr)
|
||||
{
|
||||
frameData->strSound = frameXML->Attribute(A_SOUND);
|
||||
}
|
||||
if(frameXML->Attribute(A_SOUND_EFFECT) != NULL)
|
||||
if(frameXML->Attribute(A_SOUND_EFFECT) != nullptr)
|
||||
{
|
||||
frameData->strSoundEffect = frameXML->Attribute(A_SOUND_EFFECT);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (s_FlashToolVersion >= VERSION_2_0)
|
||||
if (dataInfo->flashToolVersion >= VERSION_2_0)
|
||||
{
|
||||
if(frameXML->QueryFloatAttribute(A_COCOS2DX_X, &x) == tinyxml2::XML_SUCCESS)
|
||||
{
|
||||
|
@ -1000,19 +1030,19 @@ FrameData *DataReaderHelper::decodeFrame(tinyxml2::XMLElement *frameXML, tinyxm
|
|||
|
||||
|
||||
const char *_easing = frameXML->Attribute(A_TWEEN_EASING);
|
||||
if(_easing != NULL)
|
||||
if(_easing != nullptr)
|
||||
{
|
||||
std::string str = _easing;
|
||||
if(str.compare(FL_NAN) != 0)
|
||||
{
|
||||
if( frameXML->QueryIntAttribute(A_TWEEN_EASING, &(tweenEasing)) == tinyxml2::XML_SUCCESS)
|
||||
{
|
||||
frameData->tweenEasing = (CCTweenType)tweenEasing;
|
||||
frameData->tweenEasing = tweenEasing == 2 ? Sine_EaseInOut : (TweenType)tweenEasing;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
frameData->tweenEasing = TWEEN_EASING_MAX;
|
||||
frameData->tweenEasing = Linear;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1022,7 +1052,7 @@ FrameData *DataReaderHelper::decodeFrame(tinyxml2::XMLElement *frameXML, tinyxm
|
|||
* recalculate frame data from parent frame data, use for translate matrix
|
||||
*/
|
||||
BaseData helpNode;
|
||||
if (s_FlashToolVersion >= VERSION_2_0)
|
||||
if (dataInfo->flashToolVersion >= VERSION_2_0)
|
||||
{
|
||||
parentFrameXml->QueryFloatAttribute(A_COCOS2DX_X, &helpNode.x);
|
||||
parentFrameXml->QueryFloatAttribute(A_COCOS2DX_Y, &helpNode.y);
|
||||
|
@ -1046,19 +1076,19 @@ FrameData *DataReaderHelper::decodeFrame(tinyxml2::XMLElement *frameXML, tinyxm
|
|||
return frameData;
|
||||
}
|
||||
|
||||
TextureData *DataReaderHelper::decodeTexture(tinyxml2::XMLElement *textureXML)
|
||||
TextureData *DataReaderHelper::decodeTexture(tinyxml2::XMLElement *textureXML, DataInfo *dataInfo)
|
||||
{
|
||||
TextureData *textureData = new TextureData();
|
||||
textureData->init();
|
||||
|
||||
if( textureXML->Attribute(A_NAME) != NULL)
|
||||
if( textureXML->Attribute(A_NAME) != nullptr)
|
||||
{
|
||||
textureData->name = textureXML->Attribute(A_NAME);
|
||||
}
|
||||
|
||||
float px, py, width, height = 0;
|
||||
|
||||
if(s_FlashToolVersion >= VERSION_2_0)
|
||||
if(dataInfo->flashToolVersion >= VERSION_2_0)
|
||||
{
|
||||
textureXML->QueryFloatAttribute(A_COCOS2D_PIVOT_X, &px);
|
||||
textureXML->QueryFloatAttribute(A_COCOS2D_PIVOT_Y, &py);
|
||||
|
@ -1082,7 +1112,7 @@ TextureData *DataReaderHelper::decodeTexture(tinyxml2::XMLElement *textureXML)
|
|||
|
||||
while (contourXML)
|
||||
{
|
||||
ContourData *contourData = decodeContour(contourXML);
|
||||
ContourData *contourData = decodeContour(contourXML, dataInfo);
|
||||
textureData->addContourData(contourData);
|
||||
contourData->release();
|
||||
|
||||
|
@ -1092,7 +1122,7 @@ TextureData *DataReaderHelper::decodeTexture(tinyxml2::XMLElement *textureXML)
|
|||
return textureData;
|
||||
}
|
||||
|
||||
ContourData *DataReaderHelper::decodeContour(tinyxml2::XMLElement *contourXML)
|
||||
ContourData *DataReaderHelper::decodeContour(tinyxml2::XMLElement *contourXML, DataInfo *dataInfo)
|
||||
{
|
||||
ContourData *contourData = new ContourData();
|
||||
contourData->init();
|
||||
|
@ -1123,20 +1153,22 @@ void DataReaderHelper::addDataFromJsonCache(const char *fileContent, DataInfo *d
|
|||
JsonDictionary json;
|
||||
json.initWithDescription(fileContent);
|
||||
|
||||
dataInfo->contentScale = json.getItemFloatValue(CONTENT_SCALE, 1);
|
||||
|
||||
// Decode armatures
|
||||
int length = json.getArrayItemCount(ARMATURE_DATA);
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
JsonDictionary *armatureDic = json.getSubItemFromArray(ARMATURE_DATA, i);
|
||||
ArmatureData *armatureData = decodeArmature(*armatureDic);
|
||||
ArmatureData *armatureData = decodeArmature(*armatureDic, dataInfo);
|
||||
|
||||
if (dataInfo)
|
||||
if (dataInfo->asyncStruct)
|
||||
{
|
||||
_dataReaderHelper->_addDataMutex.lock();
|
||||
}
|
||||
ArmatureDataManager::getInstance()->addArmatureData(armatureData->name.c_str(), armatureData);
|
||||
armatureData->release();
|
||||
if (dataInfo)
|
||||
if (dataInfo->asyncStruct)
|
||||
{
|
||||
_dataReaderHelper->_addDataMutex.unlock();
|
||||
}
|
||||
|
@ -1148,15 +1180,15 @@ void DataReaderHelper::addDataFromJsonCache(const char *fileContent, DataInfo *d
|
|||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
JsonDictionary *animationDic = json.getSubItemFromArray(ANIMATION_DATA, i);
|
||||
AnimationData *animationData = decodeAnimation(*animationDic);
|
||||
AnimationData *animationData = decodeAnimation(*animationDic, dataInfo);
|
||||
|
||||
if (dataInfo)
|
||||
if (dataInfo->asyncStruct)
|
||||
{
|
||||
_dataReaderHelper->_addDataMutex.lock();
|
||||
}
|
||||
ArmatureDataManager::getInstance()->addAnimationData(animationData->name.c_str(), animationData);
|
||||
animationData->release();
|
||||
if (dataInfo)
|
||||
if (dataInfo->asyncStruct)
|
||||
{
|
||||
_dataReaderHelper->_addDataMutex.unlock();
|
||||
}
|
||||
|
@ -1170,13 +1202,13 @@ void DataReaderHelper::addDataFromJsonCache(const char *fileContent, DataInfo *d
|
|||
JsonDictionary *textureDic = json.getSubItemFromArray(TEXTURE_DATA, i);
|
||||
TextureData *textureData = decodeTexture(*textureDic);
|
||||
|
||||
if (dataInfo)
|
||||
if (dataInfo->asyncStruct)
|
||||
{
|
||||
_dataReaderHelper->_addDataMutex.lock();
|
||||
}
|
||||
ArmatureDataManager::getInstance()->addTextureData(textureData->name.c_str(), textureData);
|
||||
textureData->release();
|
||||
if (dataInfo)
|
||||
if (dataInfo->asyncStruct)
|
||||
{
|
||||
_dataReaderHelper->_addDataMutex.unlock();
|
||||
}
|
||||
|
@ -1184,14 +1216,14 @@ void DataReaderHelper::addDataFromJsonCache(const char *fileContent, DataInfo *d
|
|||
}
|
||||
|
||||
// Auto load sprite file
|
||||
bool autoLoad = dataInfo == NULL ? ArmatureDataManager::getInstance()->isAutoLoadSpriteFile() : dataInfo->asyncStruct->autoLoadSpriteFile;
|
||||
bool autoLoad = dataInfo->asyncStruct == nullptr ? ArmatureDataManager::getInstance()->isAutoLoadSpriteFile() : dataInfo->asyncStruct->autoLoadSpriteFile;
|
||||
if (autoLoad)
|
||||
{
|
||||
length = json.getArrayItemCount(CONFIG_FILE_PATH);
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
const char *path = json.getStringValueFromArray(CONFIG_FILE_PATH, i);
|
||||
if (path == NULL)
|
||||
if (path == nullptr)
|
||||
{
|
||||
CCLOG("load CONFIG_FILE_PATH error.");
|
||||
return;
|
||||
|
@ -1200,7 +1232,7 @@ void DataReaderHelper::addDataFromJsonCache(const char *fileContent, DataInfo *d
|
|||
std::string filePath = path;
|
||||
filePath = filePath.erase(filePath.find_last_of("."));
|
||||
|
||||
if (dataInfo != NULL)
|
||||
if (dataInfo->asyncStruct)
|
||||
{
|
||||
dataInfo->configFileQueue.push(filePath);
|
||||
}
|
||||
|
@ -1209,30 +1241,30 @@ void DataReaderHelper::addDataFromJsonCache(const char *fileContent, DataInfo *d
|
|||
std::string plistPath = filePath + ".plist";
|
||||
std::string pngPath = filePath + ".png";
|
||||
|
||||
ArmatureDataManager::getInstance()->addSpriteFrameFromFile((s_BasefilePath + plistPath).c_str(), (s_BasefilePath + pngPath).c_str());
|
||||
ArmatureDataManager::getInstance()->addSpriteFrameFromFile((dataInfo->baseFilePath + plistPath).c_str(), (dataInfo->baseFilePath + pngPath).c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ArmatureData *DataReaderHelper::decodeArmature(JsonDictionary &json)
|
||||
ArmatureData *DataReaderHelper::decodeArmature(JsonDictionary &json, DataInfo *dataInfo)
|
||||
{
|
||||
ArmatureData *armatureData = new ArmatureData();
|
||||
armatureData->init();
|
||||
|
||||
const char *name = json.getItemStringValue(A_NAME);
|
||||
if(name != NULL)
|
||||
if(name != nullptr)
|
||||
{
|
||||
armatureData->name = name;
|
||||
}
|
||||
|
||||
s_CocoStudioVersion = armatureData->dataVersion = json.getItemFloatValue(VERSION, 0.1f);
|
||||
dataInfo->cocoStudioVersion = armatureData->dataVersion = json.getItemFloatValue(VERSION, 0.1f);
|
||||
|
||||
int length = json.getArrayItemCount(BONE_DATA);
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
JsonDictionary *dic = json.getSubItemFromArray(BONE_DATA, i);
|
||||
BoneData *boneData = decodeBone(*dic);
|
||||
BoneData *boneData = decodeBone(*dic, dataInfo);
|
||||
armatureData->addBoneData(boneData);
|
||||
boneData->release();
|
||||
|
||||
|
@ -1242,21 +1274,21 @@ ArmatureData *DataReaderHelper::decodeArmature(JsonDictionary &json)
|
|||
return armatureData;
|
||||
}
|
||||
|
||||
BoneData *DataReaderHelper::decodeBone(JsonDictionary &json)
|
||||
BoneData *DataReaderHelper::decodeBone(JsonDictionary &json, DataInfo *dataInfo)
|
||||
{
|
||||
BoneData *boneData = new BoneData();
|
||||
boneData->init();
|
||||
|
||||
decodeNode(boneData, json);
|
||||
decodeNode(boneData, json, dataInfo);
|
||||
|
||||
const char *str = json.getItemStringValue(A_NAME);
|
||||
if(str != NULL)
|
||||
if(str != nullptr)
|
||||
{
|
||||
boneData->name = str;
|
||||
}
|
||||
|
||||
str = json.getItemStringValue(A_PARENT);
|
||||
if(str != NULL)
|
||||
if(str != nullptr)
|
||||
{
|
||||
boneData->parentName = str;
|
||||
}
|
||||
|
@ -1266,7 +1298,7 @@ BoneData *DataReaderHelper::decodeBone(JsonDictionary &json)
|
|||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
JsonDictionary *dic = json.getSubItemFromArray(DISPLAY_DATA, i);
|
||||
DisplayData *displayData = decodeBoneDisplay(*dic);
|
||||
DisplayData *displayData = decodeBoneDisplay(*dic, dataInfo);
|
||||
boneData->addDisplayData(displayData);
|
||||
displayData->release();
|
||||
|
||||
|
@ -1276,11 +1308,11 @@ BoneData *DataReaderHelper::decodeBone(JsonDictionary &json)
|
|||
return boneData;
|
||||
}
|
||||
|
||||
DisplayData *DataReaderHelper::decodeBoneDisplay(JsonDictionary &json)
|
||||
DisplayData *DataReaderHelper::decodeBoneDisplay(JsonDictionary &json, DataInfo *dataInfo)
|
||||
{
|
||||
DisplayType displayType = (DisplayType)json.getItemIntValue(A_DISPLAY_TYPE, CS_DISPLAY_SPRITE);
|
||||
|
||||
DisplayData *displayData = NULL;
|
||||
DisplayData *displayData = nullptr;
|
||||
|
||||
switch (displayType)
|
||||
{
|
||||
|
@ -1289,13 +1321,13 @@ DisplayData *DataReaderHelper::decodeBoneDisplay(JsonDictionary &json)
|
|||
displayData = new SpriteDisplayData();
|
||||
|
||||
const char *name = json.getItemStringValue(A_NAME);
|
||||
if(name != NULL)
|
||||
if(name != nullptr)
|
||||
{
|
||||
((SpriteDisplayData *)displayData)->displayName = name;
|
||||
}
|
||||
|
||||
JsonDictionary *dic = json.getSubItemFromArray(SKIN_DATA, 0);
|
||||
if (dic != NULL)
|
||||
if (dic != nullptr)
|
||||
{
|
||||
SpriteDisplayData *sdd = (SpriteDisplayData *)displayData;
|
||||
sdd->skinData.x = dic->getItemFloatValue(A_X, 0) * s_PositionReadScale;
|
||||
|
@ -1304,6 +1336,10 @@ DisplayData *DataReaderHelper::decodeBoneDisplay(JsonDictionary &json)
|
|||
sdd->skinData.scaleY = dic->getItemFloatValue(A_SCALE_Y, 1);
|
||||
sdd->skinData.skewX = dic->getItemFloatValue(A_SKEW_X, 0);
|
||||
sdd->skinData.skewY = dic->getItemFloatValue(A_SKEW_Y, 0);
|
||||
|
||||
sdd->skinData.x *= dataInfo->contentScale;
|
||||
sdd->skinData.y *= dataInfo->contentScale;
|
||||
|
||||
delete dic;
|
||||
}
|
||||
}
|
||||
|
@ -1314,7 +1350,7 @@ DisplayData *DataReaderHelper::decodeBoneDisplay(JsonDictionary &json)
|
|||
displayData = new ArmatureDisplayData();
|
||||
|
||||
const char *name = json.getItemStringValue(A_NAME);
|
||||
if(name != NULL)
|
||||
if(name != nullptr)
|
||||
{
|
||||
((ArmatureDisplayData *)displayData)->displayName = name;
|
||||
}
|
||||
|
@ -1325,9 +1361,16 @@ DisplayData *DataReaderHelper::decodeBoneDisplay(JsonDictionary &json)
|
|||
displayData = new ParticleDisplayData();
|
||||
|
||||
const char *plist = json.getItemStringValue(A_PLIST);
|
||||
if(plist != NULL)
|
||||
if(plist != nullptr)
|
||||
{
|
||||
((ParticleDisplayData *)displayData)->plist = s_BasefilePath + plist;
|
||||
if (dataInfo->asyncStruct)
|
||||
{
|
||||
static_cast<ParticleDisplayData *>(displayData)->plist = dataInfo->asyncStruct->baseFilePath + plist;
|
||||
}
|
||||
else
|
||||
{
|
||||
static_cast<ParticleDisplayData *>(displayData)->plist = dataInfo->baseFilePath + plist;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -1343,12 +1386,12 @@ DisplayData *DataReaderHelper::decodeBoneDisplay(JsonDictionary &json)
|
|||
return displayData;
|
||||
}
|
||||
|
||||
AnimationData *DataReaderHelper::decodeAnimation(JsonDictionary &json)
|
||||
AnimationData *DataReaderHelper::decodeAnimation(JsonDictionary &json, DataInfo *dataInfo)
|
||||
{
|
||||
AnimationData *aniData = new AnimationData();
|
||||
|
||||
const char *name = json.getItemStringValue(A_NAME);
|
||||
if(name != NULL)
|
||||
if(name != nullptr)
|
||||
{
|
||||
aniData->name = name;
|
||||
}
|
||||
|
@ -1358,7 +1401,7 @@ AnimationData *DataReaderHelper::decodeAnimation(JsonDictionary &json)
|
|||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
JsonDictionary *dic = json.getSubItemFromArray(MOVEMENT_DATA, i);
|
||||
MovementData *movementData = decodeMovement(*dic);
|
||||
MovementData *movementData = decodeMovement(*dic, dataInfo);
|
||||
aniData->addMovement(movementData);
|
||||
movementData->release();
|
||||
|
||||
|
@ -1368,7 +1411,7 @@ AnimationData *DataReaderHelper::decodeAnimation(JsonDictionary &json)
|
|||
return aniData;
|
||||
}
|
||||
|
||||
MovementData *DataReaderHelper::decodeMovement(JsonDictionary &json)
|
||||
MovementData *DataReaderHelper::decodeMovement(JsonDictionary &json, DataInfo *dataInfo)
|
||||
{
|
||||
MovementData *movementData = new MovementData();
|
||||
|
||||
|
@ -1377,10 +1420,10 @@ MovementData *DataReaderHelper::decodeMovement(JsonDictionary &json)
|
|||
movementData->durationTo = json.getItemIntValue(A_DURATION_TO, 0);
|
||||
movementData->duration = json.getItemIntValue(A_DURATION, 0);
|
||||
movementData->scale = json.getItemFloatValue(A_MOVEMENT_SCALE, 1);
|
||||
movementData->tweenEasing = (CCTweenType)json.getItemIntValue(A_TWEEN_EASING, Linear);
|
||||
movementData->tweenEasing = (TweenType)json.getItemIntValue(A_TWEEN_EASING, Linear);
|
||||
|
||||
const char *name = json.getItemStringValue(A_NAME);
|
||||
if(name != NULL)
|
||||
if(name != nullptr)
|
||||
{
|
||||
movementData->name = name;
|
||||
}
|
||||
|
@ -1389,7 +1432,7 @@ MovementData *DataReaderHelper::decodeMovement(JsonDictionary &json)
|
|||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
JsonDictionary *dic = json.getSubItemFromArray(MOVEMENT_BONE_DATA, i);
|
||||
MovementBoneData *movementBoneData = decodeMovementBone(*dic);
|
||||
MovementBoneData *movementBoneData = decodeMovementBone(*dic, dataInfo);
|
||||
movementData->addMovementBoneData(movementBoneData);
|
||||
movementBoneData->release();
|
||||
|
||||
|
@ -1399,7 +1442,7 @@ MovementData *DataReaderHelper::decodeMovement(JsonDictionary &json)
|
|||
return movementData;
|
||||
}
|
||||
|
||||
MovementBoneData *DataReaderHelper::decodeMovementBone(JsonDictionary &json)
|
||||
MovementBoneData *DataReaderHelper::decodeMovementBone(JsonDictionary &json, DataInfo *dataInfo)
|
||||
{
|
||||
MovementBoneData *movementBoneData = new MovementBoneData();
|
||||
movementBoneData->init();
|
||||
|
@ -1407,7 +1450,7 @@ MovementBoneData *DataReaderHelper::decodeMovementBone(JsonDictionary &json)
|
|||
movementBoneData->delay = json.getItemFloatValue(A_MOVEMENT_DELAY, 0);
|
||||
|
||||
const char *name = json.getItemStringValue(A_NAME);
|
||||
if(name != NULL)
|
||||
if(name != nullptr)
|
||||
{
|
||||
movementBoneData->name = name;
|
||||
}
|
||||
|
@ -1416,12 +1459,12 @@ MovementBoneData *DataReaderHelper::decodeMovementBone(JsonDictionary &json)
|
|||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
JsonDictionary *dic = json.getSubItemFromArray(FRAME_DATA, i);
|
||||
FrameData *frameData = decodeFrame(*dic);
|
||||
FrameData *frameData = decodeFrame(*dic, dataInfo);
|
||||
|
||||
movementBoneData->addFrameData(frameData);
|
||||
frameData->release();
|
||||
|
||||
if (s_CocoStudioVersion < VERSION_COMBINED)
|
||||
if (dataInfo->cocoStudioVersion < VERSION_COMBINED)
|
||||
{
|
||||
frameData->frameID = movementBoneData->duration;
|
||||
movementBoneData->duration += frameData->duration;
|
||||
|
@ -1431,7 +1474,7 @@ MovementBoneData *DataReaderHelper::decodeMovementBone(JsonDictionary &json)
|
|||
}
|
||||
|
||||
|
||||
if (s_CocoStudioVersion < VERSION_CHANGE_ROTATION_RANGE)
|
||||
if (dataInfo->cocoStudioVersion < VERSION_CHANGE_ROTATION_RANGE)
|
||||
{
|
||||
//! Change rotation range from (-180 -- 180) to (-infinity -- infinity)
|
||||
FrameData **frames = (FrameData **)movementBoneData->frameList.data->arr;
|
||||
|
@ -1455,7 +1498,7 @@ MovementBoneData *DataReaderHelper::decodeMovementBone(JsonDictionary &json)
|
|||
}
|
||||
}
|
||||
|
||||
if (s_CocoStudioVersion < VERSION_COMBINED)
|
||||
if (dataInfo->cocoStudioVersion < VERSION_COMBINED)
|
||||
{
|
||||
if (movementBoneData->frameList.count() > 0)
|
||||
{
|
||||
|
@ -1471,24 +1514,24 @@ MovementBoneData *DataReaderHelper::decodeMovementBone(JsonDictionary &json)
|
|||
return movementBoneData;
|
||||
}
|
||||
|
||||
FrameData *DataReaderHelper::decodeFrame(JsonDictionary &json)
|
||||
FrameData *DataReaderHelper::decodeFrame(JsonDictionary &json, DataInfo *dataInfo)
|
||||
{
|
||||
FrameData *frameData = new FrameData();
|
||||
|
||||
decodeNode(frameData, json);
|
||||
decodeNode(frameData, json, dataInfo);
|
||||
|
||||
frameData->tweenEasing = (CCTweenType)json.getItemIntValue(A_TWEEN_EASING, Linear);
|
||||
frameData->tweenEasing = (TweenType)json.getItemIntValue(A_TWEEN_EASING, Linear);
|
||||
frameData->displayIndex = json.getItemIntValue(A_DISPLAY_INDEX, 0);
|
||||
frameData->blendType = (BlendType)json.getItemIntValue(A_BLEND_TYPE, 0);
|
||||
frameData->isTween = (bool)json.getItemBoolvalue(A_TWEEN_FRAME, true);
|
||||
|
||||
const char *event = json.getItemStringValue(A_EVENT);
|
||||
if (event != NULL)
|
||||
if (event != nullptr)
|
||||
{
|
||||
frameData->strEvent = event;
|
||||
}
|
||||
|
||||
if (s_CocoStudioVersion < VERSION_COMBINED)
|
||||
if (dataInfo->cocoStudioVersion < VERSION_COMBINED)
|
||||
{
|
||||
frameData->duration = json.getItemIntValue(A_DURATION, 1);
|
||||
}
|
||||
|
@ -1506,7 +1549,7 @@ TextureData *DataReaderHelper::decodeTexture(JsonDictionary &json)
|
|||
textureData->init();
|
||||
|
||||
const char *name = json.getItemStringValue(A_NAME);
|
||||
if(name != NULL)
|
||||
if(name != nullptr)
|
||||
{
|
||||
textureData->name = name;
|
||||
}
|
||||
|
@ -1554,10 +1597,14 @@ ContourData *DataReaderHelper::decodeContour(JsonDictionary &json)
|
|||
return contourData;
|
||||
}
|
||||
|
||||
void DataReaderHelper::decodeNode(BaseData *node, JsonDictionary &json)
|
||||
void DataReaderHelper::decodeNode(BaseData *node, JsonDictionary &json, DataInfo *dataInfo)
|
||||
{
|
||||
node->x = json.getItemFloatValue(A_X, 0) * s_PositionReadScale;
|
||||
node->y = json.getItemFloatValue(A_Y, 0) * s_PositionReadScale;
|
||||
|
||||
node->x *= dataInfo->contentScale;
|
||||
node->y *= dataInfo->contentScale;
|
||||
|
||||
node->zOrder = json.getItemIntValue(A_Z, 0);
|
||||
|
||||
node->skewX = json.getItemFloatValue(A_SKEW_X, 0);
|
||||
|
@ -1565,7 +1612,15 @@ void DataReaderHelper::decodeNode(BaseData *node, JsonDictionary &json)
|
|||
node->scaleX = json.getItemFloatValue(A_SCALE_X, 1);
|
||||
node->scaleY = json.getItemFloatValue(A_SCALE_Y, 1);
|
||||
|
||||
JsonDictionary *colorDic = json.getSubItemFromArray(COLOR_INFO, 0);
|
||||
JsonDictionary *colorDic = nullptr;
|
||||
if (dataInfo->cocoStudioVersion < VERSION_COLOR_READING)
|
||||
{
|
||||
colorDic = json.getSubItemFromArray(COLOR_INFO, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
colorDic = json.getSubDictionary(COLOR_INFO);
|
||||
}
|
||||
|
||||
if (colorDic)
|
||||
{
|
||||
|
|
|
@ -63,12 +63,20 @@ protected:
|
|||
cocos2d::Object *target;
|
||||
cocos2d::SEL_SCHEDULE selector;
|
||||
bool autoLoadSpriteFile;
|
||||
|
||||
std::string imagePath;
|
||||
std::string plistPath;
|
||||
} AsyncStruct;
|
||||
|
||||
typedef struct _DataInfo
|
||||
{
|
||||
AsyncStruct *asyncStruct;
|
||||
std::queue<std::string> configFileQueue;
|
||||
float contentScale;
|
||||
std::string filename;
|
||||
std::string baseFilePath;
|
||||
float flashToolVersion;
|
||||
float cocoStudioVersion;
|
||||
} DataInfo;
|
||||
|
||||
public:
|
||||
|
@ -86,7 +94,6 @@ public:
|
|||
static float getPositionReadScale();
|
||||
|
||||
static void purge();
|
||||
static void clear();
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
|
@ -99,10 +106,11 @@ public:
|
|||
~DataReaderHelper();
|
||||
|
||||
void addDataFromFile(const char *filePath);
|
||||
void addDataFromFileAsync(const char *filePath, cocos2d::Object *target, cocos2d::SEL_SCHEDULE selector);
|
||||
void addDataFromFileAsync(const char *imagePath, const char *plistPath, const char *filePath, cocos2d::Object *target, cocos2d::SEL_SCHEDULE selector);
|
||||
|
||||
void addDataAsyncCallBack(float dt);
|
||||
|
||||
void removeConfigFile(const char *configFile);
|
||||
public:
|
||||
|
||||
/**
|
||||
|
@ -111,54 +119,54 @@ public:
|
|||
*
|
||||
* @param xmlPath The cache of the xml
|
||||
*/
|
||||
static void addDataFromCache(const char *pFileContent, DataInfo *dataInfo = NULL);
|
||||
static void addDataFromCache(const char *pFileContent, DataInfo *dataInfo = nullptr);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Decode Armature Datas from xml export from Dragon Bone flash tool
|
||||
*/
|
||||
static ArmatureData *decodeArmature(tinyxml2::XMLElement *armatureXML);
|
||||
static BoneData *decodeBone(tinyxml2::XMLElement *boneXML, tinyxml2::XMLElement *parentXML);
|
||||
static DisplayData *decodeBoneDisplay(tinyxml2::XMLElement *displayXML);
|
||||
static ArmatureData *decodeArmature(tinyxml2::XMLElement *armatureXML, DataInfo *dataInfo);
|
||||
static BoneData *decodeBone(tinyxml2::XMLElement *boneXML, tinyxml2::XMLElement *parentXML, DataInfo *dataInfo);
|
||||
static DisplayData *decodeBoneDisplay(tinyxml2::XMLElement *displayXML, DataInfo *dataInfo);
|
||||
|
||||
|
||||
/**
|
||||
* Decode ArmatureAnimation Datas from xml export from Dragon Bone flash tool
|
||||
*/
|
||||
static AnimationData *decodeAnimation(tinyxml2::XMLElement *animationXML);
|
||||
static MovementData *decodeMovement(tinyxml2::XMLElement *movementXML, ArmatureData *armatureData);
|
||||
static MovementBoneData *decodeMovementBone(tinyxml2::XMLElement *movBoneXml, tinyxml2::XMLElement *parentXml, BoneData *boneData);
|
||||
static FrameData *decodeFrame(tinyxml2::XMLElement *frameXML, tinyxml2::XMLElement *parentFrameXml, BoneData *boneData);
|
||||
static AnimationData *decodeAnimation(tinyxml2::XMLElement *animationXML, DataInfo *dataInfo);
|
||||
static MovementData *decodeMovement(tinyxml2::XMLElement *movementXML, ArmatureData *armatureData, DataInfo *dataInfo);
|
||||
static MovementBoneData *decodeMovementBone(tinyxml2::XMLElement *movBoneXml, tinyxml2::XMLElement *parentXml, BoneData *boneData, DataInfo *dataInfo);
|
||||
static FrameData *decodeFrame(tinyxml2::XMLElement *frameXML, tinyxml2::XMLElement *parentFrameXml, BoneData *boneData, DataInfo *dataInfo);
|
||||
|
||||
|
||||
/**
|
||||
* Decode Texture Datas from xml export from Dragon Bone flash tool
|
||||
*/
|
||||
static TextureData *decodeTexture(tinyxml2::XMLElement *textureXML);
|
||||
static TextureData *decodeTexture(tinyxml2::XMLElement *textureXML, DataInfo *dataInfo);
|
||||
|
||||
/**
|
||||
* Decode Contour Datas from xml export from Dragon Bone flash tool
|
||||
*/
|
||||
static ContourData *decodeContour(tinyxml2::XMLElement *contourXML);
|
||||
static ContourData *decodeContour(tinyxml2::XMLElement *contourXML, DataInfo *dataInfo);
|
||||
|
||||
public:
|
||||
static void addDataFromJsonCache(const char *fileContent, DataInfo *dataInfo = NULL);
|
||||
static void addDataFromJsonCache(const char *fileContent, DataInfo *dataInfo = nullptr);
|
||||
|
||||
static ArmatureData *decodeArmature(JsonDictionary &json);
|
||||
static BoneData *decodeBone(JsonDictionary &json);
|
||||
static DisplayData *decodeBoneDisplay(JsonDictionary &json);
|
||||
static ArmatureData *decodeArmature(JsonDictionary &json, DataInfo *dataInfo);
|
||||
static BoneData *decodeBone(JsonDictionary &json, DataInfo *dataInfo);
|
||||
static DisplayData *decodeBoneDisplay(JsonDictionary &json, DataInfo *dataInfo);
|
||||
|
||||
static AnimationData *decodeAnimation(JsonDictionary &json);
|
||||
static MovementData *decodeMovement(JsonDictionary &json);
|
||||
static MovementBoneData *decodeMovementBone(JsonDictionary &json);
|
||||
static FrameData *decodeFrame(JsonDictionary &json);
|
||||
static AnimationData *decodeAnimation(JsonDictionary &json, DataInfo *dataInfo);
|
||||
static MovementData *decodeMovement(JsonDictionary &json, DataInfo *dataInfo);
|
||||
static MovementBoneData *decodeMovementBone(JsonDictionary &json, DataInfo *dataInfo);
|
||||
static FrameData *decodeFrame(JsonDictionary &json, DataInfo *dataInfo);
|
||||
|
||||
static TextureData *decodeTexture(JsonDictionary &json);
|
||||
|
||||
static ContourData *decodeContour(JsonDictionary &json);
|
||||
|
||||
static void decodeNode(BaseData *node, JsonDictionary &json);
|
||||
static void decodeNode(BaseData *node, JsonDictionary &json, DataInfo *dataInfo);
|
||||
|
||||
protected:
|
||||
void loadData();
|
||||
|
@ -177,6 +185,8 @@ protected:
|
|||
|
||||
std::mutex _addDataMutex;
|
||||
|
||||
std::mutex _getFileMutex;
|
||||
|
||||
|
||||
unsigned long _asyncRefCount;
|
||||
unsigned long _asyncRefTotalCount;
|
||||
|
@ -186,6 +196,7 @@ protected:
|
|||
std::queue<AsyncStruct *> *_asyncStructQueue;
|
||||
std::queue<DataInfo *> *_dataQueue;
|
||||
|
||||
static std::vector<std::string> _configFileList;
|
||||
|
||||
static DataReaderHelper *_dataReaderHelper;
|
||||
};
|
||||
|
|
|
@ -39,7 +39,7 @@ public: \
|
|||
return var;\
|
||||
}\
|
||||
CC_SAFE_DELETE(var);\
|
||||
return NULL;\
|
||||
return nullptr;\
|
||||
}
|
||||
|
||||
#define CC_CREATE_NO_PARAM(varType)\
|
||||
|
@ -52,7 +52,7 @@ public: \
|
|||
return var;\
|
||||
}\
|
||||
CC_SAFE_DELETE(var);\
|
||||
return NULL;\
|
||||
return nullptr;\
|
||||
}
|
||||
|
||||
namespace cocostudio {
|
||||
|
@ -341,7 +341,7 @@ public:
|
|||
public:
|
||||
int frameID;
|
||||
int duration; //! The frame will last duration frames
|
||||
CCTweenType tweenEasing; //! Every frame's tween easing effect
|
||||
TweenType tweenEasing; //! Every frame's tween easing effect
|
||||
bool isTween; //! Whether it's a tween key frame
|
||||
|
||||
/**
|
||||
|
@ -435,7 +435,7 @@ public:
|
|||
* Which tween easing effect the movement use
|
||||
* TWEEN_EASING_MAX : use the value from MovementData get from flash design panel
|
||||
*/
|
||||
CCTweenType tweenEasing;
|
||||
TweenType tweenEasing;
|
||||
|
||||
/**
|
||||
* @brief save movment bone data
|
||||
|
|
|
@ -37,16 +37,16 @@ DecorativeDisplay *DecorativeDisplay::create()
|
|||
return pDisplay;
|
||||
}
|
||||
CC_SAFE_DELETE(pDisplay);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
DecorativeDisplay::DecorativeDisplay()
|
||||
: _display(NULL)
|
||||
, _displayData(NULL)
|
||||
: _display(nullptr)
|
||||
, _displayData(nullptr)
|
||||
|
||||
{
|
||||
#if ENABLE_PHYSICS_BOX2D_DETECT || ENABLE_PHYSICS_CHIPMUNK_DETECT
|
||||
_colliderDetector = NULL;
|
||||
_colliderDetector = nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -53,13 +53,46 @@ public:
|
|||
|
||||
virtual bool init();
|
||||
|
||||
protected:
|
||||
virtual void setDisplay(cocos2d::Node *display)
|
||||
{
|
||||
if (_display != display)
|
||||
{
|
||||
CC_SAFE_RETAIN(display);
|
||||
CC_SAFE_RELEASE(_display);
|
||||
_display = display;
|
||||
}
|
||||
}
|
||||
virtual cocos2d::Node *getDisplay() const { return _display; }
|
||||
|
||||
CC_SYNTHESIZE_RETAIN(cocos2d::Node *, _display, Display);
|
||||
CC_SYNTHESIZE_RETAIN(DisplayData *, _displayData, DisplayData);
|
||||
virtual void setDisplayData(DisplayData *data)
|
||||
{
|
||||
if (_displayData != data)
|
||||
{
|
||||
CC_SAFE_RETAIN(data);
|
||||
CC_SAFE_RELEASE(_displayData);
|
||||
_displayData = data;
|
||||
}
|
||||
}
|
||||
virtual DisplayData *getDisplayData() const { return _displayData; }
|
||||
|
||||
#if ENABLE_PHYSICS_BOX2D_DETECT || ENABLE_PHYSICS_CHIPMUNK_DETECT
|
||||
CC_SYNTHESIZE_RETAIN(ColliderDetector *, _colliderDetector, ColliderDetector);
|
||||
virtual void setColliderDetector(ColliderDetector *detector)
|
||||
{
|
||||
if (_colliderDetector != detector)
|
||||
{
|
||||
CC_SAFE_RETAIN(detector);
|
||||
CC_SAFE_RELEASE(_colliderDetector);
|
||||
_colliderDetector = detector;
|
||||
}
|
||||
}
|
||||
virtual ColliderDetector *getColliderDetector() const { return _colliderDetector; }
|
||||
#endif
|
||||
protected:
|
||||
cocos2d::Node *_display;
|
||||
DisplayData *_displayData;
|
||||
|
||||
#if ENABLE_PHYSICS_BOX2D_DETECT || ENABLE_PHYSICS_CHIPMUNK_DETECT
|
||||
ColliderDetector *_colliderDetector;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
|
@ -70,13 +70,15 @@ void DisplayFactory::createDisplay(Bone *bone, DecorativeDisplay *decoDisplay)
|
|||
}
|
||||
}
|
||||
|
||||
void DisplayFactory::updateDisplay(Bone *bone, DecorativeDisplay *decoDisplay, float dt, bool dirty)
|
||||
void DisplayFactory::updateDisplay(Bone *bone, float dt, bool dirty)
|
||||
{
|
||||
CS_RETURN_IF(!decoDisplay);
|
||||
Node *display = bone->getDisplayRenderNode();
|
||||
CS_RETURN_IF(!display);
|
||||
|
||||
#if ENABLE_PHYSICS_BOX2D_DETECT || ENABLE_PHYSICS_CHIPMUNK_DETECT
|
||||
if (dirty)
|
||||
{
|
||||
DecorativeDisplay *decoDisplay = bone->getDisplayManager()->getCurrentDecorativeDisplay();
|
||||
ColliderDetector *detector = decoDisplay->getColliderDetector();
|
||||
if (detector)
|
||||
{
|
||||
|
@ -84,9 +86,8 @@ void DisplayFactory::updateDisplay(Bone *bone, DecorativeDisplay *decoDisplay, f
|
|||
{
|
||||
CC_BREAK_IF(!detector->getBody());
|
||||
|
||||
Node *node = decoDisplay->getDisplay();
|
||||
AffineTransform displayTransform = node->getNodeToParentTransform();
|
||||
Point anchorPoint = node->getAnchorPointInPoints();
|
||||
AffineTransform displayTransform = display->getNodeToParentTransform();
|
||||
Point anchorPoint = display->getAnchorPointInPoints();
|
||||
anchorPoint = PointApplyAffineTransform(anchorPoint, displayTransform);
|
||||
displayTransform.tx = anchorPoint.x;
|
||||
displayTransform.ty = anchorPoint.y;
|
||||
|
@ -98,18 +99,19 @@ void DisplayFactory::updateDisplay(Bone *bone, DecorativeDisplay *decoDisplay, f
|
|||
}
|
||||
#endif
|
||||
|
||||
Node *display = decoDisplay->getDisplay();
|
||||
|
||||
switch(decoDisplay->getDisplayData()->displayType)
|
||||
switch(bone->getDisplayRenderNodeType())
|
||||
{
|
||||
case CS_DISPLAY_SPRITE:
|
||||
updateSpriteDisplay(bone, display, dt, dirty);
|
||||
if (dirty)
|
||||
{
|
||||
static_cast<Skin*>(display)->updateArmatureTransform();
|
||||
}
|
||||
break;
|
||||
case CS_DISPLAY_PARTICLE:
|
||||
updateParticleDisplay(bone, display, dt, dirty);
|
||||
updateParticleDisplay(bone, display, dt);
|
||||
break;
|
||||
case CS_DISPLAY_ARMATURE:
|
||||
updateArmatureDisplay(bone, display, dt, dirty);
|
||||
updateArmatureDisplay(bone, display, dt);
|
||||
break;
|
||||
default:
|
||||
{
|
||||
|
@ -131,7 +133,7 @@ void DisplayFactory::addSpriteDisplay(Bone *bone, DecorativeDisplay *decoDisplay
|
|||
|
||||
void DisplayFactory::createSpriteDisplay(Bone *bone, DecorativeDisplay *decoDisplay)
|
||||
{
|
||||
Skin *skin = NULL;
|
||||
Skin *skin = nullptr;
|
||||
|
||||
SpriteDisplayData *displayData = (SpriteDisplayData *)decoDisplay->getDisplayData();
|
||||
|
||||
|
@ -153,6 +155,13 @@ void DisplayFactory::createSpriteDisplay(Bone *bone, DecorativeDisplay *decoDisp
|
|||
skin = Skin::createWithSpriteFrameName((textureName + ".png").c_str());
|
||||
}
|
||||
|
||||
decoDisplay->setDisplay(skin);
|
||||
|
||||
if (skin == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
skin->setBone(bone);
|
||||
|
||||
initSpriteDisplay(bone, decoDisplay, displayData->displayName.c_str(), skin);
|
||||
|
@ -170,8 +179,6 @@ void DisplayFactory::createSpriteDisplay(Bone *bone, DecorativeDisplay *decoDisp
|
|||
}
|
||||
}
|
||||
|
||||
decoDisplay->setDisplay(skin);
|
||||
|
||||
}
|
||||
|
||||
void DisplayFactory::initSpriteDisplay(Bone *bone, DecorativeDisplay *decoDisplay, const char *displayName, Skin *skin)
|
||||
|
@ -206,17 +213,11 @@ void DisplayFactory::initSpriteDisplay(Bone *bone, DecorativeDisplay *decoDispla
|
|||
#endif
|
||||
}
|
||||
|
||||
void DisplayFactory::updateSpriteDisplay(Bone *bone, Node *display, float dt, bool dirty)
|
||||
{
|
||||
CS_RETURN_IF(!dirty);
|
||||
Skin *skin = (Skin *)display;
|
||||
skin->updateArmatureTransform();
|
||||
}
|
||||
|
||||
|
||||
void DisplayFactory::addArmatureDisplay(Bone *bone, DecorativeDisplay *decoDisplay, DisplayData *displayData)
|
||||
{
|
||||
ArmatureDisplayData *adp = ArmatureDisplayData::create(); ;
|
||||
ArmatureDisplayData *adp = ArmatureDisplayData::create();
|
||||
adp->copy((ArmatureDisplayData *)displayData);
|
||||
decoDisplay->setDisplayData(adp);
|
||||
|
||||
|
@ -228,15 +229,9 @@ void DisplayFactory::createArmatureDisplay(Bone *bone, DecorativeDisplay *decoDi
|
|||
|
||||
Armature *armature = Armature::create(displayData->displayName.c_str(), bone);
|
||||
|
||||
/*
|
||||
* because this bone have called this name, so armature should change it's name, or it can't add to
|
||||
* Armature's bone children.
|
||||
*/
|
||||
armature->setName((bone->getName() + "_armatureChild").c_str());
|
||||
|
||||
decoDisplay->setDisplay(armature);
|
||||
}
|
||||
void DisplayFactory::updateArmatureDisplay(Bone *bone, Node *display, float dt, bool dirty)
|
||||
void DisplayFactory::updateArmatureDisplay(Bone *bone, Node *display, float dt)
|
||||
{
|
||||
Armature *armature = (Armature *)display;
|
||||
if(armature)
|
||||
|
@ -250,7 +245,7 @@ void DisplayFactory::updateArmatureDisplay(Bone *bone, Node *display, float dt,
|
|||
|
||||
void DisplayFactory::addParticleDisplay(Bone *bone, DecorativeDisplay *decoDisplay, DisplayData *displayData)
|
||||
{
|
||||
ParticleDisplayData *adp = ParticleDisplayData::create(); ;
|
||||
ParticleDisplayData *adp = ParticleDisplayData::create();
|
||||
adp->copy((ParticleDisplayData *)displayData);
|
||||
decoDisplay->setDisplayData(adp);
|
||||
|
||||
|
@ -260,9 +255,18 @@ void DisplayFactory::createParticleDisplay(Bone *bone, DecorativeDisplay *decoDi
|
|||
{
|
||||
ParticleDisplayData *displayData = (ParticleDisplayData *)decoDisplay->getDisplayData();
|
||||
ParticleSystem *system = ParticleSystemQuad::create(displayData->plist.c_str());
|
||||
|
||||
system->removeFromParent();
|
||||
|
||||
Armature *armature = bone->getArmature();
|
||||
if (armature)
|
||||
{
|
||||
system->setParent(armature);
|
||||
}
|
||||
|
||||
decoDisplay->setDisplay(system);
|
||||
}
|
||||
void DisplayFactory::updateParticleDisplay(Bone *bone, Node *display, float dt, bool dirty)
|
||||
void DisplayFactory::updateParticleDisplay(Bone *bone, Node *display, float dt)
|
||||
{
|
||||
ParticleSystem *system = (ParticleSystem *)display;
|
||||
BaseData node;
|
||||
|
|
|
@ -40,21 +40,20 @@ class DisplayFactory
|
|||
public:
|
||||
static void addDisplay(Bone *bone, DecorativeDisplay *decoDisplay, DisplayData *displayData);
|
||||
static void createDisplay(Bone *bone, DecorativeDisplay *decoDisplay);
|
||||
static void updateDisplay(Bone *bone, DecorativeDisplay *decoDisplay, float dt, bool dirty);
|
||||
static void updateDisplay(Bone *bone, float dt, bool dirty);
|
||||
|
||||
static void addSpriteDisplay(Bone *bone, DecorativeDisplay *decoDisplay, DisplayData *displayData);
|
||||
static void createSpriteDisplay(Bone *bone, DecorativeDisplay *decoDisplay);
|
||||
static void initSpriteDisplay(Bone *bone, DecorativeDisplay *decoDisplay, const char *displayName, Skin *skin);
|
||||
static void updateSpriteDisplay(Bone *bone, cocos2d::Node *display, float dt, bool dirty);
|
||||
|
||||
|
||||
static void addArmatureDisplay(Bone *bone, DecorativeDisplay *decoDisplay, DisplayData *displayData);
|
||||
static void createArmatureDisplay(Bone *bone, DecorativeDisplay *decoDisplay);
|
||||
static void updateArmatureDisplay(Bone *bone, cocos2d::Node *display, float dt, bool dirty);
|
||||
static void updateArmatureDisplay(Bone *bone, cocos2d::Node *display, float dt);
|
||||
|
||||
static void addParticleDisplay(Bone *bone, DecorativeDisplay *decoDisplay, DisplayData *displayData);
|
||||
static void createParticleDisplay(Bone *bone, DecorativeDisplay *decoDisplay);
|
||||
static void updateParticleDisplay(Bone *bone, cocos2d::Node *display, float dt, bool dirty);
|
||||
static void updateParticleDisplay(Bone *bone, cocos2d::Node *display, float dt);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -41,18 +41,19 @@ DisplayManager *DisplayManager::create(Bone *bone)
|
|||
return pDisplayManager;
|
||||
}
|
||||
CC_SAFE_DELETE(pDisplayManager);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
DisplayManager::DisplayManager()
|
||||
: _decoDisplayList(NULL)
|
||||
, _displayRenderNode(NULL)
|
||||
, _currentDecoDisplay(NULL)
|
||||
: _decoDisplayList(nullptr)
|
||||
, _displayRenderNode(nullptr)
|
||||
, _displayType(CS_DISPLAY_MAX)
|
||||
, _currentDecoDisplay(nullptr)
|
||||
, _displayIndex(-1)
|
||||
, _forceChangeDisplay(false)
|
||||
, _visible(true)
|
||||
, _bone(NULL)
|
||||
, _bone(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -90,7 +91,7 @@ bool DisplayManager::init(Bone *bone)
|
|||
|
||||
void DisplayManager::addDisplay(DisplayData *displayData, int index)
|
||||
{
|
||||
DecorativeDisplay *decoDisplay = NULL;
|
||||
DecorativeDisplay *decoDisplay = nullptr;
|
||||
|
||||
if( (index >= 0) && (index < _decoDisplayList->count()) )
|
||||
{
|
||||
|
@ -114,7 +115,7 @@ void DisplayManager::addDisplay(DisplayData *displayData, int index)
|
|||
|
||||
void DisplayManager::addDisplay(Node *display, int index)
|
||||
{
|
||||
DecorativeDisplay *decoDisplay = NULL;
|
||||
DecorativeDisplay *decoDisplay = nullptr;
|
||||
|
||||
if( (index >= 0) && (index < _decoDisplayList->count()) )
|
||||
{
|
||||
|
@ -126,7 +127,7 @@ void DisplayManager::addDisplay(Node *display, int index)
|
|||
_decoDisplayList->addObject(decoDisplay);
|
||||
}
|
||||
|
||||
DisplayData *displayData = NULL;
|
||||
DisplayData *displayData = nullptr;
|
||||
if (Skin *skin = dynamic_cast<Skin *>(display))
|
||||
{
|
||||
skin->setBone(_bone);
|
||||
|
@ -137,6 +138,7 @@ void DisplayManager::addDisplay(Node *display, int index)
|
|||
if (SpriteDisplayData *spriteDisplayData = (SpriteDisplayData *)decoDisplay->getDisplayData())
|
||||
{
|
||||
skin->setSkinData(spriteDisplayData->skinData);
|
||||
((SpriteDisplayData *)displayData)->skinData = spriteDisplayData->skinData;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -147,6 +149,14 @@ void DisplayManager::addDisplay(Node *display, int index)
|
|||
else if (dynamic_cast<ParticleSystemQuad *>(display))
|
||||
{
|
||||
displayData = ParticleDisplayData::create();
|
||||
|
||||
display->removeFromParent();
|
||||
|
||||
Armature *armature = _bone->getArmature();
|
||||
if (armature)
|
||||
{
|
||||
display->setParent(armature);
|
||||
}
|
||||
}
|
||||
else if(Armature *armature = dynamic_cast<Armature *>(display))
|
||||
{
|
||||
|
@ -171,15 +181,16 @@ void DisplayManager::addDisplay(Node *display, int index)
|
|||
|
||||
void DisplayManager::removeDisplay(int index)
|
||||
{
|
||||
_decoDisplayList->removeObjectAtIndex(index);
|
||||
|
||||
if(index == _displayIndex)
|
||||
{
|
||||
setCurrentDecorativeDisplay(NULL);
|
||||
setCurrentDecorativeDisplay(nullptr);
|
||||
_displayIndex = -1;
|
||||
}
|
||||
|
||||
_decoDisplayList->removeObjectAtIndex(index);
|
||||
}
|
||||
|
||||
Array *DisplayManager::getDecorativeDisplayList()
|
||||
Array *DisplayManager::getDecorativeDisplayList() const
|
||||
{
|
||||
return _decoDisplayList;
|
||||
}
|
||||
|
@ -203,7 +214,7 @@ void DisplayManager::changeDisplayByIndex(int index, bool force)
|
|||
if(_displayRenderNode)
|
||||
{
|
||||
_displayRenderNode->removeFromParentAndCleanup(true);
|
||||
setCurrentDecorativeDisplay(NULL);
|
||||
setCurrentDecorativeDisplay(nullptr);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -232,12 +243,12 @@ void DisplayManager::setCurrentDecorativeDisplay(DecorativeDisplay *decoDisplay)
|
|||
}
|
||||
#endif
|
||||
|
||||
Node *displayRenderNode = _currentDecoDisplay == NULL ? NULL : _currentDecoDisplay->getDisplay();
|
||||
Node *displayRenderNode = _currentDecoDisplay == nullptr ? nullptr : _currentDecoDisplay->getDisplay();
|
||||
if (_displayRenderNode)
|
||||
{
|
||||
if (dynamic_cast<Armature *>(_displayRenderNode) != NULL)
|
||||
if (dynamic_cast<Armature *>(_displayRenderNode) != nullptr)
|
||||
{
|
||||
_bone->setChildArmature(NULL);
|
||||
_bone->setChildArmature(nullptr);
|
||||
}
|
||||
_displayRenderNode->removeFromParentAndCleanup(true);
|
||||
_displayRenderNode->release();
|
||||
|
@ -264,25 +275,37 @@ void DisplayManager::setCurrentDecorativeDisplay(DecorativeDisplay *decoDisplay)
|
|||
|
||||
_displayRenderNode->retain();
|
||||
_displayRenderNode->setVisible(_visible);
|
||||
|
||||
_displayType = _currentDecoDisplay->getDisplayData()->displayType;
|
||||
}
|
||||
else
|
||||
{
|
||||
_displayType = CS_DISPLAY_MAX;
|
||||
}
|
||||
}
|
||||
|
||||
Node *DisplayManager::getDisplayRenderNode()
|
||||
Node *DisplayManager::getDisplayRenderNode() const
|
||||
{
|
||||
return _displayRenderNode;
|
||||
}
|
||||
|
||||
int DisplayManager::getCurrentDisplayIndex()
|
||||
|
||||
DisplayType DisplayManager::getDisplayRenderNodeType() const
|
||||
{
|
||||
return _displayType;
|
||||
}
|
||||
|
||||
int DisplayManager::getCurrentDisplayIndex() const
|
||||
{
|
||||
return _displayIndex;
|
||||
}
|
||||
|
||||
DecorativeDisplay *DisplayManager::getCurrentDecorativeDisplay()
|
||||
DecorativeDisplay *DisplayManager::getCurrentDecorativeDisplay() const
|
||||
{
|
||||
return _currentDecoDisplay;
|
||||
}
|
||||
|
||||
DecorativeDisplay *DisplayManager::getDecorativeDisplayByIndex( int index)
|
||||
DecorativeDisplay *DisplayManager::getDecorativeDisplayByIndex( int index) const
|
||||
{
|
||||
return (DecorativeDisplay *)_decoDisplayList->getObjectAtIndex(index);
|
||||
}
|
||||
|
@ -295,11 +318,9 @@ void DisplayManager::initDisplayList(BoneData *boneData)
|
|||
|
||||
CS_RETURN_IF(!boneData);
|
||||
|
||||
Object *object = NULL;
|
||||
Array *displayDataList = &boneData->displayDataList;
|
||||
CCARRAY_FOREACH(displayDataList, object)
|
||||
for(auto object : boneData->displayDataList)
|
||||
{
|
||||
DisplayData *displayData = (DisplayData *)object;
|
||||
DisplayData *displayData = static_cast<DisplayData *>(object);
|
||||
|
||||
DecorativeDisplay *decoDisplay = DecorativeDisplay::create();
|
||||
decoDisplay->setDisplayData(displayData);
|
||||
|
@ -362,32 +383,32 @@ void DisplayManager::setVisible(bool visible)
|
|||
_displayRenderNode->setVisible(visible);
|
||||
}
|
||||
|
||||
bool DisplayManager::isVisible()
|
||||
bool DisplayManager::isVisible() const
|
||||
{
|
||||
return _visible;
|
||||
}
|
||||
|
||||
|
||||
Size DisplayManager::getContentSize()
|
||||
Size DisplayManager::getContentSize() const
|
||||
{
|
||||
CS_RETURN_IF(!_displayRenderNode) Size(0, 0);
|
||||
return _displayRenderNode->getContentSize();
|
||||
}
|
||||
|
||||
Rect DisplayManager::getBoundingBox()
|
||||
Rect DisplayManager::getBoundingBox() const
|
||||
{
|
||||
CS_RETURN_IF(!_displayRenderNode) Rect(0, 0, 0, 0);
|
||||
return _displayRenderNode->getBoundingBox();
|
||||
}
|
||||
|
||||
|
||||
Point DisplayManager::getAnchorPoint()
|
||||
Point DisplayManager::getAnchorPoint() const
|
||||
{
|
||||
CS_RETURN_IF(!_displayRenderNode) Point(0, 0);
|
||||
return _displayRenderNode->getAnchorPoint();
|
||||
}
|
||||
|
||||
Point DisplayManager::getAnchorPointInPoints()
|
||||
Point DisplayManager::getAnchorPointInPoints() const
|
||||
{
|
||||
CS_RETURN_IF(!_displayRenderNode) Point(0, 0);
|
||||
return _displayRenderNode->getAnchorPointInPoints();
|
||||
|
|
|
@ -76,7 +76,7 @@ public:
|
|||
|
||||
void removeDisplay(int index);
|
||||
|
||||
cocos2d::Array *getDecorativeDisplayList();
|
||||
cocos2d::Array *getDecorativeDisplayList() const;
|
||||
|
||||
/**
|
||||
* Change display by index. You can just use this method to change display in the display list.
|
||||
|
@ -90,13 +90,14 @@ public:
|
|||
void changeDisplayByIndex(int index, bool force);
|
||||
|
||||
|
||||
cocos2d::Node *getDisplayRenderNode();
|
||||
cocos2d::Node *getDisplayRenderNode() const;
|
||||
DisplayType getDisplayRenderNodeType() const;
|
||||
|
||||
int getCurrentDisplayIndex();
|
||||
int getCurrentDisplayIndex() const;
|
||||
|
||||
virtual void setCurrentDecorativeDisplay(DecorativeDisplay *decoDisplay);
|
||||
virtual DecorativeDisplay *getCurrentDecorativeDisplay();
|
||||
virtual DecorativeDisplay *getDecorativeDisplayByIndex( int index);
|
||||
virtual DecorativeDisplay *getCurrentDecorativeDisplay() const;
|
||||
virtual DecorativeDisplay *getDecorativeDisplayByIndex( int index) const;
|
||||
|
||||
/**
|
||||
* Sets whether the display is visible
|
||||
|
@ -111,13 +112,13 @@ public:
|
|||
* @see setVisible(bool)
|
||||
* @return true if the node is visible, false if the node is hidden.
|
||||
*/
|
||||
virtual bool isVisible();
|
||||
virtual bool isVisible() const;
|
||||
|
||||
cocos2d::Size getContentSize();
|
||||
cocos2d::Rect getBoundingBox();
|
||||
cocos2d::Size getContentSize() const;
|
||||
cocos2d::Rect getBoundingBox() const;
|
||||
|
||||
cocos2d::Point getAnchorPoint();
|
||||
cocos2d::Point getAnchorPointInPoints();
|
||||
cocos2d::Point getAnchorPoint() const;
|
||||
cocos2d::Point getAnchorPointInPoints() const;
|
||||
|
||||
/**
|
||||
* Check if the position is inside the bone.
|
||||
|
@ -129,16 +130,20 @@ public:
|
|||
*/
|
||||
virtual bool containPoint(float x, float y);
|
||||
|
||||
virtual void setForceChangeDisplay(bool force) { _forceChangeDisplay = force; }
|
||||
virtual bool isForceChangeDisplay() const { return _forceChangeDisplay; }
|
||||
protected:
|
||||
cocos2d::Array *_decoDisplayList;
|
||||
//! Display render node.
|
||||
cocos2d::Node *_displayRenderNode;
|
||||
//! Display render node type
|
||||
DisplayType _displayType;
|
||||
//! Include current display information, like contour sprite, etc.
|
||||
DecorativeDisplay *_currentDecoDisplay;
|
||||
//! Current display index
|
||||
int _displayIndex;
|
||||
|
||||
CC_SYNTHESIZE(bool, _forceChangeDisplay, ForceChangeDisplay)
|
||||
bool _forceChangeDisplay;
|
||||
|
||||
//! Whether of not the bone is visible. Default is true
|
||||
bool _visible;
|
||||
|
|
|
@ -89,7 +89,7 @@ void ProcessBase::play(void *animation, int durationTo, int durationTween, int
|
|||
* When changing end, m_iTotalFrames will be setted to _durationTween
|
||||
*/
|
||||
_nextFrameIndex = durationTo;
|
||||
_tweenEasing = (CCTweenType)tweenEasing;
|
||||
_tweenEasing = (TweenType)tweenEasing;
|
||||
|
||||
}
|
||||
|
||||
|
@ -141,8 +141,18 @@ void ProcessBase::update(float dt)
|
|||
|
||||
void ProcessBase::gotoFrame(int frameIndex)
|
||||
{
|
||||
if (_loopType == ANIMATION_NO_LOOP)
|
||||
{
|
||||
_loopType = ANIMATION_MAX;
|
||||
}
|
||||
else if (_loopType == ANIMATION_TO_LOOP_FRONT)
|
||||
{
|
||||
_loopType = ANIMATION_LOOP_FRONT;
|
||||
}
|
||||
|
||||
_curFrameIndex = frameIndex;
|
||||
pause();
|
||||
|
||||
_nextFrameIndex = _durationTween;
|
||||
}
|
||||
|
||||
int ProcessBase::getCurrentFrameIndex()
|
||||
|
|
|
@ -58,7 +58,7 @@ public:
|
|||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
~ProcessBase(void);
|
||||
virtual ~ProcessBase(void);
|
||||
|
||||
/**
|
||||
* Play animation by animation name.
|
||||
|
@ -104,8 +104,6 @@ public:
|
|||
virtual void stop();
|
||||
|
||||
|
||||
virtual void gotoFrame(int frameIndex);
|
||||
|
||||
/**
|
||||
* You should never call this function, unless you know what you do
|
||||
* Update the Process, include current process, current frame and son on
|
||||
|
@ -116,8 +114,26 @@ public:
|
|||
|
||||
virtual int getCurrentFrameIndex();
|
||||
|
||||
virtual void setProcessScale(float processScale) { _processScale = processScale; }
|
||||
virtual float getProcessScale() const { return _processScale; }
|
||||
|
||||
virtual void setIsPause(bool pause) { _isPause = pause; }
|
||||
virtual bool isPause() const { return _isPause; }
|
||||
|
||||
virtual void setIsComplete(bool complete) { _isComplete = complete; }
|
||||
virtual bool isComplete() const { return _isComplete; }
|
||||
|
||||
virtual void setIsPlaying(bool playing) { _isPlaying = playing; }
|
||||
virtual bool isPlaying() const { return _isPlaying; }
|
||||
|
||||
virtual float getCurrentPercent() const { return _currentPercent; }
|
||||
virtual int getRawDuration() const { return _rawDuration; }
|
||||
|
||||
virtual void setAnimationInternal(float animationInternal) { _animationInternal = animationInternal; }
|
||||
virtual float getAnimationInternal() const { return _animationInternal; }
|
||||
protected:
|
||||
|
||||
virtual void gotoFrame(int frameIndex);
|
||||
|
||||
/**
|
||||
* Update(float dt) will call this handler, you can handle your logic here
|
||||
|
@ -126,31 +142,31 @@ protected:
|
|||
|
||||
protected:
|
||||
//! Scale the process speed
|
||||
CC_SYNTHESIZE(float, _processScale, ProcessScale);
|
||||
float _processScale;
|
||||
|
||||
//! Set and get whether the aniamtion is pause
|
||||
CC_SYNTHESIZE(bool, _isPause, IsPause);
|
||||
bool _isPause;
|
||||
|
||||
//! Set and get whether the aniamtion is complete
|
||||
CC_SYNTHESIZE(bool, _isComplete, IsComplete);
|
||||
bool _isComplete;
|
||||
|
||||
//! Set and get whether the aniamtion is playing
|
||||
CC_SYNTHESIZE(bool, _isPlaying, IsPlaying);
|
||||
bool _isPlaying;
|
||||
|
||||
//! Current percent this process arrived
|
||||
CC_SYNTHESIZE(float, _currentPercent, CurrentPercent);
|
||||
float _currentPercent;
|
||||
|
||||
//! The raw duration
|
||||
CC_SYNTHESIZE(int, _rawDuration, RawDuration);
|
||||
int _rawDuration;
|
||||
|
||||
//! The animation whether or not loop
|
||||
CC_SYNTHESIZE(AnimationType, _loopType, LoopType);
|
||||
AnimationType _loopType;
|
||||
|
||||
//! The tween easing effect
|
||||
CC_SYNTHESIZE(CCTweenType, _tweenEasing, TweenEasing);
|
||||
TweenType _tweenEasing;
|
||||
|
||||
//! The animation update speed
|
||||
CC_SYNTHESIZE(float, _animationInternal, AnimationInternal);
|
||||
float _animationInternal;
|
||||
|
||||
|
||||
protected:
|
||||
|
|
|
@ -207,7 +207,7 @@ UIWidget* CCSGUIReader::widgetFromJsonFile(const char *fileName)
|
|||
JsonDictionary *jsonDict = NULL;
|
||||
jsonpath = FileUtils::getInstance()->fullPathForFilename(fileName);
|
||||
|
||||
unsigned long size = 0;
|
||||
long size = 0;
|
||||
des = (char*)(FileUtils::getInstance()->getFileData(jsonpath.c_str(),"r" , &size));
|
||||
if(NULL == des || strcmp(des, "") == 0)
|
||||
{
|
||||
|
@ -225,7 +225,7 @@ UIWidget* CCSGUIReader::widgetFromJsonFile(const char *fileName)
|
|||
}
|
||||
|
||||
int texturesCount = DICTOOL->getArrayCount_json(jsonDict, "textures");
|
||||
int pos = jsonpath.find_last_of('/');
|
||||
long pos = jsonpath.find_last_of('/');
|
||||
m_strFilePath = jsonpath.substr(0,pos+1);
|
||||
for (int i=0; i<texturesCount; i++)
|
||||
{
|
||||
|
|
|
@ -47,7 +47,7 @@ namespace cocostudio {
|
|||
|
||||
cocos2d::Node* SceneReader::createNodeWithSceneFile(const char* pszFileName)
|
||||
{
|
||||
unsigned long size = 0;
|
||||
long size = 0;
|
||||
const char* pData = 0;
|
||||
cocos2d::Node *pNode = NULL;
|
||||
do {
|
||||
|
@ -213,7 +213,7 @@ namespace cocostudio {
|
|||
{
|
||||
file_path = reDir.substr(0, pos+1);
|
||||
}
|
||||
unsigned long size = 0;
|
||||
long size = 0;
|
||||
const char *des = (char*)(cocos2d::FileUtils::getInstance()->getFileData(pPath.c_str(),"r" , &size));
|
||||
JsonDictionary *jsonDict = new JsonDictionary();
|
||||
jsonDict->initWithDescription(des);
|
||||
|
@ -227,7 +227,7 @@ namespace cocostudio {
|
|||
const char *name = DICTOOL->getStringValue_json(subData, "name");
|
||||
|
||||
childrenCount = DICTOOL->getArrayCount_json(jsonDict, "config_file_path");
|
||||
for (int i = 0; i < childrenCount; ++i)
|
||||
for (long i = 0; i < childrenCount; ++i)
|
||||
{
|
||||
const char* plist = DICTOOL->getStringValueFromArray_json(jsonDict, "config_file_path", i);
|
||||
std::string plistpath;
|
||||
|
@ -283,7 +283,7 @@ namespace cocostudio {
|
|||
if (nResType == 0)
|
||||
{
|
||||
pAttribute = ComAttribute::create();
|
||||
unsigned long size = 0;
|
||||
long size = 0;
|
||||
const char* pData = 0;
|
||||
pData = (char*)(cocos2d::FileUtils::getInstance()->getFileData(pPath.c_str(), "r", &size));
|
||||
if(pData != NULL && strcmp(pData, "") != 0)
|
||||
|
|
|
@ -37,6 +37,8 @@ namespace cocostudio {
|
|||
#define RENDER_IN_SUBPIXEL(__ARGS__) (ceil(__ARGS__))
|
||||
#endif
|
||||
|
||||
#define SET_VERTEX3F(_v_, _x_, _y_, _z_) (_v_).x = (_x_); (_v_).y = (_y_); (_v_).z = (_z_);
|
||||
|
||||
Skin *Skin::create()
|
||||
{
|
||||
Skin *skin = new Skin();
|
||||
|
@ -46,7 +48,7 @@ Skin *Skin::create()
|
|||
return skin;
|
||||
}
|
||||
CC_SAFE_DELETE(skin);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Skin *Skin::createWithSpriteFrameName(const char *pszSpriteFrameName)
|
||||
|
@ -58,7 +60,7 @@ Skin *Skin::createWithSpriteFrameName(const char *pszSpriteFrameName)
|
|||
return skin;
|
||||
}
|
||||
CC_SAFE_DELETE(skin);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Skin *Skin::create(const char *pszFileName)
|
||||
|
@ -70,42 +72,44 @@ Skin *Skin::create(const char *pszFileName)
|
|||
return skin;
|
||||
}
|
||||
CC_SAFE_DELETE(skin);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Skin::Skin()
|
||||
: _bone(NULL)
|
||||
: _bone(nullptr)
|
||||
, _armature(nullptr)
|
||||
, _displayName("")
|
||||
{
|
||||
_skinTransform = AffineTransformIdentity;
|
||||
}
|
||||
|
||||
bool Skin::initWithSpriteFrameName(const char *pszSpriteFrameName)
|
||||
bool Skin::initWithSpriteFrameName(const std::string& spriteFrameName)
|
||||
{
|
||||
bool ret = Sprite::initWithSpriteFrameName(pszSpriteFrameName);
|
||||
CCAssert(spriteFrameName != "", "");
|
||||
|
||||
if (ret)
|
||||
SpriteFrame *pFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(spriteFrameName);
|
||||
bool ret = true;
|
||||
|
||||
if (pFrame != nullptr)
|
||||
{
|
||||
TextureAtlas *atlas = SpriteFrameCacheHelper::getInstance()->getTexureAtlasWithTexture(_texture);
|
||||
setTextureAtlas(atlas);
|
||||
|
||||
_displayName = pszSpriteFrameName;
|
||||
ret = initWithSpriteFrame(pFrame);
|
||||
}
|
||||
else
|
||||
{
|
||||
CCLOG("Cann't find CCSpriteFrame with %s. Please check your .plist file", spriteFrameName.c_str());
|
||||
ret = false;
|
||||
}
|
||||
|
||||
_displayName = spriteFrameName;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool Skin::initWithFile(const char *pszFilename)
|
||||
bool Skin::initWithFile(const std::string& filename)
|
||||
{
|
||||
bool ret = Sprite::initWithFile(pszFilename);
|
||||
bool ret = Sprite::initWithFile(filename);
|
||||
|
||||
if (ret)
|
||||
{
|
||||
TextureAtlas *atlas = SpriteFrameCacheHelper::getInstance()->getTexureAtlasWithTexture(_texture);
|
||||
setTextureAtlas(atlas);
|
||||
|
||||
_displayName = pszFilename;
|
||||
}
|
||||
_displayName = filename;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -116,10 +120,12 @@ void Skin::setSkinData(const BaseData &var)
|
|||
|
||||
setScaleX(_skinData.scaleX);
|
||||
setScaleY(_skinData.scaleY);
|
||||
setRotation(CC_RADIANS_TO_DEGREES(_skinData.skewX));
|
||||
setRotationX(CC_RADIANS_TO_DEGREES(_skinData.skewX));
|
||||
setRotationY(CC_RADIANS_TO_DEGREES(-_skinData.skewY));
|
||||
setPosition(Point(_skinData.x, _skinData.y));
|
||||
|
||||
_skinTransform = getNodeToParentTransform();
|
||||
updateArmatureTransform();
|
||||
}
|
||||
|
||||
const BaseData &Skin::getSkinData() const
|
||||
|
@ -130,6 +136,10 @@ const BaseData &Skin::getSkinData() const
|
|||
void Skin::updateArmatureTransform()
|
||||
{
|
||||
_transform = AffineTransformConcat(_skinTransform, _bone->getNodeToArmatureTransform());
|
||||
if(_armature && _armature->getBatchNode())
|
||||
{
|
||||
_transform = AffineTransformConcat(_transform, _armature->getNodeToParentTransform());
|
||||
}
|
||||
}
|
||||
|
||||
void Skin::updateTransform()
|
||||
|
@ -172,13 +182,13 @@ void Skin::updateTransform()
|
|||
float dx = x1 * cr - y2 * sr2 + x;
|
||||
float dy = x1 * sr + y2 * cr2 + y;
|
||||
|
||||
_quad.bl.vertices = Vertex3F( RENDER_IN_SUBPIXEL(ax), RENDER_IN_SUBPIXEL(ay), _vertexZ );
|
||||
_quad.br.vertices = Vertex3F( RENDER_IN_SUBPIXEL(bx), RENDER_IN_SUBPIXEL(by), _vertexZ );
|
||||
_quad.tl.vertices = Vertex3F( RENDER_IN_SUBPIXEL(dx), RENDER_IN_SUBPIXEL(dy), _vertexZ );
|
||||
_quad.tr.vertices = Vertex3F( RENDER_IN_SUBPIXEL(cx), RENDER_IN_SUBPIXEL(cy), _vertexZ );
|
||||
SET_VERTEX3F( _quad.bl.vertices, RENDER_IN_SUBPIXEL(ax), RENDER_IN_SUBPIXEL(ay), _vertexZ );
|
||||
SET_VERTEX3F( _quad.br.vertices, RENDER_IN_SUBPIXEL(bx), RENDER_IN_SUBPIXEL(by), _vertexZ );
|
||||
SET_VERTEX3F( _quad.tl.vertices, RENDER_IN_SUBPIXEL(dx), RENDER_IN_SUBPIXEL(dy), _vertexZ );
|
||||
SET_VERTEX3F( _quad.tr.vertices, RENDER_IN_SUBPIXEL(cx), RENDER_IN_SUBPIXEL(cy), _vertexZ );
|
||||
}
|
||||
|
||||
// MARMALADE CHANGE: ADDED CHECK FOR NULL, TO PERMIT SPRITES WITH NO BATCH NODE / TEXTURE ATLAS
|
||||
// MARMALADE CHANGE: ADDED CHECK FOR nullptr, TO PERMIT SPRITES WITH NO BATCH NODE / TEXTURE ATLAS
|
||||
if (_textureAtlas)
|
||||
{
|
||||
_textureAtlas->updateQuad(&_quad, _textureAtlas->getTotalQuads());
|
||||
|
@ -203,4 +213,20 @@ AffineTransform Skin::getNodeToWorldTransformAR() const
|
|||
return AffineTransformConcat(displayTransform, _bone->getArmature()->getNodeToWorldTransform());
|
||||
}
|
||||
|
||||
void Skin::setBone(Bone *bone)
|
||||
{
|
||||
_bone = bone;
|
||||
if(Armature *armature = _bone->getArmature())
|
||||
{
|
||||
_armature = armature;
|
||||
TextureAtlas *atlas = armature->getTexureAtlasWithTexture(_texture);
|
||||
setTextureAtlas(atlas);
|
||||
}
|
||||
}
|
||||
|
||||
Bone *Skin::getBone() const
|
||||
{
|
||||
return _bone;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -39,21 +39,28 @@ public:
|
|||
public:
|
||||
Skin();
|
||||
|
||||
bool initWithSpriteFrameName(const char *pszSpriteFrameName);
|
||||
bool initWithFile(const char *pszFilename);
|
||||
virtual bool initWithSpriteFrameName(const std::string& spriteFrameName) override;
|
||||
virtual bool initWithFile(const std::string& filename) override;
|
||||
|
||||
void updateArmatureTransform();
|
||||
void updateTransform();
|
||||
void updateTransform() override;
|
||||
|
||||
cocos2d::AffineTransform getNodeToWorldTransform() const;
|
||||
cocos2d::AffineTransform getNodeToWorldTransform() const override;
|
||||
cocos2d::AffineTransform getNodeToWorldTransformAR() const;
|
||||
|
||||
CC_PROPERTY_PASS_BY_REF(BaseData, _skinData, SkinData);
|
||||
CC_SYNTHESIZE(Bone *, _bone, Bone);
|
||||
virtual void setSkinData(const BaseData &data);
|
||||
virtual const BaseData &getSkinData() const;
|
||||
|
||||
virtual void setBone(Bone *bone);
|
||||
virtual Bone *getBone() const;
|
||||
|
||||
virtual const std::string &getDisplayName() const { return _displayName; }
|
||||
protected:
|
||||
BaseData _skinData;
|
||||
Bone *_bone;
|
||||
Armature *_armature;
|
||||
cocos2d::AffineTransform _skinTransform;
|
||||
CC_SYNTHESIZE_READONLY(std::string, _displayName, DisplayName)
|
||||
std::string _displayName;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ using namespace cocos2d;
|
|||
|
||||
namespace cocostudio {
|
||||
|
||||
SpriteFrameCacheHelper *SpriteFrameCacheHelper::_spriteFrameCacheHelper = NULL;
|
||||
SpriteFrameCacheHelper *SpriteFrameCacheHelper::_spriteFrameCacheHelper = nullptr;
|
||||
|
||||
SpriteFrameCacheHelper *SpriteFrameCacheHelper::getInstance()
|
||||
{
|
||||
|
@ -44,7 +44,7 @@ SpriteFrameCacheHelper *SpriteFrameCacheHelper::getInstance()
|
|||
void SpriteFrameCacheHelper::purge()
|
||||
{
|
||||
delete _spriteFrameCacheHelper;
|
||||
_spriteFrameCacheHelper = NULL;
|
||||
_spriteFrameCacheHelper = nullptr;
|
||||
}
|
||||
|
||||
void SpriteFrameCacheHelper::addSpriteFrameFromFile(const char *plistPath, const char *imagePath)
|
||||
|
@ -52,26 +52,12 @@ void SpriteFrameCacheHelper::addSpriteFrameFromFile(const char *plistPath, const
|
|||
CCSpriteFrameCache::getInstance()->addSpriteFramesWithFile(plistPath, imagePath);
|
||||
}
|
||||
|
||||
TextureAtlas *SpriteFrameCacheHelper::getTexureAtlasWithTexture(Texture2D *texture)
|
||||
{
|
||||
int key = texture->getName();
|
||||
TextureAtlas *atlas = (TextureAtlas *)_textureAtlasDic->objectForKey(key);
|
||||
if (atlas == NULL)
|
||||
{
|
||||
atlas = TextureAtlas::createWithTexture(texture, 4);
|
||||
_textureAtlasDic->setObject(atlas, key);
|
||||
}
|
||||
return atlas;
|
||||
}
|
||||
|
||||
SpriteFrameCacheHelper::SpriteFrameCacheHelper()
|
||||
{
|
||||
_textureAtlasDic = new Dictionary();
|
||||
}
|
||||
|
||||
SpriteFrameCacheHelper::~SpriteFrameCacheHelper()
|
||||
{
|
||||
CC_SAFE_RELEASE_NULL(_textureAtlasDic);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -47,8 +47,6 @@ public:
|
|||
*/
|
||||
void addSpriteFrameFromFile(const char *plistPath, const char *imagePath);
|
||||
|
||||
cocos2d::TextureAtlas *getTexureAtlasWithTexture(cocos2d::Texture2D *texture);
|
||||
|
||||
private:
|
||||
/**
|
||||
* @js ctor
|
||||
|
@ -60,8 +58,6 @@ private:
|
|||
*/
|
||||
~SpriteFrameCacheHelper();
|
||||
|
||||
cocos2d::Dictionary *_textureAtlasDic;
|
||||
|
||||
static SpriteFrameCacheHelper *_spriteFrameCacheHelper;
|
||||
};
|
||||
|
||||
|
|
|
@ -96,10 +96,23 @@ void TransformHelp::transformToParentWithoutScale(BaseData &node, const BaseData
|
|||
|
||||
void TransformHelp::nodeToMatrix(const BaseData &node, AffineTransform &matrix)
|
||||
{
|
||||
matrix.a = node.scaleX * cos(node.skewY);
|
||||
matrix.b = node.scaleX * sin(node.skewY);
|
||||
matrix.c = node.scaleY * sin(node.skewX);
|
||||
matrix.d = node.scaleY * cos(node.skewX);
|
||||
if (node.skewX == -node.skewY)
|
||||
{
|
||||
double sine = sin(node.skewX);
|
||||
double cosine = cos(node.skewX);
|
||||
|
||||
matrix.a = node.scaleX * cosine;
|
||||
matrix.b = node.scaleX * -sine;
|
||||
matrix.c = node.scaleY * sine;
|
||||
matrix.d = node.scaleY * cosine;
|
||||
}
|
||||
else
|
||||
{
|
||||
matrix.a = node.scaleX * cos(node.skewY);
|
||||
matrix.b = node.scaleX * sin(node.skewY);
|
||||
matrix.c = node.scaleY * sin(node.skewX);
|
||||
matrix.d = node.scaleY * cos(node.skewX);
|
||||
}
|
||||
|
||||
matrix.tx = node.x;
|
||||
matrix.ty = node.y;
|
||||
|
|
|
@ -43,24 +43,25 @@ Tween *Tween::create(Bone *bone)
|
|||
return pTween;
|
||||
}
|
||||
CC_SAFE_DELETE(pTween);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Tween::Tween()
|
||||
: _movementBoneData(NULL)
|
||||
, _tweenData(NULL)
|
||||
, _from(NULL)
|
||||
, _to(NULL)
|
||||
, _between(NULL)
|
||||
, _bone(NULL)
|
||||
: _movementBoneData(nullptr)
|
||||
, _tweenData(nullptr)
|
||||
, _from(nullptr)
|
||||
, _to(nullptr)
|
||||
, _between(nullptr)
|
||||
, _bone(nullptr)
|
||||
|
||||
, _frameTweenEasing(Linear)
|
||||
, _fromIndex(0)
|
||||
, _toIndex(0)
|
||||
, _animation(NULL)
|
||||
, _animation(nullptr)
|
||||
, _passLastFrame(false)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -85,7 +86,7 @@ bool Tween::init(Bone *bone)
|
|||
_tweenData = _bone->getTweenData();
|
||||
_tweenData->displayIndex = -1;
|
||||
|
||||
_animation = _bone->getArmature() != NULL ? _bone->getArmature()->getAnimation() : NULL;
|
||||
_animation = _bone->getArmature() != nullptr ? _bone->getArmature()->getAnimation() : nullptr;
|
||||
|
||||
bRet = true;
|
||||
}
|
||||
|
@ -97,9 +98,16 @@ bool Tween::init(Bone *bone)
|
|||
|
||||
void Tween::play(MovementBoneData *movementBoneData, int durationTo, int durationTween, int loop, int tweenEasing)
|
||||
{
|
||||
ProcessBase::play(NULL, durationTo, durationTween, loop, tweenEasing);
|
||||
ProcessBase::play(nullptr, durationTo, durationTween, loop, tweenEasing);
|
||||
|
||||
_loopType = (AnimationType)loop;
|
||||
if (loop)
|
||||
{
|
||||
_loopType = ANIMATION_TO_LOOP_FRONT;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loopType = ANIMATION_NO_LOOP;
|
||||
}
|
||||
|
||||
_totalDuration = 0;
|
||||
_betweenDuration = 0;
|
||||
|
@ -135,15 +143,6 @@ void Tween::play(MovementBoneData *movementBoneData, int durationTo, int duratio
|
|||
}
|
||||
else if (_movementBoneData->frameList.count() > 1)
|
||||
{
|
||||
if (loop)
|
||||
{
|
||||
_loopType = ANIMATION_TO_LOOP_BACK;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loopType = ANIMATION_NO_LOOP;
|
||||
}
|
||||
|
||||
_durationTween = durationTween * _movementBoneData->scale;
|
||||
|
||||
if (loop && _movementBoneData->delay != 0)
|
||||
|
@ -166,6 +165,27 @@ void Tween::play(MovementBoneData *movementBoneData, int durationTo, int duratio
|
|||
tweenNodeTo(0);
|
||||
}
|
||||
|
||||
void Tween::gotoAndPlay(int frameIndex)
|
||||
{
|
||||
ProcessBase::gotoFrame(frameIndex);
|
||||
|
||||
_totalDuration = 0;
|
||||
_betweenDuration = 0;
|
||||
_fromIndex = _toIndex = 0;
|
||||
|
||||
_isPlaying = true;
|
||||
_isComplete = _isPause = false;
|
||||
|
||||
_currentPercent = (float)_curFrameIndex / (float)_rawDuration;
|
||||
_currentFrame = _nextFrameIndex * _currentPercent;
|
||||
}
|
||||
|
||||
void Tween::gotoAndPause(int frameIndex)
|
||||
{
|
||||
gotoAndPlay(frameIndex);
|
||||
pause();
|
||||
}
|
||||
|
||||
void Tween::updateHandler()
|
||||
{
|
||||
if (_currentPercent >= 1)
|
||||
|
@ -211,9 +231,9 @@ void Tween::updateHandler()
|
|||
}
|
||||
}
|
||||
break;
|
||||
case ANIMATION_TO_LOOP_BACK:
|
||||
case ANIMATION_TO_LOOP_FRONT:
|
||||
{
|
||||
_loopType = ANIMATION_LOOP_BACK;
|
||||
_loopType = ANIMATION_LOOP_FRONT;
|
||||
|
||||
_nextFrameIndex = _durationTween > 0 ? _durationTween : 1;
|
||||
|
||||
|
@ -244,10 +264,6 @@ void Tween::updateHandler()
|
|||
default:
|
||||
{
|
||||
_currentFrame = fmodf(_currentFrame, _nextFrameIndex);
|
||||
|
||||
_totalDuration = 0;
|
||||
_betweenDuration = 0;
|
||||
_fromIndex = _toIndex = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -312,7 +328,7 @@ void Tween::arriveKeyFrame(FrameData *keyFrameData)
|
|||
//! Change bone's display
|
||||
int displayIndex = keyFrameData->displayIndex;
|
||||
|
||||
if (!displayManager->getForceChangeDisplay())
|
||||
if (!displayManager->isForceChangeDisplay())
|
||||
{
|
||||
displayManager->changeDisplayByIndex(displayIndex, false);
|
||||
}
|
||||
|
@ -338,11 +354,11 @@ void Tween::arriveKeyFrame(FrameData *keyFrameData)
|
|||
|
||||
FrameData *Tween::tweenNodeTo(float percent, FrameData *node)
|
||||
{
|
||||
node = node == NULL ? _tweenData : node;
|
||||
node = node == nullptr ? _tweenData : node;
|
||||
|
||||
if (!_from->isTween)
|
||||
{
|
||||
return _from;
|
||||
percent = 0;
|
||||
}
|
||||
|
||||
node->x = _from->x + percent * _between->x;
|
||||
|
@ -391,43 +407,54 @@ float Tween::updateFrameData(float currentPercent)
|
|||
int length = _movementBoneData->frameList.count();
|
||||
FrameData **frames = (FrameData **)_movementBoneData->frameList.data->arr;
|
||||
|
||||
FrameData *from = NULL;
|
||||
FrameData *to = NULL;
|
||||
FrameData *from = nullptr;
|
||||
FrameData *to = nullptr;
|
||||
|
||||
if (playedTime < frames[0]->frameID)
|
||||
{
|
||||
from = to = frames[0];
|
||||
setBetween(from, to);
|
||||
return currentPercent;
|
||||
return _currentPercent;
|
||||
}
|
||||
else if(playedTime >= frames[length - 1]->frameID)
|
||||
|
||||
if(playedTime >= frames[length - 1]->frameID)
|
||||
{
|
||||
from = to = frames[length - 1];
|
||||
setBetween(from, to);
|
||||
return currentPercent;
|
||||
// If _passLastFrame is true and playedTime >= frames[length - 1]->frameID, then do not need to go on.
|
||||
if (_passLastFrame)
|
||||
{
|
||||
from = to = frames[length - 1];
|
||||
setBetween(from, to);
|
||||
return _currentPercent;
|
||||
}
|
||||
_passLastFrame = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_passLastFrame = false;
|
||||
}
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
_fromIndex = _toIndex;
|
||||
from = frames[_fromIndex];
|
||||
_totalDuration = from->frameID;
|
||||
|
||||
if (++_toIndex >= length)
|
||||
_toIndex = _fromIndex + 1;
|
||||
if (_toIndex >= length)
|
||||
{
|
||||
_toIndex = 0;
|
||||
}
|
||||
|
||||
_fromIndex = _toIndex;
|
||||
to = frames[_toIndex];
|
||||
|
||||
//! Guaranteed to trigger frame event
|
||||
if(from->strEvent.length() != 0)
|
||||
if(from->strEvent.length() != 0 && !_animation->isIgnoreFrameEvent())
|
||||
{
|
||||
_animation->frameEvent(_bone, from->strEvent.c_str(), from->frameID, playedTime);
|
||||
}
|
||||
|
||||
if (playedTime == from->frameID)
|
||||
if (playedTime == from->frameID || (_passLastFrame && _fromIndex == length-1))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
@ -447,16 +474,10 @@ float Tween::updateFrameData(float currentPercent)
|
|||
/*
|
||||
* If frame tween easing equal to TWEEN_EASING_MAX, then it will not do tween.
|
||||
*/
|
||||
|
||||
CCTweenType tweenType;
|
||||
|
||||
if ( _frameTweenEasing != TWEEN_EASING_MAX)
|
||||
TweenType tweenType = (_frameTweenEasing != Linear) ? _frameTweenEasing : _tweenEasing;
|
||||
if (tweenType != TWEEN_EASING_MAX && tweenType != Linear)
|
||||
{
|
||||
tweenType = (_tweenEasing == TWEEN_EASING_MAX) ? _frameTweenEasing : _tweenEasing;
|
||||
if (tweenType != TWEEN_EASING_MAX && tweenType != Linear)
|
||||
{
|
||||
currentPercent = TweenFunction::tweenTo(0, 1, currentPercent, 1, tweenType);
|
||||
}
|
||||
currentPercent = TweenFunction::tweenTo(0, 1, currentPercent, 1, tweenType);
|
||||
}
|
||||
|
||||
return currentPercent;
|
||||
|
|
|
@ -83,14 +83,14 @@ public:
|
|||
*/
|
||||
virtual void play(MovementBoneData *movementBoneData, int durationTo, int durationTween, int loop, int tweenEasing);
|
||||
|
||||
inline void setAnimation(ArmatureAnimation *animation)
|
||||
{
|
||||
_animation = animation;
|
||||
}
|
||||
inline ArmatureAnimation *getAnimation() const
|
||||
{
|
||||
return _animation;
|
||||
}
|
||||
inline void setAnimation(ArmatureAnimation *animation) { _animation = animation; }
|
||||
inline ArmatureAnimation *getAnimation() const { return _animation; }
|
||||
|
||||
virtual void gotoAndPlay(int frameIndex);
|
||||
virtual void gotoAndPause(int frameIndex);
|
||||
|
||||
virtual void setMovementBoneData(MovementBoneData *data) { _movementBoneData = data; }
|
||||
virtual const MovementBoneData *getMovementBoneData() const { return _movementBoneData; }
|
||||
protected:
|
||||
|
||||
/**
|
||||
|
@ -111,7 +111,7 @@ protected:
|
|||
/**
|
||||
* According to the percent to calculate current FrameData with tween effect
|
||||
*/
|
||||
virtual FrameData *tweenNodeTo(float percent, FrameData *node = NULL);
|
||||
virtual FrameData *tweenNodeTo(float percent, FrameData *node = nullptr);
|
||||
|
||||
/**
|
||||
* According to the percent to calculate current color with tween effect
|
||||
|
@ -124,27 +124,28 @@ protected:
|
|||
virtual void arriveKeyFrame(FrameData *keyFrameData);
|
||||
protected:
|
||||
//! A weak reference to the current MovementBoneData. The data is in the data pool
|
||||
CC_SYNTHESIZE(MovementBoneData *, _movementBoneData, MovementBoneData)
|
||||
MovementBoneData *_movementBoneData;
|
||||
|
||||
FrameData *_tweenData; //! The computational tween frame data, //! A weak reference to the Bone's tweenData
|
||||
FrameData *_from; //! From frame data, used for calculate between value
|
||||
FrameData *_to; //! To frame data, used for calculate between value
|
||||
FrameData *_between; //! Between frame data, used for calculate current FrameData(m_pNode) value
|
||||
FrameData *_tweenData; //! The computational tween frame data, //! A weak reference to the Bone's tweenData
|
||||
FrameData *_from; //! From frame data, used for calculate between value
|
||||
FrameData *_to; //! To frame data, used for calculate between value
|
||||
FrameData *_between; //! Between frame data, used for calculate current FrameData(m_pNode) value
|
||||
|
||||
|
||||
Bone *_bone; //! A weak reference to the Bone
|
||||
Bone *_bone; //! A weak reference to the Bone
|
||||
|
||||
CCTweenType _frameTweenEasing; //! Dedermine which tween effect current frame use
|
||||
TweenType _frameTweenEasing; //! Dedermine which tween effect current frame use
|
||||
|
||||
int _betweenDuration; //! Current key frame will last _betweenDuration frames
|
||||
int _betweenDuration; //! Current key frame will last _betweenDuration frames
|
||||
int _totalDuration;
|
||||
|
||||
|
||||
int _fromIndex; //! The current frame index in FrameList of MovementBoneData, it's different from m_iFrameIndex
|
||||
int _toIndex; //! The next frame index in FrameList of MovementBoneData, it's different from m_iFrameIndex
|
||||
int _fromIndex; //! The current frame index in FrameList of MovementBoneData, it's different from m_iFrameIndex
|
||||
int _toIndex; //! The next frame index in FrameList of MovementBoneData, it's different from m_iFrameIndex
|
||||
|
||||
ArmatureAnimation *_animation;
|
||||
|
||||
bool _passLastFrame; //! If current frame index is more than the last frame's index
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ THE SOFTWARE.
|
|||
|
||||
namespace cocostudio {
|
||||
|
||||
float TweenFunction::tweenTo(float from, float change, float time, float duration, CCTweenType tweenType)
|
||||
float TweenFunction::tweenTo(float from, float change, float time, float duration, TweenType tweenType)
|
||||
{
|
||||
float delta = 0;
|
||||
|
||||
|
@ -163,8 +163,8 @@ float TweenFunction::quadEaseOut(float t, float b, float c, float d)
|
|||
}
|
||||
float TweenFunction::quadEaseInOut(float t, float b, float c, float d)
|
||||
{
|
||||
t /= d;
|
||||
if ((t / 2) < 1)
|
||||
t = t/d*2;
|
||||
if ((t) < 1)
|
||||
return c / 2 * t * t + b;
|
||||
--t;
|
||||
return -c / 2 * (t * (t - 2) - 1) + b;
|
||||
|
@ -182,8 +182,8 @@ float TweenFunction::cubicEaseOut(float t, float b, float c, float d)
|
|||
}
|
||||
float TweenFunction::cubicEaseInOut(float t, float b, float c, float d)
|
||||
{
|
||||
t /= d;
|
||||
if ((t / 2) < 1)
|
||||
t = t/d*2;
|
||||
if ((t) < 1)
|
||||
return c / 2 * t * t * t + b;
|
||||
t -= 2;
|
||||
return c / 2 * (t * t * t + 2) + b;
|
||||
|
@ -201,8 +201,8 @@ float TweenFunction::quartEaseOut(float t, float b, float c, float d)
|
|||
}
|
||||
float TweenFunction::quartEaseInOut(float t, float b, float c, float d)
|
||||
{
|
||||
t /= d;
|
||||
if ((t / 2) < 1)
|
||||
t = t/d*2;
|
||||
if ((t) < 1)
|
||||
return c / 2 * t * t * t * t + b;
|
||||
t -= 2;
|
||||
return -c / 2 * (t * t * t * t - 2) + b;
|
||||
|
@ -220,8 +220,8 @@ float TweenFunction::quintEaseOut(float t, float b, float c, float d)
|
|||
}
|
||||
float TweenFunction::quintEaseInOut(float t, float b, float c, float d)
|
||||
{
|
||||
t /= d;
|
||||
if ((t / 2) < 1)
|
||||
t = t/d*2;
|
||||
if ((t) < 1)
|
||||
return c / 2 * t * t * t * t * t + b;
|
||||
t -= 2;
|
||||
return c / 2 * (t * t * t * t * t + 2) + b;
|
||||
|
@ -272,8 +272,8 @@ float TweenFunction::circEaseOut(float t, float b, float c, float d)
|
|||
}
|
||||
float TweenFunction::circEaseInOut(float t, float b, float c, float d)
|
||||
{
|
||||
t /= d;
|
||||
if ((t / 2) < 1)
|
||||
t = t/d*2;
|
||||
if ((t) < 1)
|
||||
return -c / 2 * (sqrt(1 - t * t) - 1) + b;
|
||||
t -= 2;
|
||||
return c / 2 * (sqrt(1 - t * t) + 1) + b;
|
||||
|
@ -323,8 +323,8 @@ float TweenFunction::elasticEaseInOut(float t, float b, float c, float d, float
|
|||
float s = 0;
|
||||
if (t == 0)
|
||||
return b;
|
||||
t /= d;
|
||||
if ((t / 2) == 2)
|
||||
t = t/d*2;
|
||||
if ((t) == 2)
|
||||
return b + c;
|
||||
if (!p)
|
||||
p = d * (.3 * 1.5);
|
||||
|
|
|
@ -31,16 +31,15 @@ THE SOFTWARE.
|
|||
|
||||
namespace cocostudio {
|
||||
|
||||
enum CCTweenType
|
||||
enum TweenType
|
||||
{
|
||||
TWEEN_EASING_MIN = -1,
|
||||
|
||||
Linear,
|
||||
|
||||
Sine_EaseIn,
|
||||
Sine_EaseInOut,
|
||||
Sine_EaseOut,
|
||||
|
||||
Sine_EaseInOut,
|
||||
|
||||
Quad_EaseIn,
|
||||
Quad_EaseOut,
|
||||
|
@ -85,7 +84,7 @@ class TweenFunction
|
|||
{
|
||||
public:
|
||||
|
||||
static float tweenTo(float from, float change, float time, float duration, CCTweenType tweenType);
|
||||
static float tweenTo(float from, float change, float time, float duration, TweenType tweenType);
|
||||
|
||||
static float linear(float t, float b, float c, float d);
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ void _AtlasPage_disposeTexture (AtlasPage* self) {
|
|||
}
|
||||
|
||||
char* _Util_readFile (const char* path, int* length) {
|
||||
unsigned long size;
|
||||
long size;
|
||||
char* data = reinterpret_cast<char*>(FileUtils::getInstance()->getFileData(
|
||||
FileUtils::getInstance()->fullPathForFilename(path).c_str(), "r", &size));
|
||||
*length = size;
|
||||
|
|
|
@ -9,6 +9,10 @@ add_library(network STATIC
|
|||
|
||||
target_link_libraries(network
|
||||
curl
|
||||
ldap
|
||||
lber
|
||||
idn
|
||||
rtmp
|
||||
)
|
||||
|
||||
set_target_properties(network
|
||||
|
|
|
@ -36,3 +36,9 @@ target_link_libraries(luabinding
|
|||
tolua
|
||||
lua
|
||||
)
|
||||
|
||||
set_target_properties(luabinding
|
||||
PROPERTIES
|
||||
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib"
|
||||
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib"
|
||||
)
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit c2b42be577425e4dd6c2501e8f0cd1520ca3d059
|
||||
Subproject commit f55eab57aa6b3ff20fd33bea986e4569ebd68c8e
|
|
@ -96,6 +96,7 @@ static void executeJSFunctionFromReservedSpot(JSContext *cx, JSObject *obj,
|
|||
if (func == JSVAL_VOID) { return; }
|
||||
jsval thisObj = JS_GetReservedSlot(obj, 1);
|
||||
JSAutoCompartment ac(cx, obj);
|
||||
|
||||
if (thisObj == JSVAL_VOID) {
|
||||
JS_CallFunctionValue(cx, obj, func, 1, &dataVal, &retval);
|
||||
} else {
|
||||
|
@ -527,7 +528,7 @@ JSBool ScriptingCore::runScript(const char *path, JSObject* global, JSContext* c
|
|||
|
||||
// a) check jsc file first
|
||||
std::string byteCodePath = RemoveFileExt(std::string(path)) + BYTE_CODE_FILE_EXT;
|
||||
unsigned long length = 0;
|
||||
long length = 0;
|
||||
unsigned char* data = futil->getFileData(byteCodePath.c_str(),
|
||||
"rb",
|
||||
&length);
|
||||
|
|
|
@ -320,6 +320,8 @@ public:
|
|||
JS_RemoveObjectRoot(this->_cx, &this->_jsthis);
|
||||
}
|
||||
JSBool invoke(unsigned int argc, jsval *argv, jsval &rval) {
|
||||
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
|
||||
|
||||
return JS_CallFunctionValue(this->_cx, this->_jsthis, this->_fval, argc, argv, &rval);
|
||||
}
|
||||
private:
|
||||
|
|
|
@ -638,6 +638,8 @@ static cpBool myCollisionBegin(cpArbiter *arb, cpSpace *space, void *data)
|
|||
args[0] = opaque_to_jsval( handler->cx, arb);
|
||||
args[1] = opaque_to_jsval( handler->cx, space );
|
||||
}
|
||||
|
||||
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
|
||||
|
||||
jsval rval;
|
||||
JSBool ok = JS_CallFunctionValue( handler->cx, handler->jsthis, OBJECT_TO_JSVAL(handler->begin), 2, args, &rval);
|
||||
|
@ -662,6 +664,8 @@ static cpBool myCollisionPre(cpArbiter *arb, cpSpace *space, void *data)
|
|||
args[0] = opaque_to_jsval( handler->cx, arb);
|
||||
args[1] = opaque_to_jsval( handler->cx, space );
|
||||
}
|
||||
|
||||
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
|
||||
|
||||
jsval rval;
|
||||
JSBool ok = JS_CallFunctionValue( handler->cx, handler->jsthis, OBJECT_TO_JSVAL(handler->pre), 2, args, &rval);
|
||||
|
@ -687,6 +691,8 @@ static void myCollisionPost(cpArbiter *arb, cpSpace *space, void *data)
|
|||
args[0] = opaque_to_jsval( handler->cx, arb);
|
||||
args[1] = opaque_to_jsval( handler->cx, space );
|
||||
}
|
||||
|
||||
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
|
||||
|
||||
jsval ignore;
|
||||
JSBool ok = JS_CallFunctionValue( handler->cx, handler->jsthis, OBJECT_TO_JSVAL(handler->post), 2, args, &ignore);
|
||||
|
@ -705,6 +711,8 @@ static void myCollisionSeparate(cpArbiter *arb, cpSpace *space, void *data)
|
|||
args[0] = opaque_to_jsval( handler->cx, arb);
|
||||
args[1] = opaque_to_jsval( handler->cx, space );
|
||||
}
|
||||
|
||||
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
|
||||
|
||||
jsval ignore;
|
||||
JSBool ok = JS_CallFunctionValue( handler->cx, handler->jsthis, OBJECT_TO_JSVAL(handler->separate), 2, args, &ignore);
|
||||
|
|
|
@ -1 +1 @@
|
|||
c93df276adb92b5e076db49c4f9482b8eb37d45c
|
||||
927efea93a520eeb9db9f62c8d8eb7a7b93b08dc
|
|
@ -14,6 +14,8 @@ public:
|
|||
jsval retval = JSVAL_NULL;
|
||||
|
||||
if(!JSVAL_IS_VOID(_jsCallback) && !JSVAL_IS_VOID(_jsThisObj)) {
|
||||
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
|
||||
|
||||
JS_CallFunctionValue(cx, JSVAL_TO_OBJECT(_jsThisObj), _jsCallback, 0, NULL, &retval);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,6 +73,9 @@ void JSArmatureWrapper::movementCallbackFunc(cocostudio::Armature *pArmature, co
|
|||
valArr[2] = idVal;
|
||||
|
||||
JS_AddValueRoot(cx, valArr);
|
||||
|
||||
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
|
||||
|
||||
JS_CallFunctionValue(cx, thisObj, _jsCallback, 3, valArr, &retval);
|
||||
JS_RemoveValueRoot(cx, valArr);
|
||||
}
|
||||
|
@ -88,6 +91,9 @@ void JSArmatureWrapper::addArmatureFileInfoAsyncCallbackFunc(float percent)
|
|||
jsval percentVal = DOUBLE_TO_JSVAL(percent);
|
||||
|
||||
JS_AddValueRoot(cx, &percentVal);
|
||||
|
||||
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
|
||||
|
||||
JS_CallFunctionValue(cx, thisObj, _jsCallback, 1, &percentVal, &retval);
|
||||
JS_RemoveValueRoot(cx, &percentVal);
|
||||
}
|
||||
|
@ -113,6 +119,9 @@ void JSArmatureWrapper::frameCallbackFunc(cocostudio::Bone *pBone, const char *f
|
|||
valArr[3] = currentIndexVal;
|
||||
|
||||
JS_AddValueRoot(cx, valArr);
|
||||
|
||||
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
|
||||
|
||||
JS_CallFunctionValue(cx, thisObj, _jsCallback, 4, valArr, &retval);
|
||||
JS_RemoveValueRoot(cx, valArr);
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ extern "C"
|
|||
}
|
||||
filename.append(".lua");
|
||||
|
||||
unsigned long codeBufferSize = 0;
|
||||
long codeBufferSize = 0;
|
||||
unsigned char* codeBuffer = FileUtils::getInstance()->getFileData(filename.c_str(), "rb", &codeBufferSize);
|
||||
|
||||
if (codeBuffer)
|
||||
|
|
|
@ -53,3 +53,9 @@ include_directories(
|
|||
add_library(box2d STATIC
|
||||
${BOX2D_SRC}
|
||||
)
|
||||
|
||||
set_target_properties(box2d
|
||||
PROPERTIES
|
||||
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib"
|
||||
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib"
|
||||
)
|
||||
|
|
|
@ -33,4 +33,10 @@ set(LUA_SRC
|
|||
|
||||
add_library(lua STATIC
|
||||
${LUA_SRC}
|
||||
)
|
||||
)
|
||||
|
||||
set_target_properties(lua
|
||||
PROPERTIES
|
||||
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib"
|
||||
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib"
|
||||
)
|
||||
|
|
|
@ -15,3 +15,8 @@ add_library(tolua STATIC
|
|||
${TOLUA_SRC}
|
||||
)
|
||||
|
||||
set_target_properties(tolua
|
||||
PROPERTIES
|
||||
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib"
|
||||
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib"
|
||||
)
|
||||
|
|
|
@ -1,5 +1,15 @@
|
|||
|
||||
if(BUILD_HelloCpp)
|
||||
add_subdirectory(Cpp/HelloCpp)
|
||||
endif(BUILD_HelloCpp)
|
||||
|
||||
if(BUILD_TestCpp)
|
||||
add_subdirectory(Cpp/TestCpp)
|
||||
endif(BUILD_TestCpp)
|
||||
|
||||
if(BUILD_HelloLua)
|
||||
add_subdirectory(Lua/HelloLua)
|
||||
endif(BUILD_HelloLua)
|
||||
|
||||
if(BUILD_TestLua)
|
||||
add_subdirectory(Lua/TestLua)
|
||||
endif(BUILD_TestLua)
|
|
@ -18,5 +18,8 @@ set(APP_BIN_DIR "${CMAKE_SOURCE_DIR}/bin/${APP_NAME}")
|
|||
set_target_properties(${APP_NAME} PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY "${APP_BIN_DIR}")
|
||||
|
||||
COPY_RES( ${APP_NAME} )
|
||||
pre_build(${APP_NAME}
|
||||
COMMAND ${CMAKE_COMMAND} -E remove_directory ${APP_BIN_DIR}/Resources
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/Resources ${APP_BIN_DIR}/Resources
|
||||
)
|
||||
|
||||
|
|
|
@ -159,5 +159,8 @@ set(APP_BIN_DIR "${CMAKE_SOURCE_DIR}/bin/${APP_NAME}")
|
|||
set_target_properties(${APP_NAME} PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY "${APP_BIN_DIR}")
|
||||
|
||||
COPY_RES( ${APP_NAME} )
|
||||
pre_build(${APP_NAME}
|
||||
COMMAND ${CMAKE_COMMAND} -E remove_directory ${APP_BIN_DIR}/Resources
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/Resources ${APP_BIN_DIR}/Resources
|
||||
)
|
||||
|
||||
|
|
|
@ -15,12 +15,15 @@ static int s_nActionIdx = -1;
|
|||
|
||||
Layer *CreateLayer(int index)
|
||||
{
|
||||
Layer *pLayer = NULL;
|
||||
Layer *pLayer = nullptr;
|
||||
switch(index)
|
||||
{
|
||||
case TEST_ASYNCHRONOUS_LOADING:
|
||||
pLayer = new TestAsynchronousLoading();
|
||||
break;
|
||||
case TEST_DIRECT_LOADING:
|
||||
pLayer = new TestDirectLoading();
|
||||
break;
|
||||
case TEST_DRAGON_BONES_2_0:
|
||||
pLayer = new TestDragonBones20();
|
||||
break;
|
||||
|
@ -30,12 +33,18 @@ Layer *CreateLayer(int index)
|
|||
case TEST_PERFORMANCE:
|
||||
pLayer = new TestPerformance();
|
||||
break;
|
||||
case TEST_PERFORMANCE_BATCHNODE:
|
||||
pLayer = new TestPerformanceBatchNode();
|
||||
break;
|
||||
case TEST_CHANGE_ZORDER:
|
||||
pLayer = new TestChangeZorder();
|
||||
break;
|
||||
case TEST_ANIMATION_EVENT:
|
||||
pLayer = new TestAnimationEvent();
|
||||
break;
|
||||
case TEST_FRAME_EVENT:
|
||||
pLayer = new TestFrameEvent();
|
||||
break;
|
||||
case TEST_PARTICLE_DISPLAY:
|
||||
pLayer = new TestParticleDisplay();
|
||||
break;
|
||||
|
@ -54,6 +63,9 @@ Layer *CreateLayer(int index)
|
|||
case TEST_ARMATURE_NESTING:
|
||||
pLayer = new TestArmatureNesting();
|
||||
break;
|
||||
case TEST_ARMATURE_NESTING_2:
|
||||
pLayer = new TestArmatureNesting2();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -155,7 +167,7 @@ void ArmatureTestLayer::onEnter()
|
|||
restartItem = MenuItemImage::create(s_pathR1, s_pathR2, CC_CALLBACK_1(ArmatureTestLayer::restartCallback, this) );
|
||||
nextItem = MenuItemImage::create(s_pathF1, s_pathF2, CC_CALLBACK_1(ArmatureTestLayer::nextCallback, this) );
|
||||
|
||||
Menu *menu = Menu::create(backItem, restartItem, nextItem, NULL);
|
||||
Menu *menu = Menu::create(backItem, restartItem, nextItem, nullptr);
|
||||
|
||||
menu->setPosition(Point::ZERO);
|
||||
backItem->setPosition(Point(VisibleRect::center().x - restartItem->getContentSize().width * 2, VisibleRect::bottom().y + restartItem->getContentSize().height / 2));
|
||||
|
@ -171,7 +183,7 @@ void ArmatureTestLayer::onExit()
|
|||
{
|
||||
removeAllChildren();
|
||||
|
||||
backItem = restartItem = nextItem = NULL;
|
||||
backItem = restartItem = nextItem = nullptr;
|
||||
|
||||
Layer::onExit();
|
||||
}
|
||||
|
@ -235,6 +247,10 @@ void TestAsynchronousLoading::onEnter()
|
|||
ArmatureDataManager::getInstance()->addArmatureFileInfoAsync("armature/cyborg.png", "armature/cyborg.plist", "armature/cyborg.xml", this, schedule_selector(TestAsynchronousLoading::dataLoaded));
|
||||
ArmatureDataManager::getInstance()->addArmatureFileInfoAsync("armature/Dragon.png", "armature/Dragon.plist", "armature/Dragon.xml", this, schedule_selector(TestAsynchronousLoading::dataLoaded));
|
||||
ArmatureDataManager::getInstance()->addArmatureFileInfoAsync("armature/Cowboy.ExportJson", this, schedule_selector(TestAsynchronousLoading::dataLoaded));
|
||||
ArmatureDataManager::getInstance()->addArmatureFileInfoAsync("armature/hero.ExportJson", this, schedule_selector(TestAsynchronousLoading::dataLoaded));
|
||||
ArmatureDataManager::getInstance()->addArmatureFileInfoAsync("armature/horse.ExportJson", this, schedule_selector(TestAsynchronousLoading::dataLoaded));
|
||||
ArmatureDataManager::getInstance()->addArmatureFileInfoAsync("armature/bear.ExportJson", this, schedule_selector(TestAsynchronousLoading::dataLoaded));
|
||||
ArmatureDataManager::getInstance()->addArmatureFileInfoAsync("armature/HeroAnimation.ExportJson", this, schedule_selector(TestAsynchronousLoading::dataLoaded));
|
||||
|
||||
//! load data directly
|
||||
// ArmatureDataManager::getInstance()->addArmatureFileInfo("armature/knight.png", "armature/knight.plist", "armature/knight.xml");
|
||||
|
@ -254,6 +270,12 @@ std::string TestAsynchronousLoading::subtitle()
|
|||
{
|
||||
return "current percent : ";
|
||||
}
|
||||
|
||||
void TestAsynchronousLoading::restartCallback(Object* pSender)
|
||||
{
|
||||
ArmatureDataManager::getInstance()->destoryInstance();
|
||||
ArmatureTestLayer::restartCallback(pSender);
|
||||
}
|
||||
void TestAsynchronousLoading::dataLoaded(float percent)
|
||||
{
|
||||
LabelTTF *label = (LabelTTF *)getChildByTag(10001);
|
||||
|
@ -273,11 +295,31 @@ void TestAsynchronousLoading::dataLoaded(float percent)
|
|||
}
|
||||
|
||||
|
||||
void TestDirectLoading::onEnter()
|
||||
{
|
||||
ArmatureTestLayer::onEnter();
|
||||
|
||||
// remove sigle resource
|
||||
ArmatureDataManager::getInstance()->removeArmatureFileInfo("armature/bear.ExportJson");
|
||||
|
||||
// load resource directly
|
||||
ArmatureDataManager::getInstance()->addArmatureFileInfo("armature/bear.ExportJson");
|
||||
|
||||
Armature *armature = Armature::create("bear");
|
||||
armature->getAnimation()->playByIndex(0);
|
||||
armature->setPosition(Point(VisibleRect::center().x, VisibleRect::center().y));
|
||||
addChild(armature);
|
||||
}
|
||||
std::string TestDirectLoading::title()
|
||||
{
|
||||
return "Test Direct Loading";
|
||||
}
|
||||
|
||||
|
||||
void TestCSWithSkeleton::onEnter()
|
||||
{
|
||||
ArmatureTestLayer::onEnter();
|
||||
Armature *armature = NULL;
|
||||
Armature *armature = nullptr;
|
||||
armature = Armature::create("Cowboy");
|
||||
armature->getAnimation()->playByIndex(0);
|
||||
armature->setScale(0.2f);
|
||||
|
@ -298,7 +340,7 @@ void TestDragonBones20::onEnter()
|
|||
{
|
||||
ArmatureTestLayer::onEnter();
|
||||
|
||||
Armature *armature = NULL;
|
||||
Armature *armature = nullptr;
|
||||
armature = Armature::create("Dragon");
|
||||
armature->getAnimation()->playByIndex(1);
|
||||
armature->getAnimation()->setSpeedScale(0.4f);
|
||||
|
@ -314,6 +356,8 @@ std::string TestDragonBones20::title()
|
|||
|
||||
|
||||
|
||||
#define ArmaturePerformanceTag 20000
|
||||
|
||||
TestPerformance::~TestPerformance()
|
||||
{
|
||||
}
|
||||
|
@ -321,10 +365,22 @@ void TestPerformance::onEnter()
|
|||
{
|
||||
ArmatureTestLayer::onEnter();
|
||||
|
||||
|
||||
MenuItemFont::setFontSize(65);
|
||||
MenuItemFont *decrease = MenuItemFont::create(" - ", CC_CALLBACK_1(TestPerformance::onDecrease, this));
|
||||
decrease->setColor(Color3B(0,200,20));
|
||||
MenuItemFont *increase = MenuItemFont::create(" + ", CC_CALLBACK_1(TestPerformance::onIncrease, this));
|
||||
increase->setColor(Color3B(0,200,20));
|
||||
|
||||
Menu *menu = Menu::create(decrease, increase, nullptr);
|
||||
menu->alignItemsHorizontally();
|
||||
menu->setPosition(Point(VisibleRect::getVisibleRect().size.width/2, VisibleRect::getVisibleRect().size.height-100));
|
||||
addChild(menu, 10000);
|
||||
|
||||
armatureCount = frames = times = lastTimes = 0;
|
||||
generated = false;
|
||||
|
||||
scheduleUpdate();
|
||||
addArmature(100);
|
||||
}
|
||||
|
||||
std::string TestPerformance::title()
|
||||
|
@ -335,44 +391,83 @@ std::string TestPerformance::subtitle()
|
|||
{
|
||||
return "Current Armature Count : ";
|
||||
}
|
||||
void TestPerformance::addArmature(Armature *armature)
|
||||
void TestPerformance::onIncrease(Object* pSender)
|
||||
{
|
||||
armatureCount++;
|
||||
addChild(armature, armatureCount);
|
||||
addArmature(20);
|
||||
}
|
||||
void TestPerformance::update(float delta)
|
||||
void TestPerformance::onDecrease(Object* pSender)
|
||||
{
|
||||
frames ++;
|
||||
times += delta;
|
||||
if (armatureCount == 0)
|
||||
return;
|
||||
|
||||
if (frames / times > 58)
|
||||
for (int i = 0; i<20; i++)
|
||||
{
|
||||
Armature *armature = NULL;
|
||||
removeArmatureFromParent(ArmaturePerformanceTag + armatureCount);
|
||||
armatureCount --;
|
||||
refreshTitile();
|
||||
}
|
||||
}
|
||||
void TestPerformance::addArmature(int number)
|
||||
{
|
||||
for (int i = 0; i<number; i++)
|
||||
{
|
||||
armatureCount++;
|
||||
|
||||
Armature *armature = nullptr;
|
||||
armature = new Armature();
|
||||
armature->init("Knight_f/Knight");
|
||||
armature->getAnimation()->playByIndex(0);
|
||||
armature->setPosition(50 + armatureCount * 2, 150);
|
||||
armature->setScale(0.6f);
|
||||
addArmature(armature);
|
||||
addArmatureToParent(armature);
|
||||
armature->release();
|
||||
|
||||
char pszCount[255];
|
||||
sprintf(pszCount, "%s %i", subtitle().c_str(), armatureCount);
|
||||
LabelTTF *label = (LabelTTF *)getChildByTag(10001);
|
||||
label->setString(pszCount);
|
||||
}
|
||||
|
||||
refreshTitile();
|
||||
}
|
||||
void TestPerformance::addArmatureToParent(cocostudio::Armature *armature)
|
||||
{
|
||||
addChild(armature, 0, ArmaturePerformanceTag + armatureCount);
|
||||
}
|
||||
void TestPerformance::removeArmatureFromParent(int tag)
|
||||
{
|
||||
removeChildByTag(ArmaturePerformanceTag + armatureCount);
|
||||
}
|
||||
void TestPerformance::refreshTitile()
|
||||
{
|
||||
char pszCount[255];
|
||||
sprintf(pszCount, "%s %i", subtitle().c_str(), armatureCount);
|
||||
LabelTTF *label = (LabelTTF *)getChildByTag(10001);
|
||||
label->setString(pszCount);
|
||||
}
|
||||
|
||||
|
||||
void TestPerformanceBatchNode::onEnter()
|
||||
{
|
||||
batchNode = BatchNode::create();
|
||||
addChild(batchNode);
|
||||
|
||||
|
||||
TestPerformance::onEnter();
|
||||
}
|
||||
std::string TestPerformanceBatchNode::title()
|
||||
{
|
||||
return "Test Performance of using BatchNode";
|
||||
}
|
||||
void TestPerformanceBatchNode::addArmatureToParent(cocostudio::Armature *armature)
|
||||
{
|
||||
batchNode->addChild(armature, 0, ArmaturePerformanceTag + armatureCount);
|
||||
}
|
||||
void TestPerformanceBatchNode::removeArmatureFromParent(int tag)
|
||||
{
|
||||
batchNode->removeChildByTag(ArmaturePerformanceTag + armatureCount);
|
||||
}
|
||||
|
||||
|
||||
void TestChangeZorder::onEnter()
|
||||
{
|
||||
ArmatureTestLayer::onEnter();
|
||||
|
||||
Armature *armature = NULL;
|
||||
Armature *armature = nullptr;
|
||||
currentTag = -1;
|
||||
|
||||
armature = Armature::create("Knight_f/Knight");
|
||||
|
@ -429,7 +524,7 @@ void TestAnimationEvent::onEnter()
|
|||
|
||||
/*
|
||||
* Set armature's movement event callback function
|
||||
* To disconnect this event, just setMovementEventCallFunc(NULL, NULL);
|
||||
* To disconnect this event, just setMovementEventCallFunc(nullptr, nullptr);
|
||||
*/
|
||||
armature->getAnimation()->setMovementEventCallFunc(this, movementEvent_selector(TestAnimationEvent::animationEvent));
|
||||
addChild(armature);
|
||||
|
@ -448,14 +543,14 @@ void TestAnimationEvent::animationEvent(Armature *armature, MovementEventType mo
|
|||
{
|
||||
ActionInterval *actionToRight = MoveTo::create(2, Point(VisibleRect::right().x - 50, VisibleRect::right().y));
|
||||
armature->stopAllActions();
|
||||
armature->runAction(Sequence::create(actionToRight, CallFunc::create( CC_CALLBACK_0(TestAnimationEvent::callback1, this)), NULL));
|
||||
armature->runAction(Sequence::create(actionToRight, CallFunc::create( CC_CALLBACK_0(TestAnimationEvent::callback1, this)), nullptr));
|
||||
armature->getAnimation()->play("Walk");
|
||||
}
|
||||
else if (id.compare("FireMax") == 0)
|
||||
{
|
||||
ActionInterval *actionToLeft = MoveTo::create(2, Point(VisibleRect::left().x + 50, VisibleRect::left().y));
|
||||
armature->stopAllActions();
|
||||
armature->runAction(Sequence::create(actionToLeft, CallFunc::create( CC_CALLBACK_0(TestAnimationEvent::callback2, this)), NULL));
|
||||
armature->runAction(Sequence::create(actionToLeft, CallFunc::create( CC_CALLBACK_0(TestAnimationEvent::callback2, this)), nullptr));
|
||||
armature->getAnimation()->play("Walk");
|
||||
}
|
||||
}
|
||||
|
@ -473,6 +568,51 @@ void TestAnimationEvent::callback2()
|
|||
|
||||
|
||||
|
||||
#define FRAME_EVENT_ACTION_TAG 10000
|
||||
|
||||
void TestFrameEvent::onEnter()
|
||||
{
|
||||
ArmatureTestLayer::onEnter();
|
||||
Armature *armature = Armature::create("HeroAnimation");
|
||||
armature->getAnimation()->play("attack");
|
||||
armature->getAnimation()->setSpeedScale(0.5);
|
||||
armature->setPosition(Point(VisibleRect::center().x - 50, VisibleRect::center().y -100));
|
||||
|
||||
/*
|
||||
* Set armature's frame event callback function
|
||||
* To disconnect this event, just setFrameEventCallFunc(nullptr, nullptr);
|
||||
*/
|
||||
armature->getAnimation()->setFrameEventCallFunc(this, frameEvent_selector(TestFrameEvent::onFrameEvent));
|
||||
|
||||
addChild(armature);
|
||||
|
||||
schedule( schedule_selector(TestFrameEvent::checkAction) );
|
||||
}
|
||||
std::string TestFrameEvent::title()
|
||||
{
|
||||
return "Test Frame Event";
|
||||
}
|
||||
void TestFrameEvent::onFrameEvent(Bone *bone, const char *evt, int originFrameIndex, int currentFrameIndex)
|
||||
{
|
||||
CCLOG("(%s) emit a frame event (%s) at frame index (%d).", bone->getName().c_str(), evt, currentFrameIndex);
|
||||
|
||||
|
||||
if (!this->getActionByTag(FRAME_EVENT_ACTION_TAG) || this->getActionByTag(FRAME_EVENT_ACTION_TAG)->isDone())
|
||||
{
|
||||
this->stopAllActions();
|
||||
|
||||
ActionInterval *action = ShatteredTiles3D::create(0.2f, Size(16,12), 5, false);
|
||||
action->setTag(FRAME_EVENT_ACTION_TAG);
|
||||
this->runAction(action);
|
||||
}
|
||||
}
|
||||
void TestFrameEvent::checkAction(float dt)
|
||||
{
|
||||
if ( this->getNumberOfRunningActions() == 0 && this->getGrid() != nullptr)
|
||||
this->setGrid(nullptr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void TestParticleDisplay::onEnter()
|
||||
{
|
||||
|
@ -610,7 +750,7 @@ void TestColliderDetector::onEnter()
|
|||
|
||||
/*
|
||||
* Set armature's frame event callback function
|
||||
* To disconnect this event, just setFrameEventCallFunc(NULL, NULL);
|
||||
* To disconnect this event, just setFrameEventCallFunc(nullptr, nullptr);
|
||||
*/
|
||||
armature->getAnimation()->setFrameEventCallFunc(this, frameEvent_selector(TestColliderDetector::onFrameEvent));
|
||||
|
||||
|
@ -864,19 +1004,14 @@ void TestColliderDetector::initWorld()
|
|||
|
||||
bullet->setCPBody(body);
|
||||
|
||||
body = cpBodyNew(INFINITY, INFINITY);
|
||||
body = cpBodyNew(1.0f, INFINITY);
|
||||
cpSpaceAddBody(space, body);
|
||||
armature2->setBody(body);
|
||||
|
||||
shape = armature2->getShapeList();
|
||||
while(shape)
|
||||
{
|
||||
cpShape *next = shape->next_private;
|
||||
shape->collision_type = eEnemyTag;
|
||||
shape = next;
|
||||
}
|
||||
ColliderFilter filter = ColliderFilter(eEnemyTag);
|
||||
armature2->setColliderFilter(&filter);
|
||||
|
||||
cpSpaceAddCollisionHandler(space, eEnemyTag, eBulletTag, beginHit, NULL, NULL, endHit, NULL);
|
||||
cpSpaceAddCollisionHandler(space, eEnemyTag, eBulletTag, beginHit, nullptr, nullptr, endHit, nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -905,7 +1040,7 @@ void TestBoundingBox::draw()
|
|||
{
|
||||
CC_NODE_DRAW_SETUP();
|
||||
|
||||
rect = RectApplyAffineTransform(armature->getBoundingBox(), armature->getNodeToParentTransform());
|
||||
rect = armature->getBoundingBox();
|
||||
|
||||
DrawPrimitives::setDrawColor4B(100, 100, 100, 255);
|
||||
DrawPrimitives::drawRect(rect.origin, Point(rect.getMaxX(), rect.getMaxY()));
|
||||
|
@ -971,9 +1106,190 @@ void TestArmatureNesting::onTouchesEnded(const std::vector<Touch*>& touches, Eve
|
|||
++weaponIndex;
|
||||
weaponIndex = weaponIndex % 4;
|
||||
|
||||
if(armature != NULL)
|
||||
if(armature != nullptr)
|
||||
{
|
||||
armature->getBone("armInside")->getChildArmature()->getAnimation()->playByIndex(weaponIndex);
|
||||
armature->getBone("armOutside")->getChildArmature()->getAnimation()->playByIndex(weaponIndex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Hero *Hero::create(const char *name)
|
||||
{
|
||||
Hero *hero = new Hero();
|
||||
if (hero && hero->init(name))
|
||||
{
|
||||
hero->autorelease();
|
||||
return hero;
|
||||
}
|
||||
CC_SAFE_DELETE(hero);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Hero::Hero()
|
||||
: m_pMount(nullptr)
|
||||
, m_pLayer(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
void Hero::changeMount(Armature *armature)
|
||||
{
|
||||
if (armature == nullptr)
|
||||
{
|
||||
retain();
|
||||
|
||||
playByIndex(0);
|
||||
//Remove hero from display list
|
||||
m_pMount->getBone("hero")->removeDisplay(0);
|
||||
m_pMount->stopAllActions();
|
||||
|
||||
//Set position to current position
|
||||
setPosition(m_pMount->getPosition());
|
||||
//Add to layer
|
||||
m_pLayer->addChild(this);
|
||||
|
||||
release();
|
||||
|
||||
setMount(armature);
|
||||
}
|
||||
else
|
||||
{
|
||||
setMount(armature);
|
||||
|
||||
retain();
|
||||
//Remove from layer
|
||||
removeFromParentAndCleanup(false);
|
||||
|
||||
//Get the hero bone
|
||||
Bone *bone = armature->getBone("hero");
|
||||
//Add hero as a display to this bone
|
||||
bone->addDisplay(this, 0);
|
||||
//Change this bone's display
|
||||
bone->changeDisplayByIndex(0, true);
|
||||
bone->setIgnoreMovementBoneData(true);
|
||||
|
||||
setPosition(Point(0,0));
|
||||
//Change animation
|
||||
playByIndex(1);
|
||||
|
||||
setScale(1);
|
||||
|
||||
release();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Hero::playByIndex(int index)
|
||||
{
|
||||
_animation->playByIndex(index);
|
||||
if (m_pMount)
|
||||
{
|
||||
m_pMount->getAnimation()->playByIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
void TestArmatureNesting2::onEnter()
|
||||
{
|
||||
ArmatureTestLayer::onEnter();
|
||||
|
||||
auto listener = EventListenerTouchAllAtOnce::create();
|
||||
listener->onTouchesEnded = CC_CALLBACK_2(TestArmatureNesting2::onTouchesEnded, this);
|
||||
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
|
||||
|
||||
touchedMenu = false;
|
||||
|
||||
LabelTTF* label = CCLabelTTF::create("Change Mount", "Arial", 20);
|
||||
MenuItemLabel* pMenuItem = CCMenuItemLabel::create(label, CC_CALLBACK_1(TestArmatureNesting2::ChangeMountCallback, this));
|
||||
|
||||
Menu* pMenu =Menu::create(pMenuItem, nullptr);
|
||||
|
||||
pMenu->setPosition( Point() );
|
||||
pMenuItem->setPosition( Point( VisibleRect::right().x - 67, VisibleRect::bottom().y + 50) );
|
||||
|
||||
addChild(pMenu, 2);
|
||||
|
||||
//Create a hero
|
||||
hero = Hero::create("hero");
|
||||
hero->setLayer(this);
|
||||
hero->playByIndex(0);
|
||||
hero->setPosition(Point(VisibleRect::left().x + 20, VisibleRect::left().y));
|
||||
addChild(hero);
|
||||
|
||||
//Create 3 mount
|
||||
horse = createMount("horse", VisibleRect::center());
|
||||
|
||||
horse2 = createMount("horse", Point(120, 200));
|
||||
horse2->setOpacity(200);
|
||||
|
||||
bear = createMount("bear", Point(300,70));
|
||||
}
|
||||
void TestArmatureNesting2::onExit()
|
||||
{
|
||||
ArmatureTestLayer::onExit();
|
||||
}
|
||||
std::string TestArmatureNesting2::title()
|
||||
{
|
||||
return "Test CCArmature Nesting 2";
|
||||
}
|
||||
std::string TestArmatureNesting2::subtitle()
|
||||
{
|
||||
return "Move to a mount and press the ChangeMount Button.";
|
||||
}
|
||||
void TestArmatureNesting2::onTouchesEnded(const std::vector<Touch*>& touches, Event* event)
|
||||
{
|
||||
Point point = touches[0]->getLocation();
|
||||
|
||||
Armature *armature = hero->getMount() == nullptr ? hero : hero->getMount();
|
||||
|
||||
//Set armature direction
|
||||
if (point.x < armature->getPositionX())
|
||||
{
|
||||
armature->setScaleX(-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
armature->setScaleX(1);
|
||||
}
|
||||
|
||||
ActionInterval *move = CCMoveTo::create(2, point);
|
||||
armature->stopAllActions();
|
||||
armature->runAction(Sequence::create(move, nullptr));
|
||||
}
|
||||
|
||||
void TestArmatureNesting2::ChangeMountCallback(Object* pSender)
|
||||
{
|
||||
hero->stopAllActions();
|
||||
|
||||
if (hero->getMount())
|
||||
{
|
||||
hero->changeMount(nullptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (hero->getPosition().getDistance(horse->getPosition()) < 20)
|
||||
{
|
||||
hero->changeMount(horse);
|
||||
}
|
||||
else if (hero->getPosition().getDistance(horse2->getPosition()) < 20)
|
||||
{
|
||||
hero->changeMount(horse2);
|
||||
}
|
||||
else if (hero->getPosition().getDistance(bear->getPosition()) < 30)
|
||||
{
|
||||
hero->changeMount(bear);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Armature * TestArmatureNesting2::createMount(const char *name, Point position)
|
||||
{
|
||||
Armature *armature = Armature::create(name);
|
||||
armature->getAnimation()->playByIndex(0);
|
||||
armature->setPosition(position);
|
||||
addChild(armature);
|
||||
|
||||
return armature;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,17 +27,21 @@ public:
|
|||
|
||||
enum {
|
||||
TEST_ASYNCHRONOUS_LOADING = 0,
|
||||
TEST_DIRECT_LOADING,
|
||||
TEST_COCOSTUDIO_WITH_SKELETON,
|
||||
TEST_DRAGON_BONES_2_0,
|
||||
TEST_PERFORMANCE,
|
||||
TEST_PERFORMANCE_BATCHNODE,
|
||||
TEST_CHANGE_ZORDER,
|
||||
TEST_ANIMATION_EVENT,
|
||||
TEST_FRAME_EVENT,
|
||||
TEST_PARTICLE_DISPLAY,
|
||||
TEST_USE_DIFFERENT_PICTURE,
|
||||
TEST_BCOLLIDER_DETECTOR,
|
||||
TEST_BOUDINGBOX,
|
||||
TEST_ANCHORPOINT,
|
||||
TEST_ARMATURE_NESTING,
|
||||
TEST_ARMATURE_NESTING_2,
|
||||
|
||||
TEST_LAYER_COUNT
|
||||
};
|
||||
|
@ -70,10 +74,18 @@ public:
|
|||
virtual void onEnter();
|
||||
virtual std::string title();
|
||||
virtual std::string subtitle();
|
||||
virtual void restartCallback(Object* pSender);
|
||||
|
||||
void dataLoaded(float percent);
|
||||
};
|
||||
|
||||
class TestDirectLoading : public ArmatureTestLayer
|
||||
{
|
||||
public:
|
||||
virtual void onEnter();
|
||||
virtual std::string title();
|
||||
};
|
||||
|
||||
class TestCSWithSkeleton : public ArmatureTestLayer
|
||||
{
|
||||
virtual void onEnter();
|
||||
|
@ -97,8 +109,12 @@ public:
|
|||
virtual void onEnter();
|
||||
virtual std::string title();
|
||||
virtual std::string subtitle();
|
||||
virtual void addArmature(cocostudio::Armature *armature);
|
||||
void update(float delta);
|
||||
virtual void onIncrease(Object* pSender);
|
||||
virtual void onDecrease(Object* pSender);
|
||||
virtual void addArmature(int number);
|
||||
virtual void addArmatureToParent(cocostudio::Armature *armature);
|
||||
virtual void removeArmatureFromParent(int tag);
|
||||
virtual void refreshTitile();
|
||||
|
||||
int armatureCount;
|
||||
|
||||
|
@ -108,6 +124,15 @@ public:
|
|||
bool generated;
|
||||
};
|
||||
|
||||
class TestPerformanceBatchNode : public TestPerformance
|
||||
{
|
||||
virtual void onEnter();
|
||||
virtual std::string title();
|
||||
virtual void addArmatureToParent(cocostudio::Armature *armature);
|
||||
virtual void removeArmatureFromParent(int tag);
|
||||
|
||||
cocostudio::BatchNode *batchNode;
|
||||
};
|
||||
|
||||
class TestChangeZorder : public ArmatureTestLayer
|
||||
{
|
||||
|
@ -132,6 +157,17 @@ public:
|
|||
cocostudio::Armature *armature;
|
||||
};
|
||||
|
||||
|
||||
class TestFrameEvent : public ArmatureTestLayer
|
||||
{
|
||||
public:
|
||||
virtual void onEnter();
|
||||
virtual std::string title();
|
||||
void onFrameEvent(cocostudio::Bone *bone, const char *evt, int originFrameIndex, int currentFrameIndex);
|
||||
void checkAction(float dt);
|
||||
};
|
||||
|
||||
|
||||
class TestUseMutiplePicture : public ArmatureTestLayer
|
||||
{
|
||||
virtual void onEnter();
|
||||
|
@ -256,4 +292,39 @@ public:
|
|||
cocostudio::Armature *armature;
|
||||
int weaponIndex;
|
||||
};
|
||||
|
||||
class Hero : public cocostudio::Armature
|
||||
{
|
||||
public:
|
||||
static Hero *create(const char *name);
|
||||
Hero();
|
||||
|
||||
virtual void changeMount(cocostudio::Armature *armature);
|
||||
virtual void playByIndex(int index);
|
||||
|
||||
CC_SYNTHESIZE(cocostudio::Armature*, m_pMount, Mount);
|
||||
CC_SYNTHESIZE(cocos2d::Layer*, m_pLayer, Layer);
|
||||
};
|
||||
|
||||
class TestArmatureNesting2 : public ArmatureTestLayer
|
||||
{
|
||||
public:
|
||||
virtual void onEnter();
|
||||
virtual void onExit();
|
||||
virtual std::string title();
|
||||
virtual std::string subtitle();
|
||||
void onTouchesEnded(const std::vector<Touch*>& touches, Event* event);
|
||||
|
||||
virtual void ChangeMountCallback(Object* pSender);
|
||||
virtual cocostudio::Armature *createMount(const char *name, Point position);
|
||||
|
||||
Hero *hero;
|
||||
|
||||
cocostudio::Armature *horse;
|
||||
cocostudio::Armature *horse2;
|
||||
cocostudio::Armature *bear;
|
||||
|
||||
|
||||
bool touchedMenu;
|
||||
};
|
||||
#endif // __HELLOWORLD_SCENE_H__
|
|
@ -1,56 +1,56 @@
|
|||
<skeleton name="Dragon" frameRate="24" version="2.0">
|
||||
<skeleton name="Dragon" frameRate="24" version="2.2">
|
||||
<armatures>
|
||||
<armature name="Dragon">
|
||||
<b name="tailTip" x="169.9" y="-106.15" kX="30" kY="30" cX="1" cY="1" pX="23" pY="93" z="0">
|
||||
<d name="parts-tailTip"/>
|
||||
<b name="tailTip" parent="tail" x="169.9" y="-106.15" kX="30" kY="30" cX="1" cY="1" pX="23.25" pY="93.05" z="0">
|
||||
<d name="parts-tailTip" pX="0" pY="0"/>
|
||||
</b>
|
||||
<b name="armUpperL" x="-43.95" y="-159.15" kX="-60" kY="-60" cX="1" cY="1" pX="0" pY="0" z="1">
|
||||
<d name="parts-armUpperL"/>
|
||||
<b name="armUpperL" parent="body" x="-43.95" y="-159.15" kX="-60" kY="-60" cX="1" cY="1" pX="0" pY="0" z="1">
|
||||
<d name="parts-armUpperL" pX="41" pY="16"/>
|
||||
</b>
|
||||
<b name="armL" x="-44.05" y="-125.75" kX="-142.73" kY="-142.73" cX="1" cY="1" pX="15" pY="33" z="2">
|
||||
<d name="parts-armL"/>
|
||||
<b name="armL" parent="armUpperL" x="-44.05" y="-125.75" kX="-142.73" kY="-142.73" cX="1" cY="1" pX="15.35" pY="33" z="2">
|
||||
<d name="parts-armL" pX="0" pY="0"/>
|
||||
</b>
|
||||
<b name="handL" x="-60" y="-96.5" kX="-90" kY="-90" cX="1" cY="1" pX="39" pY="28" z="3">
|
||||
<d name="parts-handL"/>
|
||||
<b name="handL" parent="armL" x="-60" y="-96.5" kX="-90" kY="-90" cX="1" cY="1" pX="38.9" pY="28.45" z="3">
|
||||
<d name="parts-handL" pX="0" pY="0"/>
|
||||
</b>
|
||||
<b name="legL" x="-21.05" y="-88.1" kX="-36.21" kY="-36.21" cX="1" cY="1" pX="92" pY="15" z="4">
|
||||
<d name="parts-legL"/>
|
||||
<b name="legL" parent="body" x="-21.05" y="-88.1" kX="-36.21" kY="-36.21" cX="1" cY="1" pX="91.6" pY="14.7" z="4">
|
||||
<d name="parts-legL" pX="0" pY="0"/>
|
||||
</b>
|
||||
<b name="body" x="5.9" y="-126.1" kX="0" kY="0" cX="1" cY="1" pX="59" pY="87" z="5">
|
||||
<d name="parts-body"/>
|
||||
<b name="body" x="5.9" y="-126.1" kX="0" kY="0" cX="1" cY="1" pX="58.65" pY="86.55" z="5">
|
||||
<d name="parts-body" pX="0" pY="0"/>
|
||||
</b>
|
||||
<b name="hair" x="44.4" y="-252.1" kX="0" kY="0" cX="1" cY="1" pX="31" pY="70" z="6">
|
||||
<d name="parts-hair"/>
|
||||
<b name="hair" parent="head" x="44.4" y="-252.1" kX="0" kY="0" cX="1" cY="1" pX="31" pY="70.3" z="6">
|
||||
<d name="parts-hair" pX="0" pY="0"/>
|
||||
</b>
|
||||
<b name="head" x="111.35" y="-50.2" kX="0" kY="0" cX="1" cY="1" pX="115" pY="157" z="7">
|
||||
<d name="parts-head"/>
|
||||
<b name="head" parent="body" x="111.35" y="-50.2" kX="0" kY="0" cX="1" cY="1" pX="115.4" pY="156.9" z="7">
|
||||
<d name="parts-head" pX="79.5" pY="160"/>
|
||||
</b>
|
||||
<b name="eyeL" x="-42.85" y="-281.45" kX="0" kY="0" cX="1" cY="1" pX="7" pY="11" z="8">
|
||||
<d name="parts-eyeL"/>
|
||||
<b name="eyeL" parent="head" x="-42.85" y="-281.45" kX="0" kY="0" cX="1" cY="1" pX="6.85" pY="11.3" z="8">
|
||||
<d name="parts-eyeL" pX="0" pY="0"/>
|
||||
</b>
|
||||
<b name="eyeR" x="4.1" y="-263.6" kX="0" kY="0" cX="1" cY="1" pX="9" pY="14" z="9">
|
||||
<d name="parts-eyeR"/>
|
||||
<b name="eyeR" parent="head" x="4.1" y="-263.6" kX="0" kY="0" cX="1" cY="1" pX="9.1" pY="14.4" z="9">
|
||||
<d name="parts-eyeR" pX="8" pY="15"/>
|
||||
</b>
|
||||
<b name="tail" x="45.9" y="-70.8" kX="30" kY="30" cX="1" cY="1" pX="12" pY="176" z="10">
|
||||
<d name="parts-tail"/>
|
||||
<b name="tail" parent="body" x="45.9" y="-70.8" kX="30" kY="30" cX="1" cY="1" pX="11.5" pY="176.35" z="10">
|
||||
<d name="parts-tail" pX="0" pY="-63.8"/>
|
||||
</b>
|
||||
<b name="legR" x="33.4" y="-80.5" kX="15" kY="15" cX="1" cY="1" pX="45" pY="17" z="11">
|
||||
<d name="parts-legR"/>
|
||||
<b name="legR" parent="body" x="33.4" y="-80.5" kX="15" kY="15" cX="1" cY="1" pX="44.9" pY="16.6" z="11">
|
||||
<d name="parts-legR" pX="0" pY="0"/>
|
||||
</b>
|
||||
<b name="armUpperR" x="18.05" y="-167.6" kX="78.95" kY="78.95" cX="1" cY="1" pX="0" pY="0" z="12">
|
||||
<d name="parts-armUpperR"/>
|
||||
<b name="armUpperR" parent="body" x="18.05" y="-167.6" kX="78.95" kY="78.95" cX="1" cY="1" pX="0" pY="0" z="12">
|
||||
<d name="parts-armUpperR" pX="12" pY="28"/>
|
||||
</b>
|
||||
<b name="armR" x="47.1" y="-104.6" kX="15" kY="15" cX="1" cY="1" pX="12" pY="12" z="13">
|
||||
<d name="parts-armR"/>
|
||||
<b name="armR" parent="armUpperR" x="47.1" y="-104.6" kX="15" kY="15" cX="1" cY="1" pX="12.3" pY="12.3" z="13">
|
||||
<d name="parts-armR" pX="0" pY="0"/>
|
||||
</b>
|
||||
<b name="handR" x="42.7" y="-83.35" kX="30" kY="30" cX="1" cY="1" pX="27" pY="3" z="14">
|
||||
<d name="parts-handR"/>
|
||||
<b name="handR" parent="armR" x="42.7" y="-83.35" kX="30" kY="30" cX="1" cY="1" pX="26.65" pY="2.9" z="14">
|
||||
<d name="parts-handR" pX="0" pY="0"/>
|
||||
</b>
|
||||
<b name="beardL" x="-14" y="-217.35" kX="0" kY="0" cX="1" cY="1" pX="56" pY="5" z="15">
|
||||
<d name="parts-beardL"/>
|
||||
<b name="beardL" parent="head" x="-14" y="-217.35" kX="0" kY="0" cX="1" cY="1" pX="55.95" pY="4.75" z="15">
|
||||
<d name="parts-beardL" pX="54" pY="4"/>
|
||||
</b>
|
||||
<b name="beardR" x="-19.8" y="-221.55" kX="0" kY="0" cX="1" cY="1" pX="3" pY="9" z="16">
|
||||
<d name="parts-beardR"/>
|
||||
<b name="beardR" parent="head" x="-19.8" y="-221.55" kX="0" kY="0" cX="1" cY="1" pX="3.2" pY="8.9" z="16">
|
||||
<d name="parts-beardR" pX="0" pY="0"/>
|
||||
</b>
|
||||
</armature>
|
||||
</armatures>
|
||||
|
@ -58,158 +58,286 @@
|
|||
<animation name="Dragon">
|
||||
<mov name="stand" dr="7" to="6" drTW="30" lp="1" twE="0">
|
||||
<b name="tailTip" sc="1" dl="0">
|
||||
<f x="169.9" y="-106.15" cocos2d_x="196.35" cocos2d_y="-198.4" kX="30" kY="30" cX="1" cY="1" pX="23" pY="93" z="0" dI="0" dr="2"/>
|
||||
<f x="174.9" y="-97.15" cocos2d_x="188.8" cocos2d_y="-192.1" kX="22.31" kY="22.31" cX="1" cY="1" pX="23" pY="93" z="0" dI="0" dr="3"/>
|
||||
<f x="169.9" y="-106.15" cocos2d_x="196.35" cocos2d_y="-198.4" kX="30" kY="30" cX="1" cY="1" pX="23" pY="93" z="0" dI="0" dr="2"/>
|
||||
<f x="169.9" y="-106.15" cocos2d_x="196.35" cocos2d_y="-198.4" kX="30" kY="30" cX="1" cY="1" pX="23.25" pY="93.05" z="0" dI="0" dr="2"/>
|
||||
<f x="174.9" y="-97.15" cocos2d_x="188.8" cocos2d_y="-192.1" kX="22.31" kY="22.31" cX="1" cY="1" pX="23.2" pY="93.1" z="0" dI="0" dr="3"/>
|
||||
<f x="169.9" y="-106.15" cocos2d_x="196.35" cocos2d_y="-198.4" kX="30" kY="30" cX="1" cY="1" pX="23.25" pY="93.05" z="0" dI="0" dr="2"/>
|
||||
</b>
|
||||
<b name="armUpperL" sc="1" dl="0">
|
||||
<f x="-43.95" y="-159.15" cocos2d_x="-43.95" cocos2d_y="-159.15" kX="-60" kY="-60" cX="1" cY="1" pX="0" pY="0" z="1" dI="0" dr="7"/>
|
||||
</b>
|
||||
<b name="armL" sc="1" dl="0">
|
||||
<f x="-44.05" y="-125.75" cocos2d_x="-51.85" cocos2d_y="-90.2" kX="-142.73" kY="-142.73" cX="1" cY="1" pX="15" pY="33" z="2" dI="0" dr="7"/>
|
||||
<f x="-44.05" y="-125.75" cocos2d_x="-51.85" cocos2d_y="-90.2" kX="-142.73" kY="-142.73" cX="1" cY="1" pX="15.35" pY="33" z="2" dI="0" dr="7"/>
|
||||
</b>
|
||||
<b name="handL" sc="1" dl="0">
|
||||
<f x="-60" y="-96.5" cocos2d_x="-88.45" cocos2d_y="-57.6" kX="-90" kY="-90" cX="1" cY="1" pX="39" pY="28" z="3" dI="0" dr="7"/>
|
||||
<f x="-60" y="-96.5" cocos2d_x="-88.45" cocos2d_y="-57.6" kX="-90" kY="-90" cX="1" cY="1" pX="38.9" pY="28.45" z="3" dI="0" dr="7"/>
|
||||
</b>
|
||||
<b name="legL" sc="1" dl="0">
|
||||
<f x="-21.05" y="-88.1" cocos2d_x="-103.7" cocos2d_y="-45.85" kX="-36.21" kY="-36.21" cX="1" cY="1" pX="92" pY="15" z="4" dI="0" dr="7"/>
|
||||
<f x="-21.05" y="-88.1" cocos2d_x="-103.7" cocos2d_y="-45.85" kX="-36.21" kY="-36.21" cX="1" cY="1" pX="91.6" pY="14.7" z="4" dI="0" dr="7"/>
|
||||
</b>
|
||||
<b name="body" sc="1" dl="0">
|
||||
<f x="5.9" y="-126.1" cocos2d_x="-52.75" cocos2d_y="-212.65" kX="0" kY="0" cX="1" cY="1" pX="59" pY="87" z="5" dI="0" dr="2"/>
|
||||
<f x="5.9" y="-126.1" cocos2d_x="-52.75" cocos2d_y="-212.65" kX="0" kY="0" cX="1" cY="1" pX="59" pY="87" z="5" dI="0" dr="3"/>
|
||||
<f x="5.9" y="-126.1" cocos2d_x="-52.75" cocos2d_y="-212.65" kX="0" kY="0" cX="1" cY="1" pX="59" pY="87" z="5" dI="0" dr="2"/>
|
||||
<f x="5.9" y="-126.1" cocos2d_x="-52.75" cocos2d_y="-212.65" kX="0" kY="0" cX="1" cY="1" pX="58.65" pY="86.55" z="5" dI="0" dr="2"/>
|
||||
<f x="5.9" y="-126.1" cocos2d_x="-52.75" cocos2d_y="-212.65" kX="0" kY="0" cX="1" cY="1" pX="58.65" pY="86.55" z="5" dI="0" dr="3"/>
|
||||
<f x="5.9" y="-126.1" cocos2d_x="-52.75" cocos2d_y="-212.65" kX="0" kY="0" cX="1" cY="1" pX="58.65" pY="86.55" z="5" dI="0" dr="2"/>
|
||||
</b>
|
||||
<b name="hair" sc="1" dl="0">
|
||||
<f x="44.4" y="-252.1" cocos2d_x="13.4" cocos2d_y="-322.4" kX="0" kY="0" cX="1" cY="1" pX="31" pY="70" z="6" dI="0" dr="3"/>
|
||||
<f x="45.4" y="-254.1" cocos2d_x="14.4" cocos2d_y="-324.4" kX="0" kY="0" cX="1" cY="1" pX="31" pY="70" z="6" dI="0" dr="2"/>
|
||||
<f x="44.4" y="-252.1" cocos2d_x="13.4" cocos2d_y="-322.4" kX="0" kY="0" cX="1" cY="1" pX="31" pY="70" z="6" dI="0" dr="2"/>
|
||||
<f x="44.4" y="-252.1" cocos2d_x="13.4" cocos2d_y="-322.4" kX="0" kY="0" cX="1" cY="1" pX="31" pY="70.3" z="6" dI="0" dr="3"/>
|
||||
<f x="45.4" y="-254.1" cocos2d_x="14.4" cocos2d_y="-324.4" kX="0" kY="0" cX="1" cY="1" pX="31" pY="70.3" z="6" dI="0" dr="2"/>
|
||||
<f x="44.4" y="-252.1" cocos2d_x="13.4" cocos2d_y="-322.4" kX="0" kY="0" cX="1" cY="1" pX="31" pY="70.3" z="6" dI="0" dr="2"/>
|
||||
</b>
|
||||
<b name="head" sc="1" dl="0">
|
||||
<f x="111.35" y="-50.2" cocos2d_x="-4.05" cocos2d_y="-207.1" kX="0" kY="0" cX="1" cY="1" pX="115" pY="157" z="7" dI="0" dr="7"/>
|
||||
<f x="111.35" y="-50.2" cocos2d_x="-4.05" cocos2d_y="-207.1" kX="0" kY="0" cX="1" cY="1" pX="115.4" pY="156.9" z="7" dI="0" dr="7"/>
|
||||
</b>
|
||||
<b name="eyeL" sc="1" dl="0">
|
||||
<f x="-42.85" y="-281.45" cocos2d_x="-49.7" cocos2d_y="-292.75" kX="0" kY="0" cX="1" cY="1" pX="7" pY="11" z="8" dI="0" dr="2"/>
|
||||
<f x="-42.85" y="-283.45" cocos2d_x="-49.7" cocos2d_y="-294.75" kX="0" kY="0" cX="1" cY="1" pX="7" pY="11" z="8" dI="0" dr="3"/>
|
||||
<f x="-42.85" y="-281.45" cocos2d_x="-49.7" cocos2d_y="-292.75" kX="0" kY="0" cX="1" cY="1" pX="7" pY="11" z="8" dI="0" dr="2"/>
|
||||
<f x="-42.85" y="-281.45" cocos2d_x="-49.7" cocos2d_y="-292.75" kX="0" kY="0" cX="1" cY="1" pX="6.85" pY="11.3" z="8" dI="0" dr="2"/>
|
||||
<f x="-42.85" y="-283.45" cocos2d_x="-49.7" cocos2d_y="-294.75" kX="0" kY="0" cX="1" cY="1" pX="6.85" pY="11.3" z="8" dI="0" dr="3"/>
|
||||
<f x="-42.85" y="-281.45" cocos2d_x="-49.7" cocos2d_y="-292.75" kX="0" kY="0" cX="1" cY="1" pX="6.85" pY="11.3" z="8" dI="0" dr="2"/>
|
||||
</b>
|
||||
<b name="eyeR" sc="1" dl="0">
|
||||
<f x="4.1" y="-263.6" cocos2d_x="-5" cocos2d_y="-278" kX="0" kY="0" cX="1" cY="1" pX="9" pY="14" z="9" dI="0" dr="2"/>
|
||||
<f x="4.1" y="-264.6" cocos2d_x="-5" cocos2d_y="-279" kX="0" kY="0" cX="1" cY="1" pX="9" pY="14" z="9" dI="0" dr="3"/>
|
||||
<f x="4.1" y="-263.6" cocos2d_x="-5" cocos2d_y="-278" kX="0" kY="0" cX="1" cY="1" pX="9" pY="14" z="9" dI="0" dr="2"/>
|
||||
<f x="4.1" y="-263.6" cocos2d_x="-5" cocos2d_y="-278" kX="0" kY="0" cX="1" cY="1" pX="9.1" pY="14.4" z="9" dI="0" dr="2"/>
|
||||
<f x="4.1" y="-264.6" cocos2d_x="-5" cocos2d_y="-279" kX="0" kY="0" cX="1" cY="1" pX="9.1" pY="14.4" z="9" dI="0" dr="3"/>
|
||||
<f x="4.1" y="-263.6" cocos2d_x="-5" cocos2d_y="-278" kX="0" kY="0" cX="1" cY="1" pX="9.1" pY="14.4" z="9" dI="0" dr="2"/>
|
||||
</b>
|
||||
<b name="tail" sc="1" dl="0">
|
||||
<f x="45.9" y="-70.8" cocos2d_x="124.1" cocos2d_y="-229.25" kX="30" kY="30" cX="1" cY="1" pX="12" pY="176" z="10" dI="0" dr="2"/>
|
||||
<f x="43.9" y="-70.8" cocos2d_x="135.5" cocos2d_y="-221.95" kX="34.95" kY="34.95" cX="1" cY="1" pX="12" pY="176" z="10" dI="0" dr="3"/>
|
||||
<f x="45.9" y="-70.8" cocos2d_x="124.1" cocos2d_y="-229.25" kX="30" kY="30" cX="1" cY="1" pX="12" pY="176" z="10" dI="0" dr="2"/>
|
||||
<f x="45.9" y="-70.8" cocos2d_x="124.1" cocos2d_y="-229.25" kX="30" kY="30" cX="1" cY="1" pX="11.5" pY="176.35" z="10" dI="0" dr="2"/>
|
||||
<f x="43.9" y="-70.8" cocos2d_x="135.5" cocos2d_y="-221.95" kX="34.95" kY="34.95" cX="1" cY="1" pX="11.55" pY="176.35" z="10" dI="0" dr="3"/>
|
||||
<f x="45.9" y="-70.8" cocos2d_x="124.1" cocos2d_y="-229.25" kX="30" kY="30" cX="1" cY="1" pX="11.5" pY="176.35" z="10" dI="0" dr="2"/>
|
||||
</b>
|
||||
<b name="legR" sc="1" dl="0">
|
||||
<f x="33.4" y="-80.5" cocos2d_x="-5.7" cocos2d_y="-108.2" kX="15" kY="15" cX="1" cY="1" pX="45" pY="17" z="11" dI="0" dr="7"/>
|
||||
<f x="33.4" y="-80.5" cocos2d_x="-5.7" cocos2d_y="-108.2" kX="15" kY="15" cX="1" cY="1" pX="44.9" pY="16.6" z="11" dI="0" dr="7"/>
|
||||
</b>
|
||||
<b name="armUpperR" sc="1" dl="0">
|
||||
<f x="18.05" y="-167.6" cocos2d_x="18.05" cocos2d_y="-167.6" kX="78.95" kY="78.95" cX="1" cY="1" pX="0" pY="0" z="12" dI="0" dr="7"/>
|
||||
</b>
|
||||
<b name="armR" sc="1" dl="0">
|
||||
<f x="47.1" y="-104.6" cocos2d_x="38.45" cocos2d_y="-119.7" kX="15" kY="15" cX="1" cY="1" pX="12" pY="12" z="13" dI="0" dr="7"/>
|
||||
<f x="47.1" y="-104.6" cocos2d_x="38.45" cocos2d_y="-119.7" kX="15" kY="15" cX="1" cY="1" pX="12.3" pY="12.3" z="13" dI="0" dr="7"/>
|
||||
</b>
|
||||
<b name="handR" sc="1" dl="0">
|
||||
<f x="42.7" y="-83.35" cocos2d_x="21.15" cocos2d_y="-99.2" kX="30" kY="30" cX="1" cY="1" pX="27" pY="3" z="14" dI="0" dr="7"/>
|
||||
<f x="42.7" y="-83.35" cocos2d_x="21.15" cocos2d_y="-99.2" kX="30" kY="30" cX="1" cY="1" pX="26.65" pY="2.9" z="14" dI="0" dr="7"/>
|
||||
</b>
|
||||
<b name="beardL" sc="2" dl="0.3">
|
||||
<f x="-14" y="-217.35" cocos2d_x="-69.95" cocos2d_y="-222.1" kX="0" kY="0" cX="1" cY="1" pX="56" pY="5" z="15" dI="0" dr="2"/>
|
||||
<f x="-14" y="-217.35" cocos2d_x="-69.95" cocos2d_y="-222.1" kX="0" kY="0" cX="1" cY="1" pX="55.95" pY="4.75" z="15" dI="0" dr="2"/>
|
||||
<f x="-70.1" y="-221.8" cocos2d_x="-70.1" cocos2d_y="-221.8" kX="-6.47" kY="-6.47" cX="1" cY="1" pX="0" pY="0" z="15" dI="0" dr="3"/>
|
||||
<f x="-14" y="-217.35" cocos2d_x="-69.95" cocos2d_y="-222.1" kX="0" kY="0" cX="1" cY="1" pX="56" pY="5" z="15" dI="0" dr="2"/>
|
||||
<f x="-14" y="-217.35" cocos2d_x="-69.95" cocos2d_y="-222.1" kX="0" kY="0" cX="1" cY="1" pX="55.95" pY="4.75" z="15" dI="0" dr="2"/>
|
||||
</b>
|
||||
<b name="beardR" sc="2" dl="0.3">
|
||||
<f x="-19.8" y="-221.55" cocos2d_x="-23" cocos2d_y="-230.45" kX="0" kY="0" cX="1" cY="1" pX="3" pY="9" z="16" dI="0" dr="2"/>
|
||||
<f x="-19.8" y="-221.55" cocos2d_x="-22.15" cocos2d_y="-230.75" kX="5.44" kY="5.44" cX="1" cY="1" pX="3" pY="9" z="16" dI="0" dr="3"/>
|
||||
<f x="-19.8" y="-221.55" cocos2d_x="-23" cocos2d_y="-230.45" kX="0" kY="0" cX="1" cY="1" pX="3" pY="9" z="16" dI="0" dr="2"/>
|
||||
<f x="-19.8" y="-221.55" cocos2d_x="-23" cocos2d_y="-230.45" kX="0" kY="0" cX="1" cY="1" pX="3.2" pY="8.9" z="16" dI="0" dr="2"/>
|
||||
<f x="-19.8" y="-221.55" cocos2d_x="-22.15" cocos2d_y="-230.75" kX="5.44" kY="5.44" cX="1" cY="1" pX="3.2" pY="8.95" z="16" dI="0" dr="3"/>
|
||||
<f x="-19.8" y="-221.55" cocos2d_x="-23" cocos2d_y="-230.45" kX="0" kY="0" cX="1" cY="1" pX="3.2" pY="8.9" z="16" dI="0" dr="2"/>
|
||||
</b>
|
||||
</mov>
|
||||
<mov name="walk" dr="8" to="5" drTW="20" lp="1" twE="0">
|
||||
<mov name="walk" dr="9" to="5" drTW="21" lp="1" twE="0">
|
||||
<b name="tailTip" sc="1.5" dl="0">
|
||||
<f x="169.9" y="-106.15" cocos2d_x="196.35" cocos2d_y="-198.4" kX="30" kY="30" cX="1" cY="1" pX="23" pY="93" z="0" dI="0" dr="4"/>
|
||||
<f x="153.9" y="-124.35" cocos2d_x="194.85" cocos2d_y="-211.2" kX="39.23" kY="39.23" cX="1" cY="1" pX="23" pY="93" z="0" dI="0" dr="3"/>
|
||||
<f x="169.9" y="-106.15" cocos2d_x="196.35" cocos2d_y="-198.4" kX="30" kY="30" cX="1" cY="1" pX="23" pY="93" z="0" dI="0" dr="1"/>
|
||||
<f x="169.9" y="-106.15" cocos2d_x="196.35" cocos2d_y="-198.4" kX="30" kY="30" cX="1" cY="1" pX="23.25" pY="93.05" z="0" dI="0" dr="4"/>
|
||||
<f x="153.9" y="-124.35" cocos2d_x="194.85" cocos2d_y="-211.2" kX="39.23" kY="39.23" cX="1" cY="1" pX="23.15" pY="93.15" z="0" dI="0" dr="4"/>
|
||||
<f x="169.9" y="-106.15" cocos2d_x="196.35" cocos2d_y="-198.4" kX="30" kY="30" cX="1" cY="1" pX="23.25" pY="93.05" z="0" dI="0" dr="1"/>
|
||||
</b>
|
||||
<b name="armUpperL" sc="1" dl="0">
|
||||
<f x="-43.95" y="-159.15" cocos2d_x="-43.95" cocos2d_y="-159.15" kX="-81.2" kY="-81.2" cX="1" cY="1" pX="0" pY="0" z="1" dI="0" dr="4"/>
|
||||
<f x="-43.95" y="-159.15" cocos2d_x="-43.95" cocos2d_y="-159.15" kX="-30" kY="-30" cX="1" cY="1" pX="0" pY="0" z="1" dI="0" dr="3"/>
|
||||
<f x="-43.95" y="-159.15" cocos2d_x="-43.95" cocos2d_y="-159.15" kX="-30" kY="-30" cX="1" cY="1" pX="0" pY="0" z="1" dI="0" dr="4"/>
|
||||
<f x="-43.95" y="-159.15" cocos2d_x="-43.95" cocos2d_y="-159.15" kX="-81.2" kY="-81.2" cX="1" cY="1" pX="0" pY="0" z="1" dI="0" dr="1"/>
|
||||
</b>
|
||||
<b name="armL" sc="1" dl="0">
|
||||
<f x="-34.05" y="-121.7" cocos2d_x="-7.2" cocos2d_y="-97.2" kX="157.27" kY="157.27" cX="1" cY="1" pX="15" pY="33" z="2" dI="0" dr="4"/>
|
||||
<f x="-64.05" y="-126.75" cocos2d_x="-99.85" cocos2d_y="-121" kX="-74.18" kY="-74.18" cX="1" cY="1" pX="15" pY="33" z="2" dI="0" dr="3"/>
|
||||
<f x="-34.05" y="-121.7" cocos2d_x="-7.2" cocos2d_y="-97.2" kX="157.27" kY="157.27" cX="1" cY="1" pX="15" pY="33" z="2" dI="0" dr="1"/>
|
||||
<f x="-34.05" y="-121.7" cocos2d_x="-7.2" cocos2d_y="-97.2" kX="157.27" kY="157.27" cX="1" cY="1" pX="15.25" pY="32.95" z="2" dI="0" dr="4"/>
|
||||
<f x="-64.05" y="-126.75" cocos2d_x="-99.85" cocos2d_y="-121" kX="-74.18" kY="-74.18" cX="1" cY="1" pX="15.35" pY="32.9" z="2" dI="0" dr="4"/>
|
||||
<f x="-34.05" y="-121.7" cocos2d_x="-7.2" cocos2d_y="-97.2" kX="157.27" kY="157.27" cX="1" cY="1" pX="15.25" pY="32.95" z="2" dI="0" dr="1"/>
|
||||
</b>
|
||||
<b name="handL" sc="1" dl="0">
|
||||
<f x="-16.1" y="-94" cocos2d_x="-8.75" cocos2d_y="-46.35" kX="-135" kY="-135" cX="1" cY="1" pX="39" pY="28" z="3" dI="0" dr="4"/>
|
||||
<f x="-95.85" y="-129.1" cocos2d_x="-140.8" cocos2d_y="-146.55" kX="-15" kY="-15" cX="1" cY="1" pX="39" pY="29" z="3" dI="0" dr="3"/>
|
||||
<f x="-16.1" y="-94" cocos2d_x="-8.75" cocos2d_y="-46.35" kX="-135" kY="-135" cX="1" cY="1" pX="39" pY="28" z="3" dI="0" dr="1"/>
|
||||
<f x="-16.1" y="-94" cocos2d_x="-8.75" cocos2d_y="-46.35" kX="-135" kY="-135" cX="1" cY="1" pX="38.85" pY="28.45" z="3" dI="0" dr="4"/>
|
||||
<f x="-95.85" y="-129.1" cocos2d_x="-140.8" cocos2d_y="-146.55" kX="-15" kY="-15" cX="1" cY="1" pX="38.85" pY="28.5" z="3" dI="0" dr="4"/>
|
||||
<f x="-16.1" y="-94" cocos2d_x="-8.75" cocos2d_y="-46.35" kX="-135" kY="-135" cX="1" cY="1" pX="38.85" pY="28.45" z="3" dI="0" dr="1"/>
|
||||
</b>
|
||||
<b name="legL" sc="1" dl="0">
|
||||
<f x="-9" y="-73.1" cocos2d_x="-94.7" cocos2d_y="-108.7" kX="13.46" kY="13.46" cX="1" cY="1" pX="92" pY="15" z="4" dI="0" dr="4"/>
|
||||
<f x="-3.95" y="-91.1" cocos2d_x="-68.1" cocos2d_y="-24" kX="-55.44" kY="-55.44" cX="1" cY="1" pX="92" pY="15" z="4" dI="0" dr="3"/>
|
||||
<f x="-9" y="-73.1" cocos2d_x="-94.7" cocos2d_y="-108.7" kX="13.46" kY="13.46" cX="1" cY="1" pX="92" pY="15" z="4" dI="0" dr="1"/>
|
||||
<f x="-9" y="-73.1" cocos2d_x="-94.7" cocos2d_y="-108.7" kX="13.46" kY="13.46" cX="1" cY="1" pX="91.65" pY="14.65" z="4" dI="0" dr="4"/>
|
||||
<f x="-3.95" y="-91.1" cocos2d_x="-68.1" cocos2d_y="-24" kX="-55.44" kY="-55.44" cX="1" cY="1" pX="91.7" pY="14.75" z="4" dI="0" dr="4"/>
|
||||
<f x="-9" y="-73.1" cocos2d_x="-94.7" cocos2d_y="-108.7" kX="13.46" kY="13.46" cX="1" cY="1" pX="91.65" pY="14.65" z="4" dI="0" dr="1"/>
|
||||
</b>
|
||||
<b name="body" sc="1" dl="0">
|
||||
<f x="5.9" y="-128.1" cocos2d_x="-52.75" cocos2d_y="-214.65" kX="0" kY="0" cX="1" cY="1" pX="59" pY="87" z="5" dI="0" dr="4"/>
|
||||
<f x="5.9" y="-127.1" cocos2d_x="-52.75" cocos2d_y="-213.65" kX="0" kY="0" cX="1" cY="1" pX="59" pY="87" z="5" dI="0" dr="3"/>
|
||||
<f x="5.9" y="-128.1" cocos2d_x="-52.75" cocos2d_y="-214.65" kX="0" kY="0" cX="1" cY="1" pX="59" pY="87" z="5" dI="0" dr="1"/>
|
||||
<f x="5.9" y="-128.1" cocos2d_x="-52.75" cocos2d_y="-214.65" kX="0" kY="0" cX="1" cY="1" pX="58.65" pY="86.55" z="5" dI="0" dr="4"/>
|
||||
<f x="5.9" y="-127.1" cocos2d_x="-52.75" cocos2d_y="-213.65" kX="0" kY="0" cX="1" cY="1" pX="58.65" pY="86.55" z="5" dI="0" dr="4"/>
|
||||
<f x="5.9" y="-128.1" cocos2d_x="-52.75" cocos2d_y="-214.65" kX="0" kY="0" cX="1" cY="1" pX="58.65" pY="86.55" z="5" dI="0" dr="1"/>
|
||||
</b>
|
||||
<b name="hair" sc="1" dl="0">
|
||||
<f x="44.4" y="-252.1" cocos2d_x="13.4" cocos2d_y="-322.4" kX="0" kY="0" cX="1" cY="1" pX="31" pY="70" z="6" dI="0" dr="4"/>
|
||||
<f x="47.4" y="-253.1" cocos2d_x="16.4" cocos2d_y="-323.4" kX="0" kY="0" cX="1" cY="1" pX="31" pY="70" z="6" dI="0" dr="3"/>
|
||||
<f x="44.4" y="-252.1" cocos2d_x="13.4" cocos2d_y="-322.4" kX="0" kY="0" cX="1" cY="1" pX="31" pY="70" z="6" dI="0" dr="1"/>
|
||||
<f x="44.4" y="-252.1" cocos2d_x="13.4" cocos2d_y="-322.4" kX="0" kY="0" cX="1" cY="1" pX="31" pY="70.3" z="6" dI="0" dr="4"/>
|
||||
<f x="47.4" y="-253.1" cocos2d_x="16.4" cocos2d_y="-323.4" kX="0" kY="0" cX="1" cY="1" pX="31" pY="70.3" z="6" dI="0" dr="4"/>
|
||||
<f x="44.4" y="-252.1" cocos2d_x="13.4" cocos2d_y="-322.4" kX="0" kY="0" cX="1" cY="1" pX="31" pY="70.3" z="6" dI="0" dr="1"/>
|
||||
</b>
|
||||
<b name="head" sc="1" dl="0">
|
||||
<f x="111.35" y="-50.2" cocos2d_x="-4.05" cocos2d_y="-207.1" kX="0" kY="0" cX="1" cY="1" pX="115" pY="157" z="7" dI="0" dr="4"/>
|
||||
<f x="-4.05" y="-207.1" cocos2d_x="-4.05" cocos2d_y="-207.1" kX="2.95" kY="2.95" cX="1" cY="1" pX="0" pY="0" z="7" dI="0" dr="3"/>
|
||||
<f x="111.35" y="-50.2" cocos2d_x="-4.05" cocos2d_y="-207.1" kX="0" kY="0" cX="1" cY="1" pX="115" pY="157" z="7" dI="0" dr="1"/>
|
||||
<f x="111.35" y="-50.2" cocos2d_x="-4.05" cocos2d_y="-207.1" kX="0" kY="0" cX="1" cY="1" pX="115.4" pY="156.9" z="7" dI="0" dr="4"/>
|
||||
<f x="-4.05" y="-207.1" cocos2d_x="-4.05" cocos2d_y="-207.1" kX="2.95" kY="2.95" cX="1" cY="1" pX="0" pY="0" z="7" dI="0" dr="4"/>
|
||||
<f x="111.35" y="-50.2" cocos2d_x="-4.05" cocos2d_y="-207.1" kX="0" kY="0" cX="1" cY="1" pX="115.4" pY="156.9" z="7" dI="0" dr="1"/>
|
||||
</b>
|
||||
<b name="eyeL" sc="1" dl="0">
|
||||
<f x="-42.85" y="-281.45" cocos2d_x="-49.7" cocos2d_y="-292.75" kX="0" kY="0" cX="1" cY="1" pX="7" pY="11" z="8" dI="0" dr="4"/>
|
||||
<f x="-42.85" y="-281.45" cocos2d_x="-49.7" cocos2d_y="-292.75" kX="0" kY="0" cX="1" cY="1" pX="7" pY="11" z="8" dI="0" dr="3"/>
|
||||
<f x="-42.85" y="-281.45" cocos2d_x="-49.7" cocos2d_y="-292.75" kX="0" kY="0" cX="1" cY="1" pX="7" pY="11" z="8" dI="0" dr="1"/>
|
||||
<f x="-42.85" y="-281.45" cocos2d_x="-49.7" cocos2d_y="-292.75" kX="0" kY="0" cX="1" cY="1" pX="6.85" pY="11.3" z="8" dI="0" dr="4"/>
|
||||
<f x="-42.85" y="-281.45" cocos2d_x="-49.7" cocos2d_y="-292.75" kX="0" kY="0" cX="1" cY="1" pX="6.85" pY="11.3" z="8" dI="0" dr="4"/>
|
||||
<f x="-42.85" y="-281.45" cocos2d_x="-49.7" cocos2d_y="-292.75" kX="0" kY="0" cX="1" cY="1" pX="6.85" pY="11.3" z="8" dI="0" dr="1"/>
|
||||
</b>
|
||||
<b name="eyeR" sc="1" dl="0">
|
||||
<f x="4.95" y="-263.35" cocos2d_x="-4.15" cocos2d_y="-277.75" kX="0" kY="0" cX="1" cY="1" pX="9" pY="14" z="9" dI="0" dr="4"/>
|
||||
<f x="4.95" y="-263.35" cocos2d_x="-4.15" cocos2d_y="-277.75" kX="0" kY="0" cX="1" cY="1" pX="9" pY="14" z="9" dI="0" dr="3"/>
|
||||
<f x="4.95" y="-263.35" cocos2d_x="-4.15" cocos2d_y="-277.75" kX="0" kY="0" cX="1" cY="1" pX="9" pY="14" z="9" dI="0" dr="1"/>
|
||||
<f x="4.95" y="-263.35" cocos2d_x="-4.15" cocos2d_y="-277.75" kX="0" kY="0" cX="1" cY="1" pX="9.1" pY="14.4" z="9" dI="0" dr="4"/>
|
||||
<f x="4.95" y="-263.35" cocos2d_x="-4.15" cocos2d_y="-277.75" kX="0" kY="0" cX="1" cY="1" pX="9.1" pY="14.4" z="9" dI="0" dr="4"/>
|
||||
<f x="4.95" y="-263.35" cocos2d_x="-4.15" cocos2d_y="-277.75" kX="0" kY="0" cX="1" cY="1" pX="9.1" pY="14.4" z="9" dI="0" dr="1"/>
|
||||
</b>
|
||||
<b name="tail" sc="1.1" dl="0">
|
||||
<f x="41.9" y="-72.8" cocos2d_x="120.1" cocos2d_y="-231.25" kX="30" kY="30" cX="1" cY="1" pX="12" pY="176" z="10" dI="0" dr="4"/>
|
||||
<f x="39.9" y="-74.8" cocos2d_x="93.2" cocos2d_y="-243.3" kX="21.29" kY="21.29" cX="1" cY="1" pX="12" pY="176" z="10" dI="0" dr="3"/>
|
||||
<f x="41.9" y="-72.8" cocos2d_x="120.1" cocos2d_y="-231.25" kX="30" kY="30" cX="1" cY="1" pX="12" pY="176" z="10" dI="0" dr="1"/>
|
||||
<f x="41.9" y="-72.8" cocos2d_x="120.1" cocos2d_y="-231.25" kX="30" kY="30" cX="1" cY="1" pX="11.5" pY="176.3" z="10" dI="0" dr="4"/>
|
||||
<f x="39.9" y="-74.8" cocos2d_x="93.2" cocos2d_y="-243.3" kX="21.29" kY="21.29" cX="1" cY="1" pX="11.55" pY="176.35" z="10" dI="0" dr="4"/>
|
||||
<f x="41.9" y="-72.8" cocos2d_x="120.1" cocos2d_y="-231.25" kX="30" kY="30" cX="1" cY="1" pX="11.5" pY="176.3" z="10" dI="0" dr="1"/>
|
||||
</b>
|
||||
<b name="legR" sc="1" dl="0">
|
||||
<f x="30.4" y="-89.5" cocos2d_x="-17.3" cocos2d_y="-93.95" kX="-15" kY="-15" cX="1" cY="1" pX="45" pY="17" z="11" dI="0" dr="4"/>
|
||||
<f x="31.45" y="-82.5" cocos2d_x="11.45" cocos2d_y="-126" kX="45" kY="45" cX="1" cY="1" pX="45" pY="17" z="11" dI="0" dr="3"/>
|
||||
<f x="30.4" y="-89.5" cocos2d_x="-17.3" cocos2d_y="-93.95" kX="-15" kY="-15" cX="1" cY="1" pX="45" pY="17" z="11" dI="0" dr="1"/>
|
||||
<f x="30.4" y="-89.5" cocos2d_x="-17.3" cocos2d_y="-93.95" kX="-15" kY="-15" cX="1" cY="1" pX="44.9" pY="16.65" z="11" dI="0" dr="4"/>
|
||||
<f x="31.45" y="-82.5" cocos2d_x="11.45" cocos2d_y="-126" kX="45" kY="45" cX="1" cY="1" pX="44.9" pY="16.6" z="11" dI="0" dr="4"/>
|
||||
<f x="30.4" y="-89.5" cocos2d_x="-17.3" cocos2d_y="-93.95" kX="-15" kY="-15" cX="1" cY="1" pX="44.9" pY="16.65" z="11" dI="0" dr="1"/>
|
||||
</b>
|
||||
<b name="armUpperR" sc="1" dl="0">
|
||||
<f x="15.05" y="-162.6" cocos2d_x="15.05" cocos2d_y="-162.6" kX="124.45" kY="124.45" cX="1" cY="1" pX="0" pY="0" z="12" dI="0" dr="4"/>
|
||||
<f x="18.05" y="-167.6" cocos2d_x="18.05" cocos2d_y="-167.6" kX="56.8" kY="56.8" cX="1" cY="1" pX="0" pY="0" z="12" dI="0" dr="3"/>
|
||||
<f x="18.05" y="-167.6" cocos2d_x="18.05" cocos2d_y="-167.6" kX="56.8" kY="56.8" cX="1" cY="1" pX="0" pY="0" z="12" dI="0" dr="4"/>
|
||||
<f x="15.05" y="-162.6" cocos2d_x="15.05" cocos2d_y="-162.6" kX="124.45" kY="124.45" cX="1" cY="1" pX="0" pY="0" z="12" dI="0" dr="1"/>
|
||||
</b>
|
||||
<b name="armR" sc="1" dl="0">
|
||||
<f x="-12.9" y="-101.6" cocos2d_x="-2.3" cocos2d_y="-115.35" kX="82.22" kY="82.22" cX="1" cY="1" pX="12" pY="12" z="13" dI="0" dr="4"/>
|
||||
<f x="67.9" y="-121.4" cocos2d_x="51.85" cocos2d_y="-128.1" kX="-22.78" kY="-22.78" cX="1" cY="1" pX="12" pY="12" z="13" dI="0" dr="3"/>
|
||||
<f x="-12.9" y="-101.6" cocos2d_x="-2.3" cocos2d_y="-115.35" kX="82.22" kY="82.22" cX="1" cY="1" pX="12" pY="12" z="13" dI="0" dr="1"/>
|
||||
<f x="-12.9" y="-101.6" cocos2d_x="-2.3" cocos2d_y="-115.35" kX="82.22" kY="82.22" cX="1" cY="1" pX="12.2" pY="12.35" z="13" dI="0" dr="4"/>
|
||||
<f x="67.9" y="-121.4" cocos2d_x="51.85" cocos2d_y="-128.1" kX="-22.78" kY="-22.78" cX="1" cY="1" pX="12.2" pY="12.35" z="13" dI="0" dr="4"/>
|
||||
<f x="-12.9" y="-101.6" cocos2d_x="-2.3" cocos2d_y="-115.35" kX="82.22" kY="82.22" cX="1" cY="1" pX="12.2" pY="12.35" z="13" dI="0" dr="1"/>
|
||||
</b>
|
||||
<b name="handR" sc="1" dl="0">
|
||||
<f x="-36.3" y="-105.35" cocos2d_x="-50.4" cocos2d_y="-128.1" kX="51.74" kY="51.74" cX="1" cY="1" pX="27" pY="3" z="14" dI="0" dr="4"/>
|
||||
<f x="78.55" y="-101.2" cocos2d_x="51.8" cocos2d_y="-100.4" kX="-8.26" kY="-8.26" cX="1" cY="1" pX="27" pY="3" z="14" dI="0" dr="3"/>
|
||||
<f x="-36.3" y="-105.35" cocos2d_x="-50.4" cocos2d_y="-128.1" kX="51.74" kY="51.74" cX="1" cY="1" pX="27" pY="3" z="14" dI="0" dr="1"/>
|
||||
<f x="-36.3" y="-105.35" cocos2d_x="-50.4" cocos2d_y="-128.1" kX="51.74" kY="51.74" cX="1" cY="1" pX="26.6" pY="3" z="14" dI="0" dr="4"/>
|
||||
<f x="78.55" y="-101.2" cocos2d_x="51.8" cocos2d_y="-100.4" kX="-8.26" kY="-8.26" cX="1" cY="1" pX="26.6" pY="3.05" z="14" dI="0" dr="4"/>
|
||||
<f x="-36.3" y="-105.35" cocos2d_x="-50.4" cocos2d_y="-128.1" kX="51.74" kY="51.74" cX="1" cY="1" pX="26.6" pY="3" z="14" dI="0" dr="1"/>
|
||||
</b>
|
||||
<b name="beardL" sc="1" dl="0">
|
||||
<f x="-14" y="-217.35" cocos2d_x="-69.95" cocos2d_y="-222.1" kX="0" kY="0" cX="1" cY="1" pX="56" pY="5" z="15" dI="0" dr="4"/>
|
||||
<f x="-68.95" y="-225.1" cocos2d_x="-68.95" cocos2d_y="-225.1" kX="8.99" kY="8.99" cX="1" cY="1" pX="0" pY="0" z="15" dI="0" dr="3"/>
|
||||
<f x="-14" y="-217.35" cocos2d_x="-69.95" cocos2d_y="-222.1" kX="0" kY="0" cX="1" cY="1" pX="56" pY="5" z="15" dI="0" dr="1"/>
|
||||
<f x="-14" y="-217.35" cocos2d_x="-69.95" cocos2d_y="-222.1" kX="0" kY="0" cX="1" cY="1" pX="55.95" pY="4.75" z="15" dI="0" dr="4"/>
|
||||
<f x="-68.95" y="-225.1" cocos2d_x="-68.95" cocos2d_y="-225.1" kX="8.99" kY="8.99" cX="1" cY="1" pX="0" pY="0" z="15" dI="0" dr="4"/>
|
||||
<f x="-14" y="-217.35" cocos2d_x="-69.95" cocos2d_y="-222.1" kX="0" kY="0" cX="1" cY="1" pX="55.95" pY="4.75" z="15" dI="0" dr="1"/>
|
||||
</b>
|
||||
<b name="beardR" sc="1" dl="0">
|
||||
<f x="-19.8" y="-221.55" cocos2d_x="-23" cocos2d_y="-230.45" kX="0" kY="0" cX="1" cY="1" pX="3" pY="9" z="16" dI="0" dr="4"/>
|
||||
<f x="-19.8" y="-221.55" cocos2d_x="-24.1" cocos2d_y="-230" kX="-7.5" kY="-7.5" cX="1" cY="1" pX="3" pY="9" z="16" dI="0" dr="3"/>
|
||||
<f x="-19.8" y="-221.55" cocos2d_x="-23" cocos2d_y="-230.45" kX="0" kY="0" cX="1" cY="1" pX="3" pY="9" z="16" dI="0" dr="1"/>
|
||||
<f x="-19.8" y="-221.55" cocos2d_x="-23" cocos2d_y="-230.45" kX="0" kY="0" cX="1" cY="1" pX="3.2" pY="8.9" z="16" dI="0" dr="4"/>
|
||||
<f x="-19.8" y="-221.55" cocos2d_x="-24.1" cocos2d_y="-230" kX="-7.5" kY="-7.5" cX="1" cY="1" pX="3.1" pY="8.95" z="16" dI="0" dr="4"/>
|
||||
<f x="-19.8" y="-221.55" cocos2d_x="-23" cocos2d_y="-230.45" kX="0" kY="0" cX="1" cY="1" pX="3.2" pY="8.9" z="16" dI="0" dr="1"/>
|
||||
</b>
|
||||
</mov>
|
||||
<mov name="jump" dr="5" to="3" drTW="5" lp="1" twE="NaN">
|
||||
<b name="tailTip" sc="1" dl="0">
|
||||
<f x="156.9" y="-75.35" cocos2d_x="229" cocos2d_y="-138.75" kX="62.68" kY="62.68" cX="1" cY="1" pX="23.2" pY="93.15" z="0" dI="0" dr="2"/>
|
||||
<f x="157.85" y="-71.35" cocos2d_x="239.05" cocos2d_y="-122.7" kX="71.67" kY="71.67" cX="1" cY="1" pX="23.15" pY="93.2" z="0" dI="0" dr="3"/>
|
||||
</b>
|
||||
<b name="armUpperL" sc="1" dl="0">
|
||||
<f x="-43.95" y="-190.15" cocos2d_x="-43.95" cocos2d_y="-190.15" kX="-45" kY="-45" cX="1" cY="1" pX="0" pY="0" z="1" dI="0" dr="2"/>
|
||||
<f x="-43.95" y="-189.15" cocos2d_x="-43.95" cocos2d_y="-189.15" kX="-45" kY="-45" cX="1" cY="1" pX="0" pY="0" z="1" dI="0" dr="3"/>
|
||||
</b>
|
||||
<b name="armL" sc="1" dl="0">
|
||||
<f x="-52" y="-156.8" cocos2d_x="-73.25" cocos2d_y="-127.35" kX="-119.18" kY="-119.18" cX="1" cY="1" pX="15.35" pY="32.9" z="2" dI="0" dr="5"/>
|
||||
</b>
|
||||
<b name="handL" sc="1" dl="0">
|
||||
<f x="-73.9" y="-137.75" cocos2d_x="-111.45" cocos2d_y="-107.55" kX="-75" kY="-75" cX="1" cY="1" pX="38.85" pY="28.45" z="3" dI="0" dr="5"/>
|
||||
</b>
|
||||
<b name="legL" sc="1" dl="0">
|
||||
<f x="12.25" y="-118.05" cocos2d_x="-62.45" cocos2d_y="-63.05" kX="-45.47" kY="-45.47" cX="1" cY="1" pX="91.6" pY="14.7" z="4" dI="0" dr="2"/>
|
||||
<f x="12.25" y="-117.05" cocos2d_x="-62.45" cocos2d_y="-62.05" kX="-45.47" kY="-45.47" cX="1" cY="1" pX="91.6" pY="14.7" z="4" dI="0" dr="3"/>
|
||||
</b>
|
||||
<b name="body" sc="1" dl="0">
|
||||
<f x="5.9" y="-159.1" cocos2d_x="-52.75" cocos2d_y="-245.65" kX="0" kY="0" cX="1" cY="1" pX="58.65" pY="86.55" z="5" dI="0" dr="5"/>
|
||||
</b>
|
||||
<b name="hair" sc="1" dl="0">
|
||||
<f x="53.4" y="-278.1" cocos2d_x="22.4" cocos2d_y="-348.4" kX="0" kY="0" cX="1" cY="1" pX="31" pY="70.3" z="6" dI="0" dr="2"/>
|
||||
<f x="55.4" y="-276.1" cocos2d_x="24.4" cocos2d_y="-346.4" kX="0" kY="0" cX="1" cY="1" pX="31" pY="70.3" z="6" dI="0" dr="3"/>
|
||||
</b>
|
||||
<b name="head" sc="1" dl="0">
|
||||
<f x="-2.25" y="-239.15" cocos2d_x="-2.25" cocos2d_y="-239.15" kX="10" kY="10" cX="1" cY="1" pX="0" pY="0" z="7" dI="0" dr="5"/>
|
||||
</b>
|
||||
<b name="eyeL" sc="1" dl="0">
|
||||
<f x="-32.85" y="-325.45" cocos2d_x="-39.7" cocos2d_y="-336.75" kX="0" kY="0" cX="1" cY="1" pX="6.85" pY="11.3" z="8" dI="0" dr="2"/>
|
||||
<f x="-32.35" y="-325.95" cocos2d_x="-39.2" cocos2d_y="-337.25" kX="0" kY="0" cX="1" cY="1" pX="6.85" pY="11.3" z="8" dI="0" dr="3"/>
|
||||
</b>
|
||||
<b name="eyeR" sc="1" dl="0">
|
||||
<f x="14.95" y="-300.35" cocos2d_x="5.85" cocos2d_y="-314.75" kX="0" kY="0" cX="1" cY="1" pX="9.1" pY="14.4" z="9" dI="0" dr="2"/>
|
||||
<f x="15.95" y="-301.35" cocos2d_x="6.85" cocos2d_y="-315.75" kX="0" kY="0" cX="1" cY="1" pX="9.1" pY="14.4" z="9" dI="0" dr="3"/>
|
||||
</b>
|
||||
<b name="tail" sc="1" dl="0">
|
||||
<f x="33.9" y="-108.8" cocos2d_x="180.6" cocos2d_y="-207.5" kX="59.79" kY="59.79" cX="1" cY="1" pX="11.5" pY="176.45" z="10" dI="0" dr="2"/>
|
||||
<f x="33.9" y="-108.8" cocos2d_x="185.5" cocos2d_y="-199.8" kX="62.76" kY="62.76" cX="1" cY="1" pX="11.5" pY="176.45" z="10" dI="0" dr="3"/>
|
||||
</b>
|
||||
<b name="legR" sc="1" dl="0">
|
||||
<f x="41.45" y="-107.5" cocos2d_x="-6" cocos2d_y="-113.8" kX="-12.69" kY="-12.69" cX="1" cY="1" pX="44.9" pY="16.55" z="11" dI="0" dr="2"/>
|
||||
<f x="41.45" y="-106.5" cocos2d_x="-6" cocos2d_y="-112.8" kX="-12.69" kY="-12.69" cX="1" cY="1" pX="44.9" pY="16.55" z="11" dI="0" dr="3"/>
|
||||
</b>
|
||||
<b name="armUpperR" sc="1" dl="0">
|
||||
<f x="18.05" y="-195.6" cocos2d_x="18.05" cocos2d_y="-195.6" kX="54.3" kY="54.3" cX="1" cY="1" pX="0" pY="0" z="12" dI="0" dr="2"/>
|
||||
<f x="18.05" y="-194.6" cocos2d_x="18.05" cocos2d_y="-194.6" kX="54.3" kY="54.3" cX="1" cY="1" pX="0" pY="0" z="12" dI="0" dr="3"/>
|
||||
</b>
|
||||
<b name="armR" sc="1" dl="0">
|
||||
<f x="67.9" y="-153.4" cocos2d_x="51.85" cocos2d_y="-160.1" kX="-22.78" kY="-22.78" cX="1" cY="1" pX="12.2" pY="12.35" z="13" dI="0" dr="5"/>
|
||||
</b>
|
||||
<b name="handR" sc="1" dl="0">
|
||||
<f x="78.55" y="-133.2" cocos2d_x="51.8" cocos2d_y="-132.4" kX="-8.26" kY="-8.26" cX="1" cY="1" pX="26.65" pY="3.1" z="14" dI="0" dr="5"/>
|
||||
</b>
|
||||
<b name="beardL" sc="1" dl="0">
|
||||
<f x="-63.8" y="-263.7" cocos2d_x="-63.8" cocos2d_y="-263.7" kX="-40.29" kY="-40.29" cX="1" cY="1" pX="0" pY="0" z="15" dI="0" dr="2"/>
|
||||
<f x="-63.8" y="-263.7" cocos2d_x="-63.8" cocos2d_y="-263.7" kX="-46.79" kY="-46.79" cX="1" cY="1" pX="0" pY="0" z="15" dI="0" dr="3"/>
|
||||
</b>
|
||||
<b name="beardR" sc="1" dl="0">
|
||||
<f x="-19.85" y="-253.5" cocos2d_x="-14.65" cocos2d_y="-261.45" kX="52.5" kY="52.5" cX="1" cY="1" pX="3.1" pY="8.95" z="16" dI="0" dr="2"/>
|
||||
<f x="-19.8" y="-253.45" cocos2d_x="-13.6" cocos2d_y="-260.65" kX="60.23" kY="60.23" cX="1" cY="1" pX="3.15" pY="8.95" z="16" dI="0" dr="3"/>
|
||||
</b>
|
||||
</mov>
|
||||
<mov name="fall" dr="5" to="6" drTW="5" lp="1" twE="NaN">
|
||||
<b name="tailTip" sc="1" dl="0">
|
||||
<f x="151.85" y="-179.95" cocos2d_x="148" cocos2d_y="-275.95" kX="11.67" kY="11.67" cX="1" cY="1" pX="23.15" pY="93.25" z="0" dI="0" dr="2"/>
|
||||
<f x="145.85" y="-185.85" cocos2d_x="133.75" cocos2d_y="-281.25" kX="6.73" kY="6.73" cX="1" cY="1" pX="23.2" pY="93.3" z="0" dI="0" dr="3"/>
|
||||
</b>
|
||||
<b name="armUpperL" sc="1" dl="0">
|
||||
<f x="-43.95" y="-190.15" cocos2d_x="-43.95" cocos2d_y="-190.15" kX="32.45" kY="32.45" cX="1" cY="1" pX="0" pY="0" z="1" dI="0" dr="2"/>
|
||||
<f x="-43.95" y="-191.15" cocos2d_x="-43.95" cocos2d_y="-191.15" kX="32.45" kY="32.45" cX="1" cY="1" pX="0" pY="0" z="1" dI="0" dr="3"/>
|
||||
</b>
|
||||
<b name="armL" sc="1" dl="0">
|
||||
<f x="-74.55" y="-193" cocos2d_x="-102.7" cocos2d_y="-170.05" kX="-104.18" kY="-104.18" cX="1" cY="1" pX="15.35" pY="32.9" z="2" dI="0" dr="5"/>
|
||||
</b>
|
||||
<b name="handL" sc="1" dl="0">
|
||||
<f x="-104.1" y="-178.5" cocos2d_x="-152" cocos2d_y="-183.65" kX="-30" kY="-30" cX="1" cY="1" pX="38.9" pY="28.4" z="3" dI="0" dr="5"/>
|
||||
</b>
|
||||
<b name="legL" sc="1" dl="0">
|
||||
<f x="-9.75" y="-117.15" cocos2d_x="-94.65" cocos2d_y="-154.3" kX="14.52" kY="14.52" cX="1" cY="1" pX="91.5" pY="14.7" z="4" dI="0" dr="2"/>
|
||||
<f x="-9.75" y="-118.15" cocos2d_x="-94.65" cocos2d_y="-155.3" kX="14.52" kY="14.52" cX="1" cY="1" pX="91.5" pY="14.65" z="4" dI="0" dr="3"/>
|
||||
</b>
|
||||
<b name="body" sc="1" dl="0">
|
||||
<f x="5.9" y="-159.1" cocos2d_x="-52.75" cocos2d_y="-245.65" kX="0" kY="0" cX="1" cY="1" pX="58.65" pY="86.55" z="5" dI="0" dr="5"/>
|
||||
</b>
|
||||
<b name="hair" sc="1" dl="0">
|
||||
<f x="43.35" y="-290.1" cocos2d_x="-4.75" cocos2d_y="-349.95" kX="-15" kY="-15" cX="1" cY="1" pX="30.95" pY="70.3" z="6" dI="0" dr="2"/>
|
||||
<f x="39.4" y="-293.05" cocos2d_x="-9.6" cocos2d_y="-352.25" kX="-15.82" kY="-15.82" cX="1" cY="1" pX="31" pY="70.3" z="6" dI="0" dr="3"/>
|
||||
</b>
|
||||
<b name="head" sc="1" dl="0">
|
||||
<f x="1.45" y="-241.8" cocos2d_x="1.45" cocos2d_y="-241.8" kX="-8.73" kY="-8.73" cX="1" cY="1" pX="0" pY="0" z="7" dI="0" dr="5"/>
|
||||
</b>
|
||||
<b name="eyeL" sc="1" dl="0">
|
||||
<f x="-49.35" y="-301.95" cocos2d_x="-56.2" cocos2d_y="-313.25" kX="0" kY="0" cX="1" cY="1" pX="6.85" pY="11.3" z="8" dI="0" dr="2"/>
|
||||
<f x="-49.35" y="-300.95" cocos2d_x="-56.2" cocos2d_y="-312.25" kX="0" kY="0" cX="1" cY="1" pX="6.85" pY="11.3" z="8" dI="0" dr="3"/>
|
||||
</b>
|
||||
<b name="eyeR" sc="1" dl="0">
|
||||
<f x="-13.15" y="-304.75" cocos2d_x="-13.15" cocos2d_y="-304.75" kX="0" kY="0" cX="1" cY="1" pX="0" pY="0" z="9" dI="0" dr="2"/>
|
||||
<f x="-13.15" y="-303.75" cocos2d_x="-13.15" cocos2d_y="-303.75" kX="0" kY="0" cX="1" cY="1" pX="0" pY="0" z="9" dI="0" dr="3"/>
|
||||
</b>
|
||||
<b name="tail" sc="1" dl="0">
|
||||
<f x="43.95" y="-106.85" cocos2d_x="67.9" cocos2d_y="-281.95" kX="11.53" kY="11.53" cX="1" cY="1" pX="11.5" pY="176.3" z="10" dI="0" dr="2"/>
|
||||
<f x="43.95" y="-106.85" cocos2d_x="55.75" cocos2d_y="-283.15" kX="7.56" kY="7.56" cX="1" cY="1" pX="11.5" pY="176.35" z="10" dI="0" dr="3"/>
|
||||
</b>
|
||||
<b name="legR" sc="1" dl="0">
|
||||
<f x="42.45" y="-108.5" cocos2d_x="20.8" cocos2d_y="-151.15" kX="42.76" kY="42.76" cX="1" cY="1" pX="44.9" pY="16.6" z="11" dI="0" dr="2"/>
|
||||
<f x="42.45" y="-109.5" cocos2d_x="20.8" cocos2d_y="-152.15" kX="42.76" kY="42.76" cX="1" cY="1" pX="44.85" pY="16.6" z="11" dI="0" dr="3"/>
|
||||
</b>
|
||||
<b name="armUpperR" sc="1" dl="0">
|
||||
<f x="18.05" y="-195.6" cocos2d_x="18.05" cocos2d_y="-195.6" kX="9.3" kY="9.3" cX="1" cY="1" pX="0" pY="0" z="12" dI="0" dr="2"/>
|
||||
<f x="18.05" y="-196.6" cocos2d_x="18.05" cocos2d_y="-196.6" kX="9.3" kY="9.3" cX="1" cY="1" pX="0" pY="0" z="12" dI="0" dr="3"/>
|
||||
</b>
|
||||
<b name="armR" sc="1" dl="0">
|
||||
<f x="81.95" y="-203.4" cocos2d_x="65.85" cocos2d_y="-196.8" kX="-67.78" kY="-67.78" cX="1" cY="1" pX="12.2" pY="12.4" z="13" dI="0" dr="5"/>
|
||||
</b>
|
||||
<b name="handR" sc="1" dl="0">
|
||||
<f x="101.1" y="-194.8" cocos2d_x="75.45" cocos2d_y="-187.15" kX="-23.26" kY="-23.26" cX="1" cY="1" pX="26.65" pY="3.1" z="14" dI="0" dr="5"/>
|
||||
</b>
|
||||
<b name="beardL" sc="1" dl="0">
|
||||
<f x="-64.85" y="-246.25" cocos2d_x="-64.85" cocos2d_y="-246.25" kX="-11.27" kY="-11.27" cX="1" cY="1" pX="0" pY="0" z="15" dI="0" dr="2"/>
|
||||
<f x="-64.85" y="-246.25" cocos2d_x="-64.85" cocos2d_y="-246.25" kX="-2.57" kY="-2.57" cX="1" cY="1" pX="0" pY="0" z="15" dI="0" dr="3"/>
|
||||
</b>
|
||||
<b name="beardR" sc="1" dl="0">
|
||||
<f x="-19.8" y="-250.5" cocos2d_x="-22.9" cocos2d_y="-259.4" kX="0.23" kY="0.23" cX="1" cY="1" pX="3.15" pY="8.9" z="16" dI="0" dr="2"/>
|
||||
<f x="-19.8" y="-250.5" cocos2d_x="-25.05" cocos2d_y="-258.25" kX="-14.77" kY="-14.77" cX="1" cY="1" pX="3.05" pY="8.85" z="16" dI="0" dr="3"/>
|
||||
</b>
|
||||
</mov>
|
||||
</animation>
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue