mirror of https://github.com/axmolengine/axmol.git
Merge branch 'develop' into develop_FixTestCase_LabelTest
* develop: [AUTO] : updating submodule reference to latest autogenerated bindings change “string.compare()” to “==“ fix android compile error [AUTO] : updating submodule reference to latest autogenerated bindings fix TestCpp project can't work on debug mode on vs. Updates JS tests for SpineTest. Removes CC prefix for CCSkeleton and CCSkeletonAnimation. Adds namespace `sp` for JSBindings. change some const char* to const std::string& change some const char* to const std::string&
This commit is contained in:
commit
cfb06722d5
|
@ -72,14 +72,14 @@ Component* Component::create(void)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* Component::getName() const
|
const std::string& Component::getName() const
|
||||||
{
|
{
|
||||||
return _name.c_str();
|
return _name;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Component::setName(const char *name)
|
void Component::setName(const std::string& name)
|
||||||
{
|
{
|
||||||
_name.assign(name);
|
_name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
Node* Component::getOwner() const
|
Node* Component::getOwner() const
|
||||||
|
|
|
@ -60,8 +60,8 @@ public:
|
||||||
virtual void setEnabled(bool b);
|
virtual void setEnabled(bool b);
|
||||||
static Component* create(void);
|
static Component* create(void);
|
||||||
|
|
||||||
const char* getName() const;
|
const std::string& getName() const;
|
||||||
void setName(const char *name);
|
void setName(const std::string& name);
|
||||||
|
|
||||||
void setOwner(Node *pOwner);
|
void setOwner(Node *pOwner);
|
||||||
Node* getOwner() const;
|
Node* getOwner() const;
|
||||||
|
|
|
@ -40,12 +40,10 @@ ComponentContainer::~ComponentContainer(void)
|
||||||
CC_SAFE_DELETE(_components);
|
CC_SAFE_DELETE(_components);
|
||||||
}
|
}
|
||||||
|
|
||||||
Component* ComponentContainer::get(const char *name) const
|
Component* ComponentContainer::get(const std::string& name) const
|
||||||
{
|
{
|
||||||
Component* ret = nullptr;
|
Component* ret = nullptr;
|
||||||
CCASSERT(name != nullptr, "Argument must be non-nil");
|
|
||||||
do {
|
do {
|
||||||
CC_BREAK_IF(nullptr == name);
|
|
||||||
CC_BREAK_IF(nullptr == _components);
|
CC_BREAK_IF(nullptr == _components);
|
||||||
ret = _components->at(name);
|
ret = _components->at(name);
|
||||||
|
|
||||||
|
@ -77,10 +75,9 @@ bool ComponentContainer::add(Component *com)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ComponentContainer::remove(const char *name)
|
bool ComponentContainer::remove(const std::string& name)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
CCASSERT(name != nullptr, "Argument must be non-nil");
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
CC_BREAK_IF(!_components);
|
CC_BREAK_IF(!_components);
|
||||||
|
|
|
@ -47,9 +47,9 @@ public:
|
||||||
* @lua NA
|
* @lua NA
|
||||||
*/
|
*/
|
||||||
virtual ~ComponentContainer(void);
|
virtual ~ComponentContainer(void);
|
||||||
virtual Component* get(const char *name) const;
|
virtual Component* get(const std::string& name) const;
|
||||||
virtual bool add(Component *com);
|
virtual bool add(Component *com);
|
||||||
virtual bool remove(const char *name);
|
virtual bool remove(const std::string& name);
|
||||||
virtual void removeAll();
|
virtual void removeAll();
|
||||||
virtual void visit(float delta);
|
virtual void visit(float delta);
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -284,7 +284,7 @@ void Configuration::setValue(const std::string& key, const Value& value)
|
||||||
//
|
//
|
||||||
// load file
|
// load file
|
||||||
//
|
//
|
||||||
void Configuration::loadConfigFile(const char *filename)
|
void Configuration::loadConfigFile(const std::string& filename)
|
||||||
{
|
{
|
||||||
ValueMap dict = FileUtils::getInstance()->getValueMapFromFile(filename);
|
ValueMap dict = FileUtils::getInstance()->getValueMapFromFile(filename);
|
||||||
CCASSERT(!dict.empty(), "cannot create dictionary");
|
CCASSERT(!dict.empty(), "cannot create dictionary");
|
||||||
|
@ -312,14 +312,14 @@ void Configuration::loadConfigFile(const char *filename)
|
||||||
|
|
||||||
if (! validMetadata)
|
if (! validMetadata)
|
||||||
{
|
{
|
||||||
CCLOG("Invalid config format for file: %s", filename);
|
CCLOG("Invalid config format for file: %s", filename.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto dataIter = dict.find("data");
|
auto dataIter = dict.find("data");
|
||||||
if (dataIter == dict.end() || dataIter->second.getType() != Value::Type::MAP)
|
if (dataIter == dict.end() || dataIter->second.getType() != Value::Type::MAP)
|
||||||
{
|
{
|
||||||
CCLOG("Expected 'data' dict, but not found. Config file: %s", filename);
|
CCLOG("Expected 'data' dict, but not found. Config file: %s", filename.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -128,7 +128,7 @@ public:
|
||||||
void gatherGPUInfo();
|
void gatherGPUInfo();
|
||||||
|
|
||||||
/** Loads a config file. If the keys are already present, then they are going to be replaced. Otherwise the new keys are added. */
|
/** Loads a config file. If the keys are already present, then they are going to be replaced. Otherwise the new keys are added. */
|
||||||
void loadConfigFile(const char *filename);
|
void loadConfigFile(const std::string& filename);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Configuration(void);
|
Configuration(void);
|
||||||
|
|
|
@ -30,7 +30,7 @@ NS_CC_BEGIN
|
||||||
|
|
||||||
std::unordered_map<std::string, FontAtlas *> FontAtlasCache::_atlasMap;
|
std::unordered_map<std::string, FontAtlas *> FontAtlasCache::_atlasMap;
|
||||||
|
|
||||||
FontAtlas * FontAtlasCache::getFontAtlasTTF(const char *fontFileName, int size, GlyphCollection glyphs, const char *customGlyphs, bool useDistanceField)
|
FontAtlas * FontAtlasCache::getFontAtlasTTF(const std::string& fontFileName, int size, GlyphCollection glyphs, const char *customGlyphs, bool useDistanceField)
|
||||||
{
|
{
|
||||||
std::string atlasName = generateFontName(fontFileName, size, glyphs, useDistanceField);
|
std::string atlasName = generateFontName(fontFileName, size, glyphs, useDistanceField);
|
||||||
FontAtlas *tempAtlas = _atlasMap[atlasName];
|
FontAtlas *tempAtlas = _atlasMap[atlasName];
|
||||||
|
@ -49,7 +49,7 @@ FontAtlas * FontAtlasCache::getFontAtlasTTF(const char *fontFileName, int size,
|
||||||
return tempAtlas;
|
return tempAtlas;
|
||||||
}
|
}
|
||||||
|
|
||||||
FontAtlas * FontAtlasCache::getFontAtlasFNT(const char *fontFileName)
|
FontAtlas * FontAtlasCache::getFontAtlasFNT(const std::string& fontFileName)
|
||||||
{
|
{
|
||||||
std::string atlasName = generateFontName(fontFileName, 0, GlyphCollection::CUSTOM,false);
|
std::string atlasName = generateFontName(fontFileName, 0, GlyphCollection::CUSTOM,false);
|
||||||
FontAtlas *tempAtlas = _atlasMap[atlasName];
|
FontAtlas *tempAtlas = _atlasMap[atlasName];
|
||||||
|
@ -68,7 +68,7 @@ FontAtlas * FontAtlasCache::getFontAtlasFNT(const char *fontFileName)
|
||||||
return tempAtlas;
|
return tempAtlas;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string FontAtlasCache::generateFontName(const char *fontFileName, int size, GlyphCollection theGlyphs, bool useDistanceField)
|
std::string FontAtlasCache::generateFontName(const std::string& fontFileName, int size, GlyphCollection theGlyphs, bool useDistanceField)
|
||||||
{
|
{
|
||||||
std::string tempName(fontFileName);
|
std::string tempName(fontFileName);
|
||||||
|
|
||||||
|
|
|
@ -38,14 +38,14 @@ class CC_DLL FontAtlasCache
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static FontAtlas * getFontAtlasTTF(const char *fontFileName, int size, GlyphCollection glyphs, const char *customGlyphs = 0, bool useDistanceField = false);
|
static FontAtlas * getFontAtlasTTF(const std::string& fontFileName, int size, GlyphCollection glyphs, const char *customGlyphs = 0, bool useDistanceField = false);
|
||||||
static FontAtlas * getFontAtlasFNT(const char *fontFileName);
|
static FontAtlas * getFontAtlasFNT(const std::string& fontFileName);
|
||||||
|
|
||||||
static bool releaseFontAtlas(FontAtlas *atlas);
|
static bool releaseFontAtlas(FontAtlas *atlas);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
static std::string generateFontName(const char *fontFileName, int size, GlyphCollection theGlyphs, bool useDistanceField);
|
static std::string generateFontName(const std::string& fontFileName, int size, GlyphCollection theGlyphs, bool useDistanceField);
|
||||||
static std::unordered_map<std::string, FontAtlas *> _atlasMap;
|
static std::unordered_map<std::string, FontAtlas *> _atlasMap;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
|
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
|
||||||
FontAtlas * FontAtlasFactory::createAtlasFromTTF(const char* fntFilePath, int fontSize, GlyphCollection glyphs, const char *customGlyphs, bool useDistanceField)
|
FontAtlas * FontAtlasFactory::createAtlasFromTTF(const std::string& fntFilePath, int fontSize, GlyphCollection glyphs, const char *customGlyphs, bool useDistanceField)
|
||||||
{
|
{
|
||||||
|
|
||||||
Font *font = Font::createWithTTF(fntFilePath, fontSize, glyphs, customGlyphs);
|
Font *font = Font::createWithTTF(fntFilePath, fontSize, glyphs, customGlyphs);
|
||||||
|
@ -45,7 +45,7 @@ FontAtlas * FontAtlasFactory::createAtlasFromTTF(const char* fntFilePath, int fo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FontAtlas * FontAtlasFactory::createAtlasFromFNT(const char* fntFilePath)
|
FontAtlas * FontAtlasFactory::createAtlasFromFNT(const std::string& fntFilePath)
|
||||||
{
|
{
|
||||||
Font *font = Font::createWithFNT(fntFilePath);
|
Font *font = Font::createWithFNT(fntFilePath);
|
||||||
|
|
||||||
|
|
|
@ -36,8 +36,8 @@ class CC_DLL FontAtlasFactory
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static FontAtlas * createAtlasFromTTF(const char* fntFilePath, int fontSize, GlyphCollection glyphs, const char *customGlyphs = 0, bool useDistanceField = false);
|
static FontAtlas * createAtlasFromTTF(const std::string& fntFilePath, int fontSize, GlyphCollection glyphs, const char *customGlyphs = 0, bool useDistanceField = false);
|
||||||
static FontAtlas * createAtlasFromFNT(const char* fntFilePath);
|
static FontAtlas * createAtlasFromFNT(const std::string& fntFilePath);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
|
|
@ -25,9 +25,11 @@ THE SOFTWARE.
|
||||||
#ifndef __CC_IME_DELEGATE_H__
|
#ifndef __CC_IME_DELEGATE_H__
|
||||||
#define __CC_IME_DELEGATE_H__
|
#define __CC_IME_DELEGATE_H__
|
||||||
|
|
||||||
|
#include <string>
|
||||||
#include "CCGeometry.h"
|
#include "CCGeometry.h"
|
||||||
|
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
extern const std::string STD_STRING_EMPTY;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @addtogroup input
|
* @addtogroup input
|
||||||
|
@ -114,7 +116,7 @@ protected:
|
||||||
* @js NA
|
* @js NA
|
||||||
* @lua NA
|
* @lua NA
|
||||||
*/
|
*/
|
||||||
virtual const char * getContentText() { return 0; }
|
virtual const std::string& getContentText() { return STD_STRING_EMPTY; }
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
// keyboard show/hide notification
|
// keyboard show/hide notification
|
||||||
|
|
|
@ -239,14 +239,13 @@ void IMEDispatcher::dispatchDeleteBackward()
|
||||||
} while (0);
|
} while (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char * IMEDispatcher::getContentText()
|
const std::string& IMEDispatcher::getContentText()
|
||||||
{
|
{
|
||||||
const char * contentText = 0;
|
|
||||||
if (_impl && _impl->_delegateWithIme)
|
if (_impl && _impl->_delegateWithIme)
|
||||||
{
|
{
|
||||||
contentText = _impl->_delegateWithIme->getContentText();
|
return _impl->_delegateWithIme->getContentText();
|
||||||
}
|
}
|
||||||
return (contentText) ? contentText : "";
|
return STD_STRING_EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -77,7 +77,7 @@ public:
|
||||||
* @js NA
|
* @js NA
|
||||||
* @lua NA
|
* @lua NA
|
||||||
*/
|
*/
|
||||||
const char * getContentText();
|
const std::string& getContentText();
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
// dispatch keyboard notification
|
// dispatch keyboard notification
|
||||||
|
|
|
@ -320,7 +320,7 @@ MenuItemAtlasFont * MenuItemAtlasFont::create(const std::string& value, const st
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX: deprecated
|
// XXX: deprecated
|
||||||
MenuItemAtlasFont * MenuItemAtlasFont::create(const char* value, const char* charMapFile, int itemWidth, int itemHeight, char startCharMap, Object* target, SEL_MenuHandler selector)
|
MenuItemAtlasFont * MenuItemAtlasFont::create(const std::string& value, const std::string& charMapFile, int itemWidth, int itemHeight, char startCharMap, Object* target, SEL_MenuHandler selector)
|
||||||
{
|
{
|
||||||
MenuItemAtlasFont *ret = new MenuItemAtlasFont();
|
MenuItemAtlasFont *ret = new MenuItemAtlasFont();
|
||||||
ret->initWithString(value, charMapFile, itemWidth, itemHeight, startCharMap, target, selector);
|
ret->initWithString(value, charMapFile, itemWidth, itemHeight, startCharMap, target, selector);
|
||||||
|
@ -337,7 +337,7 @@ MenuItemAtlasFont * MenuItemAtlasFont::create(const std::string& value, const st
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX: deprecated
|
// XXX: deprecated
|
||||||
bool MenuItemAtlasFont::initWithString(const char* value, const char* charMapFile, int itemWidth, int itemHeight, char startCharMap, Object* target, SEL_MenuHandler selector)
|
bool MenuItemAtlasFont::initWithString(const std::string& value, const std::string& charMapFile, int itemWidth, int itemHeight, char startCharMap, Object* target, SEL_MenuHandler selector)
|
||||||
{
|
{
|
||||||
_target = target;
|
_target = target;
|
||||||
CC_SAFE_RETAIN(_target);
|
CC_SAFE_RETAIN(_target);
|
||||||
|
@ -387,7 +387,7 @@ const std::string& MenuItemFont::getFontName()
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX: deprecated
|
// XXX: deprecated
|
||||||
MenuItemFont * MenuItemFont::create(const char *value, Object* target, SEL_MenuHandler selector)
|
MenuItemFont * MenuItemFont::create(const std::string& value, Object* target, SEL_MenuHandler selector)
|
||||||
{
|
{
|
||||||
MenuItemFont *ret = new MenuItemFont();
|
MenuItemFont *ret = new MenuItemFont();
|
||||||
ret->initWithString(value, target, selector);
|
ret->initWithString(value, target, selector);
|
||||||
|
@ -422,9 +422,9 @@ MenuItemFont::~MenuItemFont()
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX: deprecated
|
// XXX: deprecated
|
||||||
bool MenuItemFont::initWithString(const char *value, Object* target, SEL_MenuHandler selector)
|
bool MenuItemFont::initWithString(const std::string& value, Object* target, SEL_MenuHandler selector)
|
||||||
{
|
{
|
||||||
CCASSERT( value != nullptr && strlen(value) != 0, "Value length must be greater than 0");
|
CCASSERT( !value.empty(), "Value length must be greater than 0");
|
||||||
|
|
||||||
_target = target;
|
_target = target;
|
||||||
CC_SAFE_RETAIN(target);
|
CC_SAFE_RETAIN(target);
|
||||||
|
@ -433,7 +433,7 @@ bool MenuItemFont::initWithString(const char *value, Object* target, SEL_MenuHan
|
||||||
|
|
||||||
bool MenuItemFont::initWithString(const std::string& value, const ccMenuCallback& callback)
|
bool MenuItemFont::initWithString(const std::string& value, const ccMenuCallback& callback)
|
||||||
{
|
{
|
||||||
CCASSERT( value.size() >= 0, "Value length must be greater than 0");
|
CCASSERT( !value.empty(), "Value length must be greater than 0");
|
||||||
|
|
||||||
_fontName = _globalFontName;
|
_fontName = _globalFontName;
|
||||||
_fontSize = _globalFontSize;
|
_fontSize = _globalFontSize;
|
||||||
|
@ -710,7 +710,7 @@ MenuItemImage * MenuItemImage::create(const std::string& normalImage, const std:
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX deprecated
|
// XXX deprecated
|
||||||
MenuItemImage * MenuItemImage::create(const char *normalImage, const char *selectedImage, Object* target, SEL_MenuHandler selector)
|
MenuItemImage * MenuItemImage::create(const std::string& normalImage, const std::string& selectedImage, Object* target, SEL_MenuHandler selector)
|
||||||
{
|
{
|
||||||
return MenuItemImage::create(normalImage, selectedImage, "", target, selector);
|
return MenuItemImage::create(normalImage, selectedImage, "", target, selector);
|
||||||
}
|
}
|
||||||
|
@ -721,7 +721,7 @@ MenuItemImage * MenuItemImage::create(const std::string& normalImage, const std:
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX deprecated
|
// XXX deprecated
|
||||||
MenuItemImage * MenuItemImage::create(const char *normalImage, const char *selectedImage, const char *disabledImage, Object* target, SEL_MenuHandler selector)
|
MenuItemImage * MenuItemImage::create(const std::string& normalImage, const std::string& selectedImage, const std::string& disabledImage, Object* target, SEL_MenuHandler selector)
|
||||||
{
|
{
|
||||||
MenuItemImage *ret = new MenuItemImage();
|
MenuItemImage *ret = new MenuItemImage();
|
||||||
if (ret && ret->initWithNormalImage(normalImage, selectedImage, disabledImage, target, selector))
|
if (ret && ret->initWithNormalImage(normalImage, selectedImage, disabledImage, target, selector))
|
||||||
|
@ -758,7 +758,7 @@ MenuItemImage * MenuItemImage::create(const std::string& normalImage, const std:
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX: deprecated
|
// XXX: deprecated
|
||||||
bool MenuItemImage::initWithNormalImage(const char *normalImage, const char *selectedImage, const char *disabledImage, Object* target, SEL_MenuHandler selector)
|
bool MenuItemImage::initWithNormalImage(const std::string& normalImage, const std::string& selectedImage, const std::string& disabledImage, Object* target, SEL_MenuHandler selector)
|
||||||
{
|
{
|
||||||
_target = target;
|
_target = target;
|
||||||
CC_SAFE_RETAIN(_target);
|
CC_SAFE_RETAIN(_target);
|
||||||
|
|
|
@ -217,7 +217,7 @@ public:
|
||||||
/** creates a menu item from a string and atlas with a target/selector */
|
/** creates a menu item from a string and atlas with a target/selector */
|
||||||
static MenuItemAtlasFont* create(const std::string& value, const std::string& charMapFile, int itemWidth, int itemHeight, char startCharMap);
|
static MenuItemAtlasFont* create(const std::string& value, const std::string& charMapFile, int itemWidth, int itemHeight, char startCharMap);
|
||||||
/** creates a menu item from a string and atlas. Use it with MenuItemToggle */
|
/** creates a menu item from a string and atlas. Use it with MenuItemToggle */
|
||||||
CC_DEPRECATED_ATTRIBUTE static MenuItemAtlasFont* create(const char* value, const char* charMapFile, int itemWidth, int itemHeight, char startCharMap, Object* target, SEL_MenuHandler selector);
|
CC_DEPRECATED_ATTRIBUTE static MenuItemAtlasFont* create(const std::string& value, const std::string& charMapFile, int itemWidth, int itemHeight, char startCharMap, Object* target, SEL_MenuHandler selector);
|
||||||
/** creates a menu item from a string and atlas. Use it with MenuItemToggle */
|
/** creates a menu item from a string and atlas. Use it with MenuItemToggle */
|
||||||
static MenuItemAtlasFont* create(const std::string& value, const std::string& charMapFile, int itemWidth, int itemHeight, char startCharMap, const ccMenuCallback& callback);
|
static MenuItemAtlasFont* create(const std::string& value, const std::string& charMapFile, int itemWidth, int itemHeight, char startCharMap, const ccMenuCallback& callback);
|
||||||
|
|
||||||
|
@ -233,7 +233,7 @@ protected:
|
||||||
virtual ~MenuItemAtlasFont(){}
|
virtual ~MenuItemAtlasFont(){}
|
||||||
|
|
||||||
/** initializes a menu item from a string and atlas with a target/selector */
|
/** initializes a menu item from a string and atlas with a target/selector */
|
||||||
CC_DEPRECATED_ATTRIBUTE bool initWithString(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap, Object* target, SEL_MenuHandler selector);
|
CC_DEPRECATED_ATTRIBUTE bool initWithString(const std::string& value, const std::string& charMapFile, int itemWidth, int itemHeight, char startCharMap, Object* target, SEL_MenuHandler selector);
|
||||||
/** initializes a menu item from a string and atlas with a target/selector */
|
/** initializes a menu item from a string and atlas with a target/selector */
|
||||||
bool initWithString(const std::string& value, const std::string& charMapFile, int itemWidth, int itemHeight, char startCharMap, const ccMenuCallback& callback);
|
bool initWithString(const std::string& value, const std::string& charMapFile, int itemWidth, int itemHeight, char startCharMap, const ccMenuCallback& callback);
|
||||||
|
|
||||||
|
@ -251,7 +251,7 @@ public:
|
||||||
/** creates a menu item from a string without target/selector. To be used with MenuItemToggle */
|
/** creates a menu item from a string without target/selector. To be used with MenuItemToggle */
|
||||||
static MenuItemFont * create(const std::string& value = "");
|
static MenuItemFont * create(const std::string& value = "");
|
||||||
/** creates a menu item from a string with a target/selector */
|
/** creates a menu item from a string with a target/selector */
|
||||||
CC_DEPRECATED_ATTRIBUTE static MenuItemFont * create(const char *value, Object* target, SEL_MenuHandler selector);
|
CC_DEPRECATED_ATTRIBUTE static MenuItemFont * create(const std::string& value, Object* target, SEL_MenuHandler selector);
|
||||||
/** creates a menu item from a string with a target/selector */
|
/** creates a menu item from a string with a target/selector */
|
||||||
static MenuItemFont * create(const std::string& value, const ccMenuCallback& callback);
|
static MenuItemFont * create(const std::string& value, const ccMenuCallback& callback);
|
||||||
|
|
||||||
|
@ -306,7 +306,7 @@ protected:
|
||||||
virtual ~MenuItemFont();
|
virtual ~MenuItemFont();
|
||||||
|
|
||||||
/** initializes a menu item from a string with a target/selector */
|
/** initializes a menu item from a string with a target/selector */
|
||||||
CC_DEPRECATED_ATTRIBUTE bool initWithString(const char *value, Object* target, SEL_MenuHandler selector);
|
CC_DEPRECATED_ATTRIBUTE bool initWithString(const std::string& value, Object* target, SEL_MenuHandler selector);
|
||||||
/** initializes a menu item from a string with a target/selector */
|
/** initializes a menu item from a string with a target/selector */
|
||||||
bool initWithString(const std::string& value, const ccMenuCallback& callback);
|
bool initWithString(const std::string& value, const ccMenuCallback& callback);
|
||||||
|
|
||||||
|
@ -411,12 +411,12 @@ public:
|
||||||
/** creates a menu item with a normal,selected and disabled image*/
|
/** creates a menu item with a normal,selected and disabled image*/
|
||||||
static MenuItemImage* create(const std::string& normalImage, const std::string& selectedImage, const std::string& disabledImage);
|
static MenuItemImage* create(const std::string& normalImage, const std::string& selectedImage, const std::string& disabledImage);
|
||||||
/** creates a menu item with a normal and selected image with target/selector */
|
/** creates a menu item with a normal and selected image with target/selector */
|
||||||
CC_DEPRECATED_ATTRIBUTE static MenuItemImage* create(const char *normalImage, const char *selectedImage, Object* target, SEL_MenuHandler selector);
|
CC_DEPRECATED_ATTRIBUTE static MenuItemImage* create(const std::string& normalImage, const std::string& selectedImage, Object* target, SEL_MenuHandler selector);
|
||||||
/** creates a menu item with a normal and selected image with a callable object */
|
/** creates a menu item with a normal and selected image with a callable object */
|
||||||
static MenuItemImage* create(const std::string&normalImage, const std::string&selectedImage, const ccMenuCallback& callback);
|
static MenuItemImage* create(const std::string&normalImage, const std::string&selectedImage, const ccMenuCallback& callback);
|
||||||
|
|
||||||
/** creates a menu item with a normal,selected and disabled image with target/selector */
|
/** creates a menu item with a normal,selected and disabled image with target/selector */
|
||||||
CC_DEPRECATED_ATTRIBUTE static MenuItemImage* create(const char *normalImage, const char *selectedImage, const char *disabledImage, Object* target, SEL_MenuHandler selector);
|
CC_DEPRECATED_ATTRIBUTE static MenuItemImage* create(const std::string& normalImage, const std::string& selectedImage, const std::string& disabledImage, Object* target, SEL_MenuHandler selector);
|
||||||
/** creates a menu item with a normal,selected and disabled image with a callable object */
|
/** creates a menu item with a normal,selected and disabled image with a callable object */
|
||||||
static MenuItemImage* create(const std::string&normalImage, const std::string&selectedImage, const std::string&disabledImage, const ccMenuCallback& callback);
|
static MenuItemImage* create(const std::string&normalImage, const std::string&selectedImage, const std::string&disabledImage, const ccMenuCallback& callback);
|
||||||
|
|
||||||
|
@ -440,7 +440,7 @@ protected:
|
||||||
|
|
||||||
bool init();
|
bool init();
|
||||||
/** initializes a menu item with a normal, selected and disabled image with target/selector */
|
/** initializes a menu item with a normal, selected and disabled image with target/selector */
|
||||||
CC_DEPRECATED_ATTRIBUTE bool initWithNormalImage(const char *normalImage, const char *selectedImage, const char *disabledImage, Object* target, SEL_MenuHandler selector);
|
CC_DEPRECATED_ATTRIBUTE bool initWithNormalImage(const std::string& normalImage, const std::string& selectedImage, const std::string& disabledImage, Object* target, SEL_MenuHandler selector);
|
||||||
/** initializes a menu item with a normal, selected and disabled image with a callable object */
|
/** initializes a menu item with a normal, selected and disabled image with a callable object */
|
||||||
bool initWithNormalImage(const std::string& normalImage, const std::string& selectedImage, const std::string& disabledImage, const ccMenuCallback& callback);
|
bool initWithNormalImage(const std::string& normalImage, const std::string& selectedImage, const std::string& disabledImage, const ccMenuCallback& callback);
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ MotionStreak::~MotionStreak()
|
||||||
CC_SAFE_FREE(_texCoords);
|
CC_SAFE_FREE(_texCoords);
|
||||||
}
|
}
|
||||||
|
|
||||||
MotionStreak* MotionStreak::create(float fade, float minSeg, float stroke, const Color3B& color, const char* path)
|
MotionStreak* MotionStreak::create(float fade, float minSeg, float stroke, const Color3B& color, const std::string& path)
|
||||||
{
|
{
|
||||||
MotionStreak *ret = new MotionStreak();
|
MotionStreak *ret = new MotionStreak();
|
||||||
if (ret && ret->initWithFade(fade, minSeg, stroke, color, path))
|
if (ret && ret->initWithFade(fade, minSeg, stroke, color, path))
|
||||||
|
@ -91,9 +91,9 @@ MotionStreak* MotionStreak::create(float fade, float minSeg, float stroke, const
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MotionStreak::initWithFade(float fade, float minSeg, float stroke, const Color3B& color, const char* path)
|
bool MotionStreak::initWithFade(float fade, float minSeg, float stroke, const Color3B& color, const std::string& path)
|
||||||
{
|
{
|
||||||
CCASSERT(path != nullptr, "Invalid filename");
|
CCASSERT(!path.empty(), "Invalid filename");
|
||||||
|
|
||||||
Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(path);
|
Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(path);
|
||||||
return initWithFade(fade, minSeg, stroke, color, texture);
|
return initWithFade(fade, minSeg, stroke, color, texture);
|
||||||
|
|
|
@ -50,7 +50,7 @@ class CC_DLL MotionStreak : public Node, public TextureProtocol
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/** creates and initializes a motion streak with fade in seconds, minimum segments, stroke's width, color, texture filename */
|
/** creates and initializes a motion streak with fade in seconds, minimum segments, stroke's width, color, texture filename */
|
||||||
static MotionStreak* create(float fade, float minSeg, float stroke, const Color3B& color, const char* path);
|
static MotionStreak* create(float fade, float minSeg, float stroke, const Color3B& color, const std::string& path);
|
||||||
/** creates and initializes a motion streak with fade in seconds, minimum segments, stroke's width, color, texture */
|
/** creates and initializes a motion streak with fade in seconds, minimum segments, stroke's width, color, texture */
|
||||||
static MotionStreak* create(float fade, float minSeg, float stroke, const Color3B& color, Texture2D* texture);
|
static MotionStreak* create(float fade, float minSeg, float stroke, const Color3B& color, Texture2D* texture);
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ protected:
|
||||||
virtual ~MotionStreak();
|
virtual ~MotionStreak();
|
||||||
|
|
||||||
/** initializes a motion streak with fade in seconds, minimum segments, stroke's width, color and texture filename */
|
/** initializes a motion streak with fade in seconds, minimum segments, stroke's width, color and texture filename */
|
||||||
bool initWithFade(float fade, float minSeg, float stroke, const Color3B& color, const char* path);
|
bool initWithFade(float fade, float minSeg, float stroke, const Color3B& color, const std::string& path);
|
||||||
/** initializes a motion streak with fade in seconds, minimum segments, stroke's width, color and texture */
|
/** initializes a motion streak with fade in seconds, minimum segments, stroke's width, color and texture */
|
||||||
bool initWithFade(float fade, float minSeg, float stroke, const Color3B& color, Texture2D* texture);
|
bool initWithFade(float fade, float minSeg, float stroke, const Color3B& color, Texture2D* texture);
|
||||||
|
|
||||||
|
|
|
@ -1346,7 +1346,7 @@ void Node::updateTransform()
|
||||||
child->updateTransform();
|
child->updateTransform();
|
||||||
}
|
}
|
||||||
|
|
||||||
Component* Node::getComponent(const char *pName)
|
Component* Node::getComponent(const std::string& pName)
|
||||||
{
|
{
|
||||||
if( _componentContainer )
|
if( _componentContainer )
|
||||||
return _componentContainer->get(pName);
|
return _componentContainer->get(pName);
|
||||||
|
@ -1361,7 +1361,7 @@ bool Node::addComponent(Component *pComponent)
|
||||||
return _componentContainer->add(pComponent);
|
return _componentContainer->add(pComponent);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Node::removeComponent(const char *pName)
|
bool Node::removeComponent(const std::string& pName)
|
||||||
{
|
{
|
||||||
if( _componentContainer )
|
if( _componentContainer )
|
||||||
return _componentContainer->remove(pName);
|
return _componentContainer->remove(pName);
|
||||||
|
|
|
@ -1322,7 +1322,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* gets a component by its name
|
* gets a component by its name
|
||||||
*/
|
*/
|
||||||
Component* getComponent(const char *pName);
|
Component* getComponent(const std::string& pName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* adds a component
|
* adds a component
|
||||||
|
@ -1332,7 +1332,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* removes a component by its name
|
* removes a component by its name
|
||||||
*/
|
*/
|
||||||
virtual bool removeComponent(const char *pName);
|
virtual bool removeComponent(const std::string& pName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* removes all components
|
* removes all components
|
||||||
|
|
|
@ -74,7 +74,7 @@ void NotificationCenter::purgeNotificationCenter(void)
|
||||||
//
|
//
|
||||||
// internal functions
|
// internal functions
|
||||||
//
|
//
|
||||||
bool NotificationCenter::observerExisted(Object *target,const char *name, Object *sender)
|
bool NotificationCenter::observerExisted(Object *target, const std::string& name, Object *sender)
|
||||||
{
|
{
|
||||||
Object* obj = nullptr;
|
Object* obj = nullptr;
|
||||||
CCARRAY_FOREACH(_observers, obj)
|
CCARRAY_FOREACH(_observers, obj)
|
||||||
|
@ -83,7 +83,7 @@ bool NotificationCenter::observerExisted(Object *target,const char *name, Object
|
||||||
if (!observer)
|
if (!observer)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!strcmp(observer->getName(),name) && observer->getTarget() == target && observer->getSender() == sender)
|
if (observer->getName() == name && observer->getTarget() == target && observer->getSender() == sender)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -94,7 +94,7 @@ bool NotificationCenter::observerExisted(Object *target,const char *name, Object
|
||||||
//
|
//
|
||||||
void NotificationCenter::addObserver(Object *target,
|
void NotificationCenter::addObserver(Object *target,
|
||||||
SEL_CallFuncO selector,
|
SEL_CallFuncO selector,
|
||||||
const char *name,
|
const std::string& name,
|
||||||
Object *sender)
|
Object *sender)
|
||||||
{
|
{
|
||||||
if (this->observerExisted(target, name, sender))
|
if (this->observerExisted(target, name, sender))
|
||||||
|
@ -108,7 +108,7 @@ void NotificationCenter::addObserver(Object *target,
|
||||||
_observers->addObject(observer);
|
_observers->addObject(observer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotificationCenter::removeObserver(Object *target,const char *name)
|
void NotificationCenter::removeObserver(Object *target, const std::string& name)
|
||||||
{
|
{
|
||||||
Object* obj = nullptr;
|
Object* obj = nullptr;
|
||||||
CCARRAY_FOREACH(_observers, obj)
|
CCARRAY_FOREACH(_observers, obj)
|
||||||
|
@ -117,7 +117,7 @@ void NotificationCenter::removeObserver(Object *target,const char *name)
|
||||||
if (!observer)
|
if (!observer)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!strcmp(observer->getName(),name) && observer->getTarget() == target)
|
if (observer->getName() == name && observer->getTarget() == target)
|
||||||
{
|
{
|
||||||
_observers->removeObject(observer);
|
_observers->removeObject(observer);
|
||||||
return;
|
return;
|
||||||
|
@ -146,7 +146,7 @@ int NotificationCenter::removeAllObservers(Object *target)
|
||||||
return static_cast<int>(toRemove->count());
|
return static_cast<int>(toRemove->count());
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotificationCenter::registerScriptObserver( Object *target, int handler,const char* name)
|
void NotificationCenter::registerScriptObserver( Object *target, int handler,const std::string& name)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (this->observerExisted(target, name, nullptr))
|
if (this->observerExisted(target, name, nullptr))
|
||||||
|
@ -161,7 +161,7 @@ void NotificationCenter::registerScriptObserver( Object *target, int handler,con
|
||||||
_observers->addObject(observer);
|
_observers->addObject(observer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotificationCenter::unregisterScriptObserver(Object *target,const char* name)
|
void NotificationCenter::unregisterScriptObserver(Object *target,const std::string& name)
|
||||||
{
|
{
|
||||||
Object* obj = nullptr;
|
Object* obj = nullptr;
|
||||||
CCARRAY_FOREACH(_observers, obj)
|
CCARRAY_FOREACH(_observers, obj)
|
||||||
|
@ -170,14 +170,14 @@ void NotificationCenter::unregisterScriptObserver(Object *target,const char* nam
|
||||||
if (!observer)
|
if (!observer)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ( !strcmp(observer->getName(),name) && observer->getTarget() == target)
|
if ( observer->getName() == name && observer->getTarget() == target)
|
||||||
{
|
{
|
||||||
_observers->removeObject(observer);
|
_observers->removeObject(observer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotificationCenter::postNotification(const char *name, Object *sender)
|
void NotificationCenter::postNotification(const std::string& name, Object *sender)
|
||||||
{
|
{
|
||||||
__Array* ObserversCopy = __Array::createWithCapacity(_observers->count());
|
__Array* ObserversCopy = __Array::createWithCapacity(_observers->count());
|
||||||
ObserversCopy->addObjectsFromArray(_observers);
|
ObserversCopy->addObjectsFromArray(_observers);
|
||||||
|
@ -188,11 +188,11 @@ void NotificationCenter::postNotification(const char *name, Object *sender)
|
||||||
if (!observer)
|
if (!observer)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!strcmp(name,observer->getName()) && (observer->getSender() == sender || observer->getSender() == nullptr || sender == nullptr))
|
if (observer->getName() == name && (observer->getSender() == sender || observer->getSender() == nullptr || sender == nullptr))
|
||||||
{
|
{
|
||||||
if (0 != observer->getHandler())
|
if (0 != observer->getHandler())
|
||||||
{
|
{
|
||||||
BasicScriptData data(this, (void*)name);
|
BasicScriptData data(this, (void*)name.c_str());
|
||||||
ScriptEvent scriptEvent(kNotificationEvent,(void*)&data);
|
ScriptEvent scriptEvent(kNotificationEvent,(void*)&data);
|
||||||
ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&scriptEvent);
|
ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&scriptEvent);
|
||||||
}
|
}
|
||||||
|
@ -204,14 +204,14 @@ void NotificationCenter::postNotification(const char *name, Object *sender)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotificationCenter::postNotification(const char *name)
|
void NotificationCenter::postNotification(const std::string& name)
|
||||||
{
|
{
|
||||||
this->postNotification(name,nullptr);
|
this->postNotification(name,nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
int NotificationCenter::getObserverHandlerByName(const char* name)
|
int NotificationCenter::getObserverHandlerByName(const std::string& name)
|
||||||
{
|
{
|
||||||
if (nullptr == name || strlen(name) == 0)
|
if (name.empty())
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -223,7 +223,7 @@ int NotificationCenter::getObserverHandlerByName(const char* name)
|
||||||
if (nullptr == observer)
|
if (nullptr == observer)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ( 0 == strcmp(observer->getName(),name) )
|
if ( observer->getName() == name )
|
||||||
{
|
{
|
||||||
return observer->getHandler();
|
return observer->getHandler();
|
||||||
break;
|
break;
|
||||||
|
@ -240,7 +240,7 @@ int NotificationCenter::getObserverHandlerByName(const char* name)
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
NotificationObserver::NotificationObserver(Object *target,
|
NotificationObserver::NotificationObserver(Object *target,
|
||||||
SEL_CallFuncO selector,
|
SEL_CallFuncO selector,
|
||||||
const char *name,
|
const std::string& name,
|
||||||
Object *sender)
|
Object *sender)
|
||||||
{
|
{
|
||||||
_target = target;
|
_target = target;
|
||||||
|
@ -278,9 +278,9 @@ SEL_CallFuncO NotificationObserver::getSelector() const
|
||||||
return _selector;
|
return _selector;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* NotificationObserver::getName() const
|
const std::string& NotificationObserver::getName() const
|
||||||
{
|
{
|
||||||
return _name.c_str();
|
return _name;
|
||||||
}
|
}
|
||||||
|
|
||||||
Object* NotificationObserver::getSender() const
|
Object* NotificationObserver::getSender() const
|
||||||
|
|
|
@ -67,14 +67,14 @@ public:
|
||||||
*/
|
*/
|
||||||
void addObserver(Object *target,
|
void addObserver(Object *target,
|
||||||
SEL_CallFuncO selector,
|
SEL_CallFuncO selector,
|
||||||
const char *name,
|
const std::string& name,
|
||||||
Object *sender);
|
Object *sender);
|
||||||
|
|
||||||
/** @brief Removes the observer by the specified target and name.
|
/** @brief Removes the observer by the specified target and name.
|
||||||
* @param target The target of this notification.
|
* @param target The target of this notification.
|
||||||
* @param name The name of this notification.
|
* @param name The name of this notification.
|
||||||
*/
|
*/
|
||||||
void removeObserver(Object *target,const char *name);
|
void removeObserver(Object *target,const std::string& name);
|
||||||
|
|
||||||
/** @brief Removes all notifications registered by this target
|
/** @brief Removes all notifications registered by this target
|
||||||
* @param target The target of this notification.
|
* @param target The target of this notification.
|
||||||
|
@ -86,21 +86,21 @@ public:
|
||||||
* @note Only supports Lua Binding now.
|
* @note Only supports Lua Binding now.
|
||||||
* @param handler The lua handler.
|
* @param handler The lua handler.
|
||||||
*/
|
*/
|
||||||
void registerScriptObserver(Object *target,int handler,const char* name);
|
void registerScriptObserver(Object *target,int handler,const std::string& name);
|
||||||
|
|
||||||
/** Unregisters script observer */
|
/** Unregisters script observer */
|
||||||
void unregisterScriptObserver(Object *target,const char* name);
|
void unregisterScriptObserver(Object *target,const std::string& name);
|
||||||
|
|
||||||
/** @brief Posts one notification event by name.
|
/** @brief Posts one notification event by name.
|
||||||
* @param name The name of this notification.
|
* @param name The name of this notification.
|
||||||
*/
|
*/
|
||||||
void postNotification(const char *name);
|
void postNotification(const std::string& name);
|
||||||
|
|
||||||
/** @brief Posts one notification event by name.
|
/** @brief Posts one notification event by name.
|
||||||
* @param name The name of this notification.
|
* @param name The name of this notification.
|
||||||
* @param sender The object posting the notification. Can be nullptr
|
* @param sender The object posting the notification. Can be nullptr
|
||||||
*/
|
*/
|
||||||
void postNotification(const char *name, Object *sender);
|
void postNotification(const std::string& name, Object *sender);
|
||||||
|
|
||||||
/** @brief Gets script handler.
|
/** @brief Gets script handler.
|
||||||
* @note Only supports Lua Binding now.
|
* @note Only supports Lua Binding now.
|
||||||
|
@ -112,12 +112,12 @@ public:
|
||||||
* @param name The name of this notification.
|
* @param name The name of this notification.
|
||||||
* @return The observer script handle.
|
* @return The observer script handle.
|
||||||
*/
|
*/
|
||||||
int getObserverHandlerByName(const char* name);
|
int getObserverHandlerByName(const std::string& name);
|
||||||
private:
|
private:
|
||||||
// internal functions
|
// internal functions
|
||||||
|
|
||||||
// Check whether the observer exists by the specified target and name.
|
// Check whether the observer exists by the specified target and name.
|
||||||
bool observerExisted(Object *target,const char *name, Object *sender);
|
bool observerExisted(Object *target,const std::string& name, Object *sender);
|
||||||
|
|
||||||
// variables
|
// variables
|
||||||
//
|
//
|
||||||
|
@ -138,7 +138,7 @@ public:
|
||||||
*/
|
*/
|
||||||
NotificationObserver(Object *target,
|
NotificationObserver(Object *target,
|
||||||
SEL_CallFuncO selector,
|
SEL_CallFuncO selector,
|
||||||
const char *name,
|
const std::string& name,
|
||||||
Object *sender);
|
Object *sender);
|
||||||
|
|
||||||
/** NotificationObserver destructor function
|
/** NotificationObserver destructor function
|
||||||
|
@ -168,7 +168,7 @@ public:
|
||||||
* @js NA
|
* @js NA
|
||||||
* @lua NA
|
* @lua NA
|
||||||
*/
|
*/
|
||||||
const char* getName() const;
|
const std::string& getName() const;
|
||||||
/**
|
/**
|
||||||
* @js NA
|
* @js NA
|
||||||
* @lua NA
|
* @lua NA
|
||||||
|
|
|
@ -41,7 +41,7 @@ static Texture2D* getDefaultTexture()
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
const char* key = "/__firePngData";
|
const std::string key = "/__firePngData";
|
||||||
texture = Director::getInstance()->getTextureCache()->getTextureForKey(key);
|
texture = Director::getInstance()->getTextureCache()->getTextureForKey(key);
|
||||||
CC_BREAK_IF(texture != nullptr);
|
CC_BREAK_IF(texture != nullptr);
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ SpriteBatchNode* SpriteBatchNode::createWithTexture(Texture2D* tex, ssize_t capa
|
||||||
* creation with File Image
|
* creation with File Image
|
||||||
*/
|
*/
|
||||||
|
|
||||||
SpriteBatchNode* SpriteBatchNode::create(const char *fileImage, ssize_t capacity/* = DEFAULT_CAPACITY*/)
|
SpriteBatchNode* SpriteBatchNode::create(const std::string& fileImage, ssize_t capacity/* = DEFAULT_CAPACITY*/)
|
||||||
{
|
{
|
||||||
SpriteBatchNode *batchNode = new SpriteBatchNode();
|
SpriteBatchNode *batchNode = new SpriteBatchNode();
|
||||||
batchNode->initWithFile(fileImage, capacity);
|
batchNode->initWithFile(fileImage, capacity);
|
||||||
|
@ -112,7 +112,7 @@ bool SpriteBatchNode::init()
|
||||||
/*
|
/*
|
||||||
* init with FileImage
|
* init with FileImage
|
||||||
*/
|
*/
|
||||||
bool SpriteBatchNode::initWithFile(const char* fileImage, ssize_t capacity)
|
bool SpriteBatchNode::initWithFile(const std::string& fileImage, ssize_t capacity)
|
||||||
{
|
{
|
||||||
Texture2D *texture2D = Director::getInstance()->getTextureCache()->addImage(fileImage);
|
Texture2D *texture2D = Director::getInstance()->getTextureCache()->addImage(fileImage);
|
||||||
return initWithTexture(texture2D, capacity);
|
return initWithTexture(texture2D, capacity);
|
||||||
|
|
|
@ -74,7 +74,7 @@ public:
|
||||||
The capacity will be increased in 33% in runtime if it run out of space.
|
The capacity will be increased in 33% in runtime if it run out of space.
|
||||||
The file will be loaded using the TextureMgr.
|
The file will be loaded using the TextureMgr.
|
||||||
*/
|
*/
|
||||||
static SpriteBatchNode* create(const char* fileImage, ssize_t capacity = DEFAULT_CAPACITY);
|
static SpriteBatchNode* create(const std::string& fileImage, ssize_t capacity = DEFAULT_CAPACITY);
|
||||||
/**
|
/**
|
||||||
* @js ctor
|
* @js ctor
|
||||||
*/
|
*/
|
||||||
|
@ -95,7 +95,7 @@ public:
|
||||||
* @js init
|
* @js init
|
||||||
* @lua init
|
* @lua init
|
||||||
*/
|
*/
|
||||||
bool initWithFile(const char* fileImage, ssize_t capacity);
|
bool initWithFile(const std::string& fileImage, ssize_t capacity);
|
||||||
bool init();
|
bool init();
|
||||||
|
|
||||||
/** returns the TextureAtlas object */
|
/** returns the TextureAtlas object */
|
||||||
|
|
|
@ -143,8 +143,8 @@ public:
|
||||||
/** Creates the tiles */
|
/** Creates the tiles */
|
||||||
void setupTiles();
|
void setupTiles();
|
||||||
|
|
||||||
inline const char* getLayerName(){ return _layerName.c_str(); }
|
inline const std::string& getLayerName(){ return _layerName; }
|
||||||
inline void setLayerName(const char *layerName){ _layerName = layerName; }
|
inline void setLayerName(const std::string& layerName){ _layerName = layerName; }
|
||||||
|
|
||||||
/** size of the layer in tiles */
|
/** size of the layer in tiles */
|
||||||
inline const Size& getLayerSize() const { return _layerSize; };
|
inline const Size& getLayerSize() const { return _layerSize; };
|
||||||
|
|
|
@ -122,7 +122,7 @@ public:
|
||||||
* @js NA
|
* @js NA
|
||||||
* @lua NA
|
* @lua NA
|
||||||
*/
|
*/
|
||||||
CC_DEPRECATED_ATTRIBUTE TMXLayer* layerNamed(const char *layerName) const { return getLayer(layerName); };
|
CC_DEPRECATED_ATTRIBUTE TMXLayer* layerNamed(const std::string& layerName) const { return getLayer(layerName); };
|
||||||
|
|
||||||
/** return the TMXObjectGroup for the specific group */
|
/** return the TMXObjectGroup for the specific group */
|
||||||
TMXObjectGroup* getObjectGroup(const std::string& groupName) const;
|
TMXObjectGroup* getObjectGroup(const std::string& groupName) const;
|
||||||
|
@ -130,7 +130,7 @@ public:
|
||||||
* @js NA
|
* @js NA
|
||||||
* @lua NA
|
* @lua NA
|
||||||
*/
|
*/
|
||||||
CC_DEPRECATED_ATTRIBUTE TMXObjectGroup* objectGroupNamed(const char *groupName) const { return getObjectGroup(groupName); };
|
CC_DEPRECATED_ATTRIBUTE TMXObjectGroup* objectGroupNamed(const std::string& groupName) const { return getObjectGroup(groupName); };
|
||||||
|
|
||||||
/** return the value for the specific property name */
|
/** return the value for the specific property name */
|
||||||
Value getProperty(const std::string& propertyName) const;
|
Value getProperty(const std::string& propertyName) const;
|
||||||
|
|
|
@ -236,9 +236,9 @@ void TextFieldTTF::deleteBackward()
|
||||||
setString(text);
|
setString(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char * TextFieldTTF::getContentText()
|
const std::string& TextFieldTTF::getContentText()
|
||||||
{
|
{
|
||||||
return _inputText.c_str();
|
return _inputText;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextFieldTTF::draw()
|
void TextFieldTTF::draw()
|
||||||
|
|
|
@ -182,7 +182,7 @@ protected:
|
||||||
virtual bool canDetachWithIME() override;
|
virtual bool canDetachWithIME() override;
|
||||||
virtual void insertText(const char * text, int len) override;
|
virtual void insertText(const char * text, int len) override;
|
||||||
virtual void deleteBackward() override;
|
virtual void deleteBackward() override;
|
||||||
virtual const char * getContentText() override;
|
virtual const std::string& getContentText() override;
|
||||||
private:
|
private:
|
||||||
class LengthStack;
|
class LengthStack;
|
||||||
LengthStack * _lens;
|
LengthStack * _lens;
|
||||||
|
|
|
@ -110,7 +110,7 @@ void TextureAtlas::setQuads(V3F_C4B_T2F_Quad* quads)
|
||||||
|
|
||||||
// TextureAtlas - alloc & init
|
// TextureAtlas - alloc & init
|
||||||
|
|
||||||
TextureAtlas * TextureAtlas::create(const char* file, ssize_t capacity)
|
TextureAtlas * TextureAtlas::create(const std::string& file, ssize_t capacity)
|
||||||
{
|
{
|
||||||
TextureAtlas * textureAtlas = new TextureAtlas();
|
TextureAtlas * textureAtlas = new TextureAtlas();
|
||||||
if(textureAtlas && textureAtlas->initWithFile(file, capacity))
|
if(textureAtlas && textureAtlas->initWithFile(file, capacity))
|
||||||
|
@ -134,7 +134,7 @@ TextureAtlas * TextureAtlas::createWithTexture(Texture2D *texture, ssize_t capac
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TextureAtlas::initWithFile(const char * file, ssize_t capacity)
|
bool TextureAtlas::initWithFile(const std::string& file, ssize_t capacity)
|
||||||
{
|
{
|
||||||
// retained in property
|
// retained in property
|
||||||
Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(file);
|
Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(file);
|
||||||
|
@ -145,7 +145,7 @@ bool TextureAtlas::initWithFile(const char * file, ssize_t capacity)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CCLOG("cocos2d: Could not open file: %s", file);
|
CCLOG("cocos2d: Could not open file: %s", file.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ public:
|
||||||
/** creates a TextureAtlas with an filename and with an initial capacity for Quads.
|
/** creates a TextureAtlas with an filename and with an initial capacity for Quads.
|
||||||
* The TextureAtlas capacity can be increased in runtime.
|
* The TextureAtlas capacity can be increased in runtime.
|
||||||
*/
|
*/
|
||||||
static TextureAtlas* create(const char* file , ssize_t capacity);
|
static TextureAtlas* create(const std::string& file , ssize_t capacity);
|
||||||
|
|
||||||
/** creates a TextureAtlas with a previously initialized Texture2D object, and
|
/** creates a TextureAtlas with a previously initialized Texture2D object, and
|
||||||
* with an initial capacity for n Quads.
|
* with an initial capacity for n Quads.
|
||||||
|
@ -81,7 +81,7 @@ public:
|
||||||
*
|
*
|
||||||
* WARNING: Do not reinitialize the TextureAtlas because it will leak memory (issue #706)
|
* WARNING: Do not reinitialize the TextureAtlas because it will leak memory (issue #706)
|
||||||
*/
|
*/
|
||||||
bool initWithFile(const char* file, ssize_t capacity);
|
bool initWithFile(const std::string& file, ssize_t capacity);
|
||||||
|
|
||||||
/** initializes a TextureAtlas with a previously initialized Texture2D object, and
|
/** initializes a TextureAtlas with a previously initialized Texture2D object, and
|
||||||
* with an initial capacity for Quads.
|
* with an initial capacity for Quads.
|
||||||
|
|
|
@ -193,13 +193,13 @@ void TextureCache::loadImage()
|
||||||
|
|
||||||
if (generateImage)
|
if (generateImage)
|
||||||
{
|
{
|
||||||
const char *filename = asyncStruct->filename.c_str();
|
const std::string& filename = asyncStruct->filename;
|
||||||
// generate image
|
// generate image
|
||||||
image = new Image();
|
image = new Image();
|
||||||
if (image && !image->initWithImageFileThreadSafe(filename))
|
if (image && !image->initWithImageFileThreadSafe(filename))
|
||||||
{
|
{
|
||||||
CC_SAFE_RELEASE(image);
|
CC_SAFE_RELEASE(image);
|
||||||
CCLOG("can not load %s", filename);
|
CCLOG("can not load %s", filename.c_str());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -245,7 +245,7 @@ void TextureCache::addImageAsyncCallBack(float dt)
|
||||||
|
|
||||||
Object *target = asyncStruct->target;
|
Object *target = asyncStruct->target;
|
||||||
SEL_CallFuncO selector = asyncStruct->selector;
|
SEL_CallFuncO selector = asyncStruct->selector;
|
||||||
const char* filename = asyncStruct->filename.c_str();
|
const std::string& filename = asyncStruct->filename;
|
||||||
|
|
||||||
Texture2D *texture = nullptr;
|
Texture2D *texture = nullptr;
|
||||||
if (image)
|
if (image)
|
||||||
|
@ -326,7 +326,7 @@ Texture2D * TextureCache::addImage(const std::string &path)
|
||||||
{
|
{
|
||||||
#if CC_ENABLE_CACHE_TEXTURE_DATA
|
#if CC_ENABLE_CACHE_TEXTURE_DATA
|
||||||
// cache the texture file name
|
// cache the texture file name
|
||||||
VolatileTextureMgr::addImageTexture(texture, fullpath.c_str());
|
VolatileTextureMgr::addImageTexture(texture, fullpath);
|
||||||
#endif
|
#endif
|
||||||
// texture already retained, no need to re-retain it
|
// texture already retained, no need to re-retain it
|
||||||
_textures.insert( std::make_pair(fullpath, texture) );
|
_textures.insert( std::make_pair(fullpath, texture) );
|
||||||
|
@ -509,7 +509,7 @@ VolatileTexture::~VolatileTexture()
|
||||||
CC_SAFE_RELEASE(_uiImage);
|
CC_SAFE_RELEASE(_uiImage);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VolatileTextureMgr::addImageTexture(Texture2D *tt, const char* imageFileName)
|
void VolatileTextureMgr::addImageTexture(Texture2D *tt, const std::string& imageFileName)
|
||||||
{
|
{
|
||||||
if (_isReloading)
|
if (_isReloading)
|
||||||
{
|
{
|
||||||
|
|
|
@ -124,13 +124,13 @@ public:
|
||||||
* If "key" is nil, then a new texture will be created each time.
|
* If "key" is nil, then a new texture will be created each time.
|
||||||
*/
|
*/
|
||||||
Texture2D* addImage(Image *image, const std::string &key);
|
Texture2D* addImage(Image *image, const std::string &key);
|
||||||
CC_DEPRECATED_ATTRIBUTE Texture2D* addUIImage(Image *image, const char *key) { return addImage(image,key); }
|
CC_DEPRECATED_ATTRIBUTE Texture2D* addUIImage(Image *image, const std::string& key) { return addImage(image,key); }
|
||||||
|
|
||||||
/** Returns an already created texture. Returns nil if the texture doesn't exist.
|
/** Returns an already created texture. Returns nil if the texture doesn't exist.
|
||||||
@since v0.99.5
|
@since v0.99.5
|
||||||
*/
|
*/
|
||||||
Texture2D* getTextureForKey(const std::string& key) const;
|
Texture2D* getTextureForKey(const std::string& key) const;
|
||||||
CC_DEPRECATED_ATTRIBUTE Texture2D* textureForKey(const char* key) const { return getTextureForKey(key); }
|
CC_DEPRECATED_ATTRIBUTE Texture2D* textureForKey(const std::string& key) const { return getTextureForKey(key); }
|
||||||
|
|
||||||
/** Purges the dictionary of loaded textures.
|
/** Purges the dictionary of loaded textures.
|
||||||
* Call this method if you receive the "Memory Warning"
|
* Call this method if you receive the "Memory Warning"
|
||||||
|
@ -250,7 +250,7 @@ protected:
|
||||||
class VolatileTextureMgr
|
class VolatileTextureMgr
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void addImageTexture(Texture2D *tt, const char* imageFileName);
|
static void addImageTexture(Texture2D *tt, const std::string& imageFileName);
|
||||||
static void addStringTexture(Texture2D *tt, const char* text, const FontDefinition& fontDefinition);
|
static void addStringTexture(Texture2D *tt, const char* text, const FontDefinition& fontDefinition);
|
||||||
static void addDataTexture(Texture2D *tt, void* data, int dataLen, Texture2D::PixelFormat pixelFormat, const Size& contentSize);
|
static void addDataTexture(Texture2D *tt, void* data, int dataLen, Texture2D::PixelFormat pixelFormat, const Size& contentSize);
|
||||||
static void addImage(Texture2D *tt, Image *image);
|
static void addImage(Texture2D *tt, Image *image);
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include "ccTypes.h"
|
#include "ccTypes.h"
|
||||||
|
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
const std::string STD_STRING_EMPTY("");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Color3B
|
* Color3B
|
||||||
|
|
|
@ -471,6 +471,8 @@ public:
|
||||||
Acceleration(): x(0), y(0), z(0), timestamp(0) {}
|
Acceleration(): x(0), y(0), z(0), timestamp(0) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern const std::string STD_STRING_EMPTY;
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
||||||
#endif //__CCTYPES_H__
|
#endif //__CCTYPES_H__
|
||||||
|
|
|
@ -83,7 +83,7 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ValueMap dictionaryWithContentsOfFile(const char *fileName)
|
ValueMap dictionaryWithContentsOfFile(const std::string& fileName)
|
||||||
{
|
{
|
||||||
_resultType = SAX_RESULT_DICT;
|
_resultType = SAX_RESULT_DICT;
|
||||||
SAXParser parser;
|
SAXParser parser;
|
||||||
|
@ -95,7 +95,7 @@ public:
|
||||||
return _rootDict;
|
return _rootDict;
|
||||||
}
|
}
|
||||||
|
|
||||||
ValueVector arrayWithContentsOfFile(const char* fileName)
|
ValueVector arrayWithContentsOfFile(const std::string& fileName)
|
||||||
{
|
{
|
||||||
_resultType = SAX_RESULT_ARRAY;
|
_resultType = SAX_RESULT_ARRAY;
|
||||||
SAXParser parser;
|
SAXParser parser;
|
||||||
|
@ -555,10 +555,10 @@ Data FileUtils::getDataFromFile(const std::string& filename)
|
||||||
return getData(filename, false);
|
return getData(filename, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char* FileUtils::getFileData(const char* filename, const char* mode, ssize_t *size)
|
unsigned char* FileUtils::getFileData(const std::string& filename, const char* mode, ssize_t *size)
|
||||||
{
|
{
|
||||||
unsigned char * buffer = nullptr;
|
unsigned char * buffer = nullptr;
|
||||||
CCASSERT(filename != nullptr && size != nullptr && mode != nullptr, "Invalid parameters.");
|
CCASSERT(!filename.empty() && size != nullptr && mode != nullptr, "Invalid parameters.");
|
||||||
*size = 0;
|
*size = 0;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
@ -585,7 +585,7 @@ unsigned char* FileUtils::getFileData(const char* filename, const char* mode, ss
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char* FileUtils::getFileDataFromZip(const char* zipFilePath, const char* filename, ssize_t *size)
|
unsigned char* FileUtils::getFileDataFromZip(const std::string& zipFilePath, const std::string& filename, ssize_t *size)
|
||||||
{
|
{
|
||||||
unsigned char * buffer = nullptr;
|
unsigned char * buffer = nullptr;
|
||||||
unzFile file = nullptr;
|
unzFile file = nullptr;
|
||||||
|
@ -593,13 +593,12 @@ unsigned char* FileUtils::getFileDataFromZip(const char* zipFilePath, const char
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
CC_BREAK_IF(!zipFilePath || !filename);
|
CC_BREAK_IF(zipFilePath.empty());
|
||||||
CC_BREAK_IF(strlen(zipFilePath) == 0);
|
|
||||||
|
|
||||||
file = unzOpen(zipFilePath);
|
file = unzOpen(zipFilePath.c_str());
|
||||||
CC_BREAK_IF(!file);
|
CC_BREAK_IF(!file);
|
||||||
|
|
||||||
int ret = unzLocateFile(file, filename, 1);
|
int ret = unzLocateFile(file, filename.c_str(), 1);
|
||||||
CC_BREAK_IF(UNZ_OK != ret);
|
CC_BREAK_IF(UNZ_OK != ret);
|
||||||
|
|
||||||
char filePathA[260];
|
char filePathA[260];
|
||||||
|
|
|
@ -96,7 +96,7 @@ public:
|
||||||
* @return Upon success, a pointer to the data is returned, otherwise NULL.
|
* @return Upon success, a pointer to the data is returned, otherwise NULL.
|
||||||
* @warning Recall: you are responsible for calling free() on any Non-NULL pointer returned.
|
* @warning Recall: you are responsible for calling free() on any Non-NULL pointer returned.
|
||||||
*/
|
*/
|
||||||
CC_DEPRECATED_ATTRIBUTE virtual unsigned char* getFileData(const char* filename, const char* mode, ssize_t *size);
|
CC_DEPRECATED_ATTRIBUTE virtual unsigned char* getFileData(const std::string& filename, const char* mode, ssize_t *size);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets resource file data from a zip file.
|
* Gets resource file data from a zip file.
|
||||||
|
@ -106,7 +106,7 @@ public:
|
||||||
* @return Upon success, a pointer to the data is returned, otherwise nullptr.
|
* @return Upon success, a pointer to the data is returned, otherwise nullptr.
|
||||||
* @warning Recall: you are responsible for calling free() on any Non-nullptr pointer returned.
|
* @warning Recall: you are responsible for calling free() on any Non-nullptr pointer returned.
|
||||||
*/
|
*/
|
||||||
virtual unsigned char* getFileDataFromZip(const char* zipFilePath, const char* filename, ssize_t *size);
|
virtual unsigned char* getFileDataFromZip(const std::string& zipFilePath, const std::string& filename, ssize_t *size);
|
||||||
|
|
||||||
|
|
||||||
/** Returns the fullpath for a given filename.
|
/** Returns the fullpath for a given filename.
|
||||||
|
|
|
@ -111,7 +111,7 @@ public:
|
||||||
@param path the absolute file path.
|
@param path the absolute file path.
|
||||||
@return true if loaded correctly.
|
@return true if loaded correctly.
|
||||||
*/
|
*/
|
||||||
bool initWithImageFile(const char *path);
|
bool initWithImageFile(const std::string& path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Load image from stream buffer.
|
@brief Load image from stream buffer.
|
||||||
|
@ -246,7 +246,7 @@ private:
|
||||||
@param imageType the type of image, currently only supporting two types.
|
@param imageType the type of image, currently only supporting two types.
|
||||||
@return true if loaded correctly.
|
@return true if loaded correctly.
|
||||||
*/
|
*/
|
||||||
bool initWithImageFileThreadSafe(const char *fullpath);
|
bool initWithImageFileThreadSafe(const std::string& fullpath);
|
||||||
|
|
||||||
Format detectFormat(const unsigned char * data, ssize_t dataLen);
|
Format detectFormat(const unsigned char * data, ssize_t dataLen);
|
||||||
bool isPng(const unsigned char * data, ssize_t dataLen);
|
bool isPng(const unsigned char * data, ssize_t dataLen);
|
||||||
|
|
|
@ -396,10 +396,10 @@ Image::~Image()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Image::initWithImageFile(const char * strPath)
|
bool Image::initWithImageFile(const std::string& path)
|
||||||
{
|
{
|
||||||
bool bRet = false;
|
bool ret = false;
|
||||||
_filePath = FileUtils::getInstance()->fullPathForFilename(strPath);
|
_filePath = FileUtils::getInstance()->fullPathForFilename(path);
|
||||||
|
|
||||||
#ifdef EMSCRIPTEN
|
#ifdef EMSCRIPTEN
|
||||||
// Emscripten includes a re-implementation of SDL that uses HTML5 canvas
|
// Emscripten includes a re-implementation of SDL that uses HTML5 canvas
|
||||||
|
@ -409,7 +409,7 @@ bool Image::initWithImageFile(const char * strPath)
|
||||||
SDL_Surface *iSurf = IMG_Load(fullPath.c_str());
|
SDL_Surface *iSurf = IMG_Load(fullPath.c_str());
|
||||||
|
|
||||||
int size = 4 * (iSurf->w * iSurf->h);
|
int size = 4 * (iSurf->w * iSurf->h);
|
||||||
bRet = initWithRawData((const unsigned char*)iSurf->pixels, size, iSurf->w, iSurf->h, 8, true);
|
ret = initWithRawData((const unsigned char*)iSurf->pixels, size, iSurf->w, iSurf->h, 8, true);
|
||||||
|
|
||||||
unsigned int *tmp = (unsigned int *)_data;
|
unsigned int *tmp = (unsigned int *)_data;
|
||||||
int nrPixels = iSurf->w * iSurf->h;
|
int nrPixels = iSurf->w * iSurf->h;
|
||||||
|
@ -425,14 +425,14 @@ bool Image::initWithImageFile(const char * strPath)
|
||||||
|
|
||||||
if (!data.isNull())
|
if (!data.isNull())
|
||||||
{
|
{
|
||||||
bRet = initWithImageData(data.getBytes(), data.getSize());
|
ret = initWithImageData(data.getBytes(), data.getSize());
|
||||||
}
|
}
|
||||||
#endif // EMSCRIPTEN
|
#endif // EMSCRIPTEN
|
||||||
|
|
||||||
return bRet;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Image::initWithImageFileThreadSafe(const char *fullpath)
|
bool Image::initWithImageFileThreadSafe(const std::string& fullpath)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
_filePath = fullpath;
|
_filePath = fullpath;
|
||||||
|
|
|
@ -247,11 +247,11 @@ Data FileUtilsAndroid::getDataFromFile(const std::string& filename)
|
||||||
return getData(filename, false);
|
return getData(filename, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char* FileUtilsAndroid::getFileData(const char* filename, const char* mode, ssize_t * size)
|
unsigned char* FileUtilsAndroid::getFileData(const std::string& filename, const char* mode, ssize_t * size)
|
||||||
{
|
{
|
||||||
unsigned char * data = 0;
|
unsigned char * data = 0;
|
||||||
|
|
||||||
if ((! filename) || (! mode) || 0 == strlen(filename))
|
if ( filename.empty() || (! mode) )
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ public:
|
||||||
bool init();
|
bool init();
|
||||||
|
|
||||||
/** @deprecated Please use FileUtils::getDataFromFile or FileUtils::getStringFromFile instead. */
|
/** @deprecated Please use FileUtils::getDataFromFile or FileUtils::getStringFromFile instead. */
|
||||||
CC_DEPRECATED_ATTRIBUTE virtual unsigned char* getFileData(const char* filename, const char* mode, ssize_t * size) override;
|
CC_DEPRECATED_ATTRIBUTE virtual unsigned char* getFileData(const std::string& filename, const char* mode, ssize_t * size) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets string from a file.
|
* Gets string from a file.
|
||||||
|
|
|
@ -74,7 +74,7 @@ extern "C" {
|
||||||
if (JniHelper::getJavaVM()->GetEnv((void**)&env, JNI_VERSION_1_4) != JNI_OK || ! env) {
|
if (JniHelper::getJavaVM()->GetEnv((void**)&env, JNI_VERSION_1_4) != JNI_OK || ! env) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
const char * text = cocos2d::IMEDispatcher::sharedDispatcher()->getContentText();
|
const std::string& text = cocos2d::IMEDispatcher::sharedDispatcher()->getContentText();
|
||||||
return env->NewStringUTF(text);
|
return env->NewStringUTF(text.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,20 +87,20 @@ static CGSize _calculateStringSize(NSString *str, id font, CGSize *constrainSize
|
||||||
#define ALIGN_CENTER 3
|
#define ALIGN_CENTER 3
|
||||||
#define ALIGN_BOTTOM 2
|
#define ALIGN_BOTTOM 2
|
||||||
|
|
||||||
static bool _initWithString(const char * pText, cocos2d::Image::TextAlign eAlign, const char * pFontName, int nSize, tImageInfo* pInfo)
|
static bool _initWithString(const char * text, cocos2d::Image::TextAlign align, const char * fontName, int size, tImageInfo* info)
|
||||||
{
|
{
|
||||||
bool bRet = false;
|
bool bRet = false;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
CC_BREAK_IF(! pText || ! pInfo);
|
CC_BREAK_IF(! text || ! info);
|
||||||
|
|
||||||
NSString * str = [NSString stringWithUTF8String:pText];
|
NSString * str = [NSString stringWithUTF8String:text];
|
||||||
NSString * fntName = [NSString stringWithUTF8String:pFontName];
|
NSString * fntName = [NSString stringWithUTF8String:fontName];
|
||||||
|
|
||||||
CGSize dim, constrainSize;
|
CGSize dim, constrainSize;
|
||||||
|
|
||||||
constrainSize.width = pInfo->width;
|
constrainSize.width = info->width;
|
||||||
constrainSize.height = pInfo->height;
|
constrainSize.height = info->height;
|
||||||
|
|
||||||
// On iOS custom fonts must be listed beforehand in the App info.plist (in order to be usable) and referenced only the by the font family name itself when
|
// On iOS custom fonts must be listed beforehand in the App info.plist (in order to be usable) and referenced only the by the font family name itself when
|
||||||
// calling [UIFont fontWithName]. Therefore even if the developer adds 'SomeFont.ttf' or 'fonts/SomeFont.ttf' to the App .plist, the font must
|
// calling [UIFont fontWithName]. Therefore even if the developer adds 'SomeFont.ttf' or 'fonts/SomeFont.ttf' to the App .plist, the font must
|
||||||
|
@ -110,7 +110,7 @@ static bool _initWithString(const char * pText, cocos2d::Image::TextAlign eAlign
|
||||||
fntName = [[fntName lastPathComponent] stringByDeletingPathExtension];
|
fntName = [[fntName lastPathComponent] stringByDeletingPathExtension];
|
||||||
|
|
||||||
// create the font
|
// create the font
|
||||||
id font = [UIFont fontWithName:fntName size:nSize];
|
id font = [UIFont fontWithName:fntName size:size];
|
||||||
|
|
||||||
if (font)
|
if (font)
|
||||||
{
|
{
|
||||||
|
@ -120,7 +120,7 @@ static bool _initWithString(const char * pText, cocos2d::Image::TextAlign eAlign
|
||||||
{
|
{
|
||||||
if (!font)
|
if (!font)
|
||||||
{
|
{
|
||||||
font = [UIFont systemFontOfSize:nSize];
|
font = [UIFont systemFontOfSize:size];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (font)
|
if (font)
|
||||||
|
@ -136,7 +136,7 @@ static bool _initWithString(const char * pText, cocos2d::Image::TextAlign eAlign
|
||||||
if (constrainSize.height > dim.height)
|
if (constrainSize.height > dim.height)
|
||||||
{
|
{
|
||||||
// vertical alignment
|
// vertical alignment
|
||||||
unsigned int vAlignment = ((int)eAlign >> 4) & 0x0F;
|
unsigned int vAlignment = ((int)align >> 4) & 0x0F;
|
||||||
if (vAlignment == ALIGN_TOP)
|
if (vAlignment == ALIGN_TOP)
|
||||||
{
|
{
|
||||||
startH = 0;
|
startH = 0;
|
||||||
|
@ -166,16 +166,16 @@ static bool _initWithString(const char * pText, cocos2d::Image::TextAlign eAlign
|
||||||
float shadowStrokePaddingX = 0.0f;
|
float shadowStrokePaddingX = 0.0f;
|
||||||
float shadowStrokePaddingY = 0.0f;
|
float shadowStrokePaddingY = 0.0f;
|
||||||
|
|
||||||
if ( pInfo->hasStroke )
|
if ( info->hasStroke )
|
||||||
{
|
{
|
||||||
shadowStrokePaddingX = ceilf(pInfo->strokeSize);
|
shadowStrokePaddingX = ceilf(info->strokeSize);
|
||||||
shadowStrokePaddingY = ceilf(pInfo->strokeSize);
|
shadowStrokePaddingY = ceilf(info->strokeSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( pInfo->hasShadow )
|
if ( info->hasShadow )
|
||||||
{
|
{
|
||||||
shadowStrokePaddingX = std::max(shadowStrokePaddingX, (float)fabs(pInfo->shadowOffset.width));
|
shadowStrokePaddingX = std::max(shadowStrokePaddingX, (float)fabs(info->shadowOffset.width));
|
||||||
shadowStrokePaddingY = std::max(shadowStrokePaddingY, (float)fabs(pInfo->shadowOffset.height));
|
shadowStrokePaddingY = std::max(shadowStrokePaddingY, (float)fabs(info->shadowOffset.height));
|
||||||
}
|
}
|
||||||
|
|
||||||
// add the padding (this could be 0 if no shadow and no stroke)
|
// add the padding (this could be 0 if no shadow and no stroke)
|
||||||
|
@ -203,7 +203,7 @@ static bool _initWithString(const char * pText, cocos2d::Image::TextAlign eAlign
|
||||||
}
|
}
|
||||||
|
|
||||||
// text color
|
// text color
|
||||||
CGContextSetRGBFillColor(context, pInfo->tintColorR, pInfo->tintColorG, pInfo->tintColorB, 1);
|
CGContextSetRGBFillColor(context, info->tintColorR, info->tintColorG, info->tintColorB, 1);
|
||||||
// move Y rendering to the top of the image
|
// move Y rendering to the top of the image
|
||||||
CGContextTranslateCTM(context, 0.0f, (dim.height - shadowStrokePaddingY) );
|
CGContextTranslateCTM(context, 0.0f, (dim.height - shadowStrokePaddingY) );
|
||||||
CGContextScaleCTM(context, 1.0f, -1.0f); //NOTE: NSString draws in UIKit referential i.e. renders upside-down compared to CGBitmapContext referential
|
CGContextScaleCTM(context, 1.0f, -1.0f); //NOTE: NSString draws in UIKit referential i.e. renders upside-down compared to CGBitmapContext referential
|
||||||
|
@ -212,30 +212,30 @@ static bool _initWithString(const char * pText, cocos2d::Image::TextAlign eAlign
|
||||||
UIGraphicsPushContext(context);
|
UIGraphicsPushContext(context);
|
||||||
|
|
||||||
// measure text size with specified font and determine the rectangle to draw text in
|
// measure text size with specified font and determine the rectangle to draw text in
|
||||||
unsigned uHoriFlag = (int)eAlign & 0x0f;
|
unsigned uHoriFlag = (int)align & 0x0f;
|
||||||
UITextAlignment align = (UITextAlignment)((2 == uHoriFlag) ? UITextAlignmentRight
|
UITextAlignment testAlign = (UITextAlignment)((2 == uHoriFlag) ? UITextAlignmentRight
|
||||||
: (3 == uHoriFlag) ? UITextAlignmentCenter
|
: (3 == uHoriFlag) ? UITextAlignmentCenter
|
||||||
: UITextAlignmentLeft);
|
: UITextAlignmentLeft);
|
||||||
|
|
||||||
|
|
||||||
// take care of stroke if needed
|
// take care of stroke if needed
|
||||||
if ( pInfo->hasStroke )
|
if ( info->hasStroke )
|
||||||
{
|
{
|
||||||
CGContextSetTextDrawingMode(context, kCGTextFillStroke);
|
CGContextSetTextDrawingMode(context, kCGTextFillStroke);
|
||||||
CGContextSetRGBStrokeColor(context, pInfo->strokeColorR, pInfo->strokeColorG, pInfo->strokeColorB, 1);
|
CGContextSetRGBStrokeColor(context, info->strokeColorR, info->strokeColorG, info->strokeColorB, 1);
|
||||||
CGContextSetLineWidth(context, pInfo->strokeSize);
|
CGContextSetLineWidth(context, info->strokeSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
// take care of shadow if needed
|
// take care of shadow if needed
|
||||||
if ( pInfo->hasShadow )
|
if ( info->hasShadow )
|
||||||
{
|
{
|
||||||
CGSize offset;
|
CGSize offset;
|
||||||
offset.height = pInfo->shadowOffset.height;
|
offset.height = info->shadowOffset.height;
|
||||||
offset.width = pInfo->shadowOffset.width;
|
offset.width = info->shadowOffset.width;
|
||||||
CGFloat shadowColorValues[] = {0, 0, 0, pInfo->shadowOpacity};
|
CGFloat shadowColorValues[] = {0, 0, 0, info->shadowOpacity};
|
||||||
CGColorRef shadowColor = CGColorCreate (colorSpace, shadowColorValues);
|
CGColorRef shadowColor = CGColorCreate (colorSpace, shadowColorValues);
|
||||||
|
|
||||||
CGContextSetShadowWithColor(context, offset, pInfo->shadowBlur, shadowColor);
|
CGContextSetShadowWithColor(context, offset, info->shadowBlur, shadowColor);
|
||||||
|
|
||||||
CGColorRelease (shadowColor);
|
CGColorRelease (shadowColor);
|
||||||
}
|
}
|
||||||
|
@ -266,7 +266,7 @@ static bool _initWithString(const char * pText, cocos2d::Image::TextAlign eAlign
|
||||||
float textHeight = dim.height - shadowStrokePaddingY;
|
float textHeight = dim.height - shadowStrokePaddingY;
|
||||||
|
|
||||||
|
|
||||||
if ( pInfo->shadowOffset.width < 0 )
|
if ( info->shadowOffset.width < 0 )
|
||||||
{
|
{
|
||||||
textOriginX = shadowStrokePaddingX;
|
textOriginX = shadowStrokePaddingX;
|
||||||
}
|
}
|
||||||
|
@ -275,7 +275,7 @@ static bool _initWithString(const char * pText, cocos2d::Image::TextAlign eAlign
|
||||||
textOriginX = 0.0;
|
textOriginX = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pInfo->shadowOffset.height > 0)
|
if (info->shadowOffset.height > 0)
|
||||||
{
|
{
|
||||||
textOrigingY = startH;
|
textOrigingY = startH;
|
||||||
}
|
}
|
||||||
|
@ -289,7 +289,7 @@ static bool _initWithString(const char * pText, cocos2d::Image::TextAlign eAlign
|
||||||
CGContextBeginTransparencyLayerWithRect(context, rect, nullptr);
|
CGContextBeginTransparencyLayerWithRect(context, rect, nullptr);
|
||||||
// actually draw the text in the context
|
// actually draw the text in the context
|
||||||
// XXX: ios7 casting
|
// XXX: ios7 casting
|
||||||
[str drawInRect: rect withFont:font lineBreakMode:NSLineBreakByWordWrapping alignment:(NSTextAlignment)align];
|
[str drawInRect: rect withFont:font lineBreakMode:NSLineBreakByWordWrapping alignment:(NSTextAlignment)testAlign];
|
||||||
|
|
||||||
CGContextEndTransparencyLayer(context);
|
CGContextEndTransparencyLayer(context);
|
||||||
|
|
||||||
|
@ -300,10 +300,10 @@ static bool _initWithString(const char * pText, cocos2d::Image::TextAlign eAlign
|
||||||
CGContextRelease(context);
|
CGContextRelease(context);
|
||||||
|
|
||||||
// output params
|
// output params
|
||||||
pInfo->data = data;
|
info->data = data;
|
||||||
pInfo->isPremultipliedAlpha = true;
|
info->isPremultipliedAlpha = true;
|
||||||
pInfo->width = dim.width;
|
info->width = dim.width;
|
||||||
pInfo->height = dim.height;
|
info->height = dim.height;
|
||||||
bRet = true;
|
bRet = true;
|
||||||
|
|
||||||
} while (0);
|
} while (0);
|
||||||
|
@ -325,12 +325,12 @@ bool Image::initWithString(
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Image::initWithStringShadowStroke(
|
bool Image::initWithStringShadowStroke(
|
||||||
const char * pText,
|
const char * text,
|
||||||
int nWidth ,
|
int width ,
|
||||||
int nHeight ,
|
int height ,
|
||||||
TextAlign eAlignMask ,
|
TextAlign alignMask ,
|
||||||
const char * pFontName ,
|
const char * fontName ,
|
||||||
int nSize ,
|
int size ,
|
||||||
float textTintR,
|
float textTintR,
|
||||||
float textTintG,
|
float textTintG,
|
||||||
float textTintB,
|
float textTintB,
|
||||||
|
@ -349,8 +349,8 @@ bool Image::initWithStringShadowStroke(
|
||||||
|
|
||||||
|
|
||||||
tImageInfo info = {0};
|
tImageInfo info = {0};
|
||||||
info.width = nWidth;
|
info.width = width;
|
||||||
info.height = nHeight;
|
info.height = height;
|
||||||
info.hasShadow = shadow;
|
info.hasShadow = shadow;
|
||||||
info.shadowOffset.width = shadowOffsetX;
|
info.shadowOffset.width = shadowOffsetX;
|
||||||
info.shadowOffset.height = shadowOffsetY;
|
info.shadowOffset.height = shadowOffsetY;
|
||||||
|
@ -366,7 +366,7 @@ bool Image::initWithStringShadowStroke(
|
||||||
info.tintColorB = textTintB;
|
info.tintColorB = textTintB;
|
||||||
|
|
||||||
|
|
||||||
if (! _initWithString(pText, eAlignMask, pFontName, nSize, &info))
|
if (! _initWithString(text, alignMask, fontName, size, &info))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -380,7 +380,7 @@ bool Image::initWithStringShadowStroke(
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Image::saveToFile(const std::string& filename, bool bIsToRGB)
|
bool Image::saveToFile(const std::string& filename, bool isToRGB)
|
||||||
{
|
{
|
||||||
bool saveToPNG = false;
|
bool saveToPNG = false;
|
||||||
bool needToCopyPixels = false;
|
bool needToCopyPixels = false;
|
||||||
|
@ -392,7 +392,7 @@ bool Image::saveToFile(const std::string& filename, bool bIsToRGB)
|
||||||
|
|
||||||
int bitsPerComponent = 8;
|
int bitsPerComponent = 8;
|
||||||
int bitsPerPixel = hasAlpha() ? 32 : 24;
|
int bitsPerPixel = hasAlpha() ? 32 : 24;
|
||||||
if ((! saveToPNG) || bIsToRGB)
|
if ((! saveToPNG) || isToRGB)
|
||||||
{
|
{
|
||||||
bitsPerPixel = 24;
|
bitsPerPixel = 24;
|
||||||
}
|
}
|
||||||
|
@ -404,7 +404,7 @@ bool Image::saveToFile(const std::string& filename, bool bIsToRGB)
|
||||||
|
|
||||||
// The data has alpha channel, and want to save it with an RGB png file,
|
// The data has alpha channel, and want to save it with an RGB png file,
|
||||||
// or want to save as jpg, remove the alpha channel.
|
// or want to save as jpg, remove the alpha channel.
|
||||||
if ((saveToPNG && hasAlpha() && bIsToRGB)
|
if ((saveToPNG && hasAlpha() && isToRGB)
|
||||||
|| (! saveToPNG))
|
|| (! saveToPNG))
|
||||||
{
|
{
|
||||||
pixels = new unsigned char[myDataLength];
|
pixels = new unsigned char[myDataLength];
|
||||||
|
@ -424,7 +424,7 @@ bool Image::saveToFile(const std::string& filename, bool bIsToRGB)
|
||||||
|
|
||||||
// make data provider with data.
|
// make data provider with data.
|
||||||
CGBitmapInfo bitmapInfo = kCGBitmapByteOrderDefault;
|
CGBitmapInfo bitmapInfo = kCGBitmapByteOrderDefault;
|
||||||
if (saveToPNG && hasAlpha() && (! bIsToRGB))
|
if (saveToPNG && hasAlpha() && (! isToRGB))
|
||||||
{
|
{
|
||||||
bitmapInfo |= kCGImageAlphaPremultipliedLast;
|
bitmapInfo |= kCGImageAlphaPremultipliedLast;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ public:
|
||||||
/*
|
/*
|
||||||
*frameZoomFactor for frame. This method is for debugging big resolution (e.g.new ipad) app on desktop.
|
*frameZoomFactor for frame. This method is for debugging big resolution (e.g.new ipad) app on desktop.
|
||||||
*/
|
*/
|
||||||
bool init(const char* viewName, float width, float height, float frameZoomFactor = 1.0f);
|
bool init(const std::string& viewName, float width, float height, float frameZoomFactor = 1.0f);
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//void resize(int width, int height);
|
//void resize(int width, int height);
|
||||||
|
|
|
@ -325,7 +325,7 @@ EGLView::~EGLView()
|
||||||
s_pEglView = nullptr;
|
s_pEglView = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EGLView::init(const char *viewName, float width, float height, float frameZoomFactor)
|
bool EGLView::init(const std::string& viewName, float width, float height, float frameZoomFactor)
|
||||||
{
|
{
|
||||||
if(nullptr != _mainWindow) return true;
|
if(nullptr != _mainWindow) return true;
|
||||||
|
|
||||||
|
|
|
@ -122,7 +122,7 @@ __Array* __Array::createWithCapacity(int capacity)
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
__Array* __Array::createWithContentsOfFile(const char* fileName)
|
__Array* __Array::createWithContentsOfFile(const std::string& fileName)
|
||||||
{
|
{
|
||||||
__Array* ret = __Array::createWithContentsOfFileThreadSafe(fileName);
|
__Array* ret = __Array::createWithContentsOfFileThreadSafe(fileName);
|
||||||
if (ret != nullptr)
|
if (ret != nullptr)
|
||||||
|
@ -132,7 +132,7 @@ __Array* __Array::createWithContentsOfFile(const char* fileName)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
__Array* __Array::createWithContentsOfFileThreadSafe(const char* fileName)
|
__Array* __Array::createWithContentsOfFileThreadSafe(const std::string& fileName)
|
||||||
{
|
{
|
||||||
return FileUtils::getInstance()->createArrayWithContentsOfFile(fileName);
|
return FileUtils::getInstance()->createArrayWithContentsOfFile(fileName);
|
||||||
}
|
}
|
||||||
|
@ -465,7 +465,7 @@ __Array* __Array::createWithCapacity(ssize_t capacity)
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
__Array* __Array::createWithContentsOfFile(const char* fileName)
|
__Array* __Array::createWithContentsOfFile(const std::string& fileName)
|
||||||
{
|
{
|
||||||
__Array* ret = __Array::createWithContentsOfFileThreadSafe(fileName);
|
__Array* ret = __Array::createWithContentsOfFileThreadSafe(fileName);
|
||||||
if (ret != nullptr)
|
if (ret != nullptr)
|
||||||
|
@ -475,7 +475,7 @@ __Array* __Array::createWithContentsOfFile(const char* fileName)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
__Array* __Array::createWithContentsOfFileThreadSafe(const char* fileName)
|
__Array* __Array::createWithContentsOfFileThreadSafe(const std::string& fileName)
|
||||||
{
|
{
|
||||||
ValueVector arr = FileUtils::getInstance()->getValueVectorFromFile(fileName);
|
ValueVector arr = FileUtils::getInstance()->getValueVectorFromFile(fileName);
|
||||||
|
|
||||||
|
|
|
@ -261,7 +261,7 @@ public:
|
||||||
@return The Array pointer generated from the file
|
@return The Array pointer generated from the file
|
||||||
* @js NA
|
* @js NA
|
||||||
*/
|
*/
|
||||||
static __Array* createWithContentsOfFile(const char* pFileName);
|
static __Array* createWithContentsOfFile(const std::string& pFileName);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@brief The same meaning as arrayWithContentsOfFile(), but it doesn't call autorelease, so the
|
@brief The same meaning as arrayWithContentsOfFile(), but it doesn't call autorelease, so the
|
||||||
|
@ -269,7 +269,7 @@ public:
|
||||||
* @js NA
|
* @js NA
|
||||||
* @lua NA
|
* @lua NA
|
||||||
*/
|
*/
|
||||||
static __Array* createWithContentsOfFileThreadSafe(const char* pFileName);
|
static __Array* createWithContentsOfFileThreadSafe(const std::string& pFileName);
|
||||||
/**
|
/**
|
||||||
* @js NA
|
* @js NA
|
||||||
* @lua NA
|
* @lua NA
|
||||||
|
|
|
@ -40,25 +40,25 @@ using std::max;
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
|
|
||||||
CCSkeleton* CCSkeleton::createWithData (spSkeletonData* skeletonData, bool isOwnsSkeletonData) {
|
Skeleton* Skeleton::createWithData (spSkeletonData* skeletonData, bool isOwnsSkeletonData) {
|
||||||
CCSkeleton* node = new CCSkeleton(skeletonData, isOwnsSkeletonData);
|
Skeleton* node = new Skeleton(skeletonData, isOwnsSkeletonData);
|
||||||
node->autorelease();
|
node->autorelease();
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCSkeleton* CCSkeleton::createWithFile (const char* skeletonDataFile, spAtlas* atlas, float scale) {
|
Skeleton* Skeleton::createWithFile (const char* skeletonDataFile, spAtlas* atlas, float scale) {
|
||||||
CCSkeleton* node = new CCSkeleton(skeletonDataFile, atlas, scale);
|
Skeleton* node = new Skeleton(skeletonDataFile, atlas, scale);
|
||||||
node->autorelease();
|
node->autorelease();
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCSkeleton* CCSkeleton::createWithFile (const char* skeletonDataFile, const char* atlasFile, float scale) {
|
Skeleton* Skeleton::createWithFile (const char* skeletonDataFile, const char* atlasFile, float scale) {
|
||||||
CCSkeleton* node = new CCSkeleton(skeletonDataFile, atlasFile, scale);
|
Skeleton* node = new Skeleton(skeletonDataFile, atlasFile, scale);
|
||||||
node->autorelease();
|
node->autorelease();
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCSkeleton::initialize () {
|
void Skeleton::initialize () {
|
||||||
atlas = 0;
|
atlas = 0;
|
||||||
debugSlots = false;
|
debugSlots = false;
|
||||||
debugBones = false;
|
debugBones = false;
|
||||||
|
@ -73,23 +73,23 @@ void CCSkeleton::initialize () {
|
||||||
scheduleUpdate();
|
scheduleUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCSkeleton::setSkeletonData (spSkeletonData *skeletonData, bool isOwnsSkeletonData) {
|
void Skeleton::setSkeletonData (spSkeletonData *skeletonData, bool isOwnsSkeletonData) {
|
||||||
skeleton = spSkeleton_create(skeletonData);
|
skeleton = spSkeleton_create(skeletonData);
|
||||||
rootBone = skeleton->bones[0];
|
rootBone = skeleton->bones[0];
|
||||||
this->ownsSkeletonData = isOwnsSkeletonData;
|
this->ownsSkeletonData = isOwnsSkeletonData;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCSkeleton::CCSkeleton () {
|
Skeleton::Skeleton () {
|
||||||
initialize();
|
initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
CCSkeleton::CCSkeleton (spSkeletonData *skeletonData, bool isOwnsSkeletonData) {
|
Skeleton::Skeleton (spSkeletonData *skeletonData, bool isOwnsSkeletonData) {
|
||||||
initialize();
|
initialize();
|
||||||
|
|
||||||
setSkeletonData(skeletonData, isOwnsSkeletonData);
|
setSkeletonData(skeletonData, isOwnsSkeletonData);
|
||||||
}
|
}
|
||||||
|
|
||||||
CCSkeleton::CCSkeleton (const char* skeletonDataFile, spAtlas* aAtlas, float scale) {
|
Skeleton::Skeleton (const char* skeletonDataFile, spAtlas* aAtlas, float scale) {
|
||||||
initialize();
|
initialize();
|
||||||
|
|
||||||
spSkeletonJson* json = spSkeletonJson_create(aAtlas);
|
spSkeletonJson* json = spSkeletonJson_create(aAtlas);
|
||||||
|
@ -101,7 +101,7 @@ CCSkeleton::CCSkeleton (const char* skeletonDataFile, spAtlas* aAtlas, float sca
|
||||||
setSkeletonData(skeletonData, true);
|
setSkeletonData(skeletonData, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
CCSkeleton::CCSkeleton (const char* skeletonDataFile, const char* atlasFile, float scale) {
|
Skeleton::Skeleton (const char* skeletonDataFile, const char* atlasFile, float scale) {
|
||||||
initialize();
|
initialize();
|
||||||
|
|
||||||
atlas = spAtlas_readAtlasFile(atlasFile);
|
atlas = spAtlas_readAtlasFile(atlasFile);
|
||||||
|
@ -116,17 +116,17 @@ CCSkeleton::CCSkeleton (const char* skeletonDataFile, const char* atlasFile, flo
|
||||||
setSkeletonData(skeletonData, true);
|
setSkeletonData(skeletonData, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
CCSkeleton::~CCSkeleton () {
|
Skeleton::~Skeleton () {
|
||||||
if (ownsSkeletonData) spSkeletonData_dispose(skeleton->data);
|
if (ownsSkeletonData) spSkeletonData_dispose(skeleton->data);
|
||||||
if (atlas) spAtlas_dispose(atlas);
|
if (atlas) spAtlas_dispose(atlas);
|
||||||
spSkeleton_dispose(skeleton);
|
spSkeleton_dispose(skeleton);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCSkeleton::update (float deltaTime) {
|
void Skeleton::update (float deltaTime) {
|
||||||
spSkeleton_update(skeleton, deltaTime * timeScale);
|
spSkeleton_update(skeleton, deltaTime * timeScale);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCSkeleton::draw () {
|
void Skeleton::draw () {
|
||||||
CC_NODE_DRAW_SETUP();
|
CC_NODE_DRAW_SETUP();
|
||||||
|
|
||||||
GL::blendFunc(blendFunc.src, blendFunc.dst);
|
GL::blendFunc(blendFunc.src, blendFunc.dst);
|
||||||
|
@ -222,11 +222,11 @@ void CCSkeleton::draw () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureAtlas* CCSkeleton::getTextureAtlas (spRegionAttachment* regionAttachment) const {
|
TextureAtlas* Skeleton::getTextureAtlas (spRegionAttachment* regionAttachment) const {
|
||||||
return (TextureAtlas*)((spAtlasRegion*)regionAttachment->rendererObject)->page->rendererObject;
|
return (TextureAtlas*)((spAtlasRegion*)regionAttachment->rendererObject)->page->rendererObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
Rect CCSkeleton::getBoundingBox () const {
|
Rect Skeleton::getBoundingBox () const {
|
||||||
float minX = FLT_MAX, minY = FLT_MAX, maxX = FLT_MIN, maxY = FLT_MIN;
|
float minX = FLT_MAX, minY = FLT_MAX, maxX = FLT_MIN, maxY = FLT_MIN;
|
||||||
float scaleX = getScaleX();
|
float scaleX = getScaleX();
|
||||||
float scaleY = getScaleY();
|
float scaleY = getScaleY();
|
||||||
|
@ -259,50 +259,50 @@ Rect CCSkeleton::getBoundingBox () const {
|
||||||
|
|
||||||
// --- Convenience methods for Skeleton_* functions.
|
// --- Convenience methods for Skeleton_* functions.
|
||||||
|
|
||||||
void CCSkeleton::updateWorldTransform () {
|
void Skeleton::updateWorldTransform () {
|
||||||
spSkeleton_updateWorldTransform(skeleton);
|
spSkeleton_updateWorldTransform(skeleton);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCSkeleton::setToSetupPose () {
|
void Skeleton::setToSetupPose () {
|
||||||
spSkeleton_setToSetupPose(skeleton);
|
spSkeleton_setToSetupPose(skeleton);
|
||||||
}
|
}
|
||||||
void CCSkeleton::setBonesToSetupPose () {
|
void Skeleton::setBonesToSetupPose () {
|
||||||
spSkeleton_setBonesToSetupPose(skeleton);
|
spSkeleton_setBonesToSetupPose(skeleton);
|
||||||
}
|
}
|
||||||
void CCSkeleton::setSlotsToSetupPose () {
|
void Skeleton::setSlotsToSetupPose () {
|
||||||
spSkeleton_setSlotsToSetupPose(skeleton);
|
spSkeleton_setSlotsToSetupPose(skeleton);
|
||||||
}
|
}
|
||||||
|
|
||||||
spBone* CCSkeleton::findBone (const char* boneName) const {
|
spBone* Skeleton::findBone (const char* boneName) const {
|
||||||
return spSkeleton_findBone(skeleton, boneName);
|
return spSkeleton_findBone(skeleton, boneName);
|
||||||
}
|
}
|
||||||
|
|
||||||
spSlot* CCSkeleton::findSlot (const char* slotName) const {
|
spSlot* Skeleton::findSlot (const char* slotName) const {
|
||||||
return spSkeleton_findSlot(skeleton, slotName);
|
return spSkeleton_findSlot(skeleton, slotName);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CCSkeleton::setSkin (const char* skinName) {
|
bool Skeleton::setSkin (const char* skinName) {
|
||||||
return spSkeleton_setSkinByName(skeleton, skinName) ? true : false;
|
return spSkeleton_setSkinByName(skeleton, skinName) ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
spAttachment* CCSkeleton::getAttachment (const char* slotName, const char* attachmentName) const {
|
spAttachment* Skeleton::getAttachment (const char* slotName, const char* attachmentName) const {
|
||||||
return spSkeleton_getAttachmentForSlotName(skeleton, slotName, attachmentName);
|
return spSkeleton_getAttachmentForSlotName(skeleton, slotName, attachmentName);
|
||||||
}
|
}
|
||||||
bool CCSkeleton::setAttachment (const char* slotName, const char* attachmentName) {
|
bool Skeleton::setAttachment (const char* slotName, const char* attachmentName) {
|
||||||
return spSkeleton_setAttachment(skeleton, slotName, attachmentName) ? true : false;
|
return spSkeleton_setAttachment(skeleton, slotName, attachmentName) ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- CCBlendProtocol
|
// --- CCBlendProtocol
|
||||||
|
|
||||||
const cocos2d::BlendFunc& CCSkeleton::getBlendFunc () const {
|
const cocos2d::BlendFunc& Skeleton::getBlendFunc () const {
|
||||||
return blendFunc;
|
return blendFunc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCSkeleton::setBlendFunc (const cocos2d::BlendFunc& aBlendFunc) {
|
void Skeleton::setBlendFunc (const cocos2d::BlendFunc& aBlendFunc) {
|
||||||
this->blendFunc = aBlendFunc;
|
this->blendFunc = aBlendFunc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCSkeleton::setFittedBlendingFunc(cocos2d::TextureAtlas * nextRenderedTexture)
|
void Skeleton::setFittedBlendingFunc(cocos2d::TextureAtlas * nextRenderedTexture)
|
||||||
{
|
{
|
||||||
if(nextRenderedTexture->getTexture() && nextRenderedTexture->getTexture()->hasPremultipliedAlpha())
|
if(nextRenderedTexture->getTexture() && nextRenderedTexture->getTexture()->hasPremultipliedAlpha())
|
||||||
{
|
{
|
||||||
|
|
|
@ -42,7 +42,7 @@ namespace spine {
|
||||||
/**
|
/**
|
||||||
Draws a skeleton.
|
Draws a skeleton.
|
||||||
*/
|
*/
|
||||||
class CCSkeleton: public cocos2d::Node, public cocos2d::BlendProtocol {
|
class Skeleton: public cocos2d::Node, public cocos2d::BlendProtocol {
|
||||||
public:
|
public:
|
||||||
spSkeleton* skeleton;
|
spSkeleton* skeleton;
|
||||||
spBone* rootBone;
|
spBone* rootBone;
|
||||||
|
@ -52,15 +52,15 @@ public:
|
||||||
bool premultipliedAlpha;
|
bool premultipliedAlpha;
|
||||||
cocos2d::BlendFunc blendFunc;
|
cocos2d::BlendFunc blendFunc;
|
||||||
|
|
||||||
static CCSkeleton* createWithData (spSkeletonData* skeletonData, bool ownsSkeletonData = false);
|
static Skeleton* createWithData (spSkeletonData* skeletonData, bool ownsSkeletonData = false);
|
||||||
static CCSkeleton* createWithFile (const char* skeletonDataFile, spAtlas* atlas, float scale = 0);
|
static Skeleton* createWithFile (const char* skeletonDataFile, spAtlas* atlas, float scale = 0);
|
||||||
static CCSkeleton* createWithFile (const char* skeletonDataFile, const char* atlasFile, float scale = 0);
|
static Skeleton* createWithFile (const char* skeletonDataFile, const char* atlasFile, float scale = 0);
|
||||||
|
|
||||||
CCSkeleton (spSkeletonData* skeletonData, bool ownsSkeletonData = false);
|
Skeleton (spSkeletonData* skeletonData, bool ownsSkeletonData = false);
|
||||||
CCSkeleton (const char* skeletonDataFile, spAtlas* atlas, float scale = 0);
|
Skeleton (const char* skeletonDataFile, spAtlas* atlas, float scale = 0);
|
||||||
CCSkeleton (const char* skeletonDataFile, const char* atlasFile, float scale = 0);
|
Skeleton (const char* skeletonDataFile, const char* atlasFile, float scale = 0);
|
||||||
|
|
||||||
virtual ~CCSkeleton ();
|
virtual ~Skeleton ();
|
||||||
|
|
||||||
virtual void update (float deltaTime) override;
|
virtual void update (float deltaTime) override;
|
||||||
virtual void draw() override;
|
virtual void draw() override;
|
||||||
|
@ -93,7 +93,7 @@ public:
|
||||||
virtual void setBlendFunc(const cocos2d::BlendFunc& func) override;
|
virtual void setBlendFunc(const cocos2d::BlendFunc& func) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CCSkeleton ();
|
Skeleton ();
|
||||||
void setSkeletonData (spSkeletonData* skeletonData, bool ownsSkeletonData);
|
void setSkeletonData (spSkeletonData* skeletonData, bool ownsSkeletonData);
|
||||||
virtual cocos2d::TextureAtlas* getTextureAtlas (spRegionAttachment* regionAttachment) const;
|
virtual cocos2d::TextureAtlas* getTextureAtlas (spRegionAttachment* regionAttachment) const;
|
||||||
|
|
||||||
|
|
|
@ -43,28 +43,28 @@ using std::vector;
|
||||||
namespace spine {
|
namespace spine {
|
||||||
|
|
||||||
static void callback (spAnimationState* state, int trackIndex, spEventType type, spEvent* event, int loopCount) {
|
static void callback (spAnimationState* state, int trackIndex, spEventType type, spEvent* event, int loopCount) {
|
||||||
((CCSkeletonAnimation*)state->context)->onAnimationStateEvent(trackIndex, type, event, loopCount);
|
((SkeletonAnimation*)state->context)->onAnimationStateEvent(trackIndex, type, event, loopCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
CCSkeletonAnimation* CCSkeletonAnimation::createWithData (spSkeletonData* skeletonData) {
|
SkeletonAnimation* SkeletonAnimation::createWithData (spSkeletonData* skeletonData) {
|
||||||
CCSkeletonAnimation* node = new CCSkeletonAnimation(skeletonData);
|
SkeletonAnimation* node = new SkeletonAnimation(skeletonData);
|
||||||
node->autorelease();
|
node->autorelease();
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCSkeletonAnimation* CCSkeletonAnimation::createWithFile (const char* skeletonDataFile, spAtlas* atlas, float scale) {
|
SkeletonAnimation* SkeletonAnimation::createWithFile (const char* skeletonDataFile, spAtlas* atlas, float scale) {
|
||||||
CCSkeletonAnimation* node = new CCSkeletonAnimation(skeletonDataFile, atlas, scale);
|
SkeletonAnimation* node = new SkeletonAnimation(skeletonDataFile, atlas, scale);
|
||||||
node->autorelease();
|
node->autorelease();
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCSkeletonAnimation* CCSkeletonAnimation::createWithFile (const char* skeletonDataFile, const char* atlasFile, float scale) {
|
SkeletonAnimation* SkeletonAnimation::createWithFile (const char* skeletonDataFile, const char* atlasFile, float scale) {
|
||||||
CCSkeletonAnimation* node = new CCSkeletonAnimation(skeletonDataFile, atlasFile, scale);
|
SkeletonAnimation* node = new SkeletonAnimation(skeletonDataFile, atlasFile, scale);
|
||||||
node->autorelease();
|
node->autorelease();
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCSkeletonAnimation::initialize () {
|
void SkeletonAnimation::initialize () {
|
||||||
listenerInstance = 0;
|
listenerInstance = 0;
|
||||||
listenerMethod = 0;
|
listenerMethod = 0;
|
||||||
|
|
||||||
|
@ -74,27 +74,27 @@ void CCSkeletonAnimation::initialize () {
|
||||||
state->listener = callback;
|
state->listener = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCSkeletonAnimation::CCSkeletonAnimation (spSkeletonData *skeletonData)
|
SkeletonAnimation::SkeletonAnimation (spSkeletonData *skeletonData)
|
||||||
: CCSkeleton(skeletonData) {
|
: Skeleton(skeletonData) {
|
||||||
initialize();
|
initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
CCSkeletonAnimation::CCSkeletonAnimation (const char* skeletonDataFile, spAtlas* atlas, float scale)
|
SkeletonAnimation::SkeletonAnimation (const char* skeletonDataFile, spAtlas* atlas, float scale)
|
||||||
: CCSkeleton(skeletonDataFile, atlas, scale) {
|
: Skeleton(skeletonDataFile, atlas, scale) {
|
||||||
initialize();
|
initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
CCSkeletonAnimation::CCSkeletonAnimation (const char* skeletonDataFile, const char* atlasFile, float scale)
|
SkeletonAnimation::SkeletonAnimation (const char* skeletonDataFile, const char* atlasFile, float scale)
|
||||||
: CCSkeleton(skeletonDataFile, atlasFile, scale) {
|
: Skeleton(skeletonDataFile, atlasFile, scale) {
|
||||||
initialize();
|
initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
CCSkeletonAnimation::~CCSkeletonAnimation () {
|
SkeletonAnimation::~SkeletonAnimation () {
|
||||||
if (ownsAnimationStateData) spAnimationStateData_dispose(state->data);
|
if (ownsAnimationStateData) spAnimationStateData_dispose(state->data);
|
||||||
spAnimationState_dispose(state);
|
spAnimationState_dispose(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCSkeletonAnimation::update (float deltaTime) {
|
void SkeletonAnimation::update (float deltaTime) {
|
||||||
super::update(deltaTime);
|
super::update(deltaTime);
|
||||||
|
|
||||||
deltaTime *= timeScale;
|
deltaTime *= timeScale;
|
||||||
|
@ -103,7 +103,7 @@ void CCSkeletonAnimation::update (float deltaTime) {
|
||||||
spSkeleton_updateWorldTransform(skeleton);
|
spSkeleton_updateWorldTransform(skeleton);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCSkeletonAnimation::setAnimationStateData (spAnimationStateData* stateData) {
|
void SkeletonAnimation::setAnimationStateData (spAnimationStateData* stateData) {
|
||||||
CCAssert(stateData, "stateData cannot be null.");
|
CCAssert(stateData, "stateData cannot be null.");
|
||||||
|
|
||||||
if (ownsAnimationStateData) spAnimationStateData_dispose(state->data);
|
if (ownsAnimationStateData) spAnimationStateData_dispose(state->data);
|
||||||
|
@ -115,46 +115,46 @@ void CCSkeletonAnimation::setAnimationStateData (spAnimationStateData* stateData
|
||||||
state->listener = callback;
|
state->listener = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCSkeletonAnimation::setMix (const char* fromAnimation, const char* toAnimation, float duration) {
|
void SkeletonAnimation::setMix (const char* fromAnimation, const char* toAnimation, float duration) {
|
||||||
spAnimationStateData_setMixByName(state->data, fromAnimation, toAnimation, duration);
|
spAnimationStateData_setMixByName(state->data, fromAnimation, toAnimation, duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCSkeletonAnimation::setAnimationListener (Object* instance, SEL_AnimationStateEvent method) {
|
void SkeletonAnimation::setAnimationListener (Object* instance, SEL_AnimationStateEvent method) {
|
||||||
listenerInstance = instance;
|
listenerInstance = instance;
|
||||||
listenerMethod = method;
|
listenerMethod = method;
|
||||||
}
|
}
|
||||||
|
|
||||||
spTrackEntry* CCSkeletonAnimation::setAnimation (int trackIndex, const char* name, bool loop) {
|
spTrackEntry* SkeletonAnimation::setAnimation (int trackIndex, const char* name, bool loop) {
|
||||||
spAnimation* animation = spSkeletonData_findAnimation(skeleton->data, name);
|
spAnimation* animation = spSkeletonData_findAnimation(skeleton->data, name);
|
||||||
if (!animation) {
|
if (!animation) {
|
||||||
CCLog("Spine: Animation not found: %s", name);
|
log("Spine: Animation not found: %s", name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return spAnimationState_setAnimation(state, trackIndex, animation, loop);
|
return spAnimationState_setAnimation(state, trackIndex, animation, loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
spTrackEntry* CCSkeletonAnimation::addAnimation (int trackIndex, const char* name, bool loop, float delay) {
|
spTrackEntry* SkeletonAnimation::addAnimation (int trackIndex, const char* name, bool loop, float delay) {
|
||||||
spAnimation* animation = spSkeletonData_findAnimation(skeleton->data, name);
|
spAnimation* animation = spSkeletonData_findAnimation(skeleton->data, name);
|
||||||
if (!animation) {
|
if (!animation) {
|
||||||
CCLog("Spine: Animation not found: %s", name);
|
log("Spine: Animation not found: %s", name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return spAnimationState_addAnimation(state, trackIndex, animation, loop, delay);
|
return spAnimationState_addAnimation(state, trackIndex, animation, loop, delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
spTrackEntry* CCSkeletonAnimation::getCurrent (int trackIndex) {
|
spTrackEntry* SkeletonAnimation::getCurrent (int trackIndex) {
|
||||||
return spAnimationState_getCurrent(state, trackIndex);
|
return spAnimationState_getCurrent(state, trackIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCSkeletonAnimation::clearTracks () {
|
void SkeletonAnimation::clearTracks () {
|
||||||
spAnimationState_clearTracks(state);
|
spAnimationState_clearTracks(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCSkeletonAnimation::clearTrack (int trackIndex) {
|
void SkeletonAnimation::clearTrack (int trackIndex) {
|
||||||
spAnimationState_clearTrack(state, trackIndex);
|
spAnimationState_clearTrack(state, trackIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCSkeletonAnimation::onAnimationStateEvent (int trackIndex, spEventType type, spEvent* event, int loopCount) {
|
void SkeletonAnimation::onAnimationStateEvent (int trackIndex, spEventType type, spEvent* event, int loopCount) {
|
||||||
if (listenerInstance) (listenerInstance->*listenerMethod)(this, trackIndex, type, event, loopCount);
|
if (listenerInstance) (listenerInstance->*listenerMethod)(this, trackIndex, type, event, loopCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,25 +40,25 @@
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
|
|
||||||
class CCSkeletonAnimation;
|
class SkeletonAnimation;
|
||||||
typedef void (cocos2d::Object::*SEL_AnimationStateEvent)(spine::CCSkeletonAnimation* node, int trackIndex, spEventType type, spEvent* event, int loopCount);
|
typedef void (cocos2d::Object::*SEL_AnimationStateEvent)(spine::SkeletonAnimation* node, int trackIndex, spEventType type, spEvent* event, int loopCount);
|
||||||
#define animationStateEvent_selector(_SELECTOR) (SEL_AnimationStateEvent)(&_SELECTOR)
|
#define animationStateEvent_selector(_SELECTOR) (SEL_AnimationStateEvent)(&_SELECTOR)
|
||||||
|
|
||||||
/** Draws an animated skeleton, providing an AnimationState for applying one or more animations and queuing animations to be
|
/** Draws an animated skeleton, providing an AnimationState for applying one or more animations and queuing animations to be
|
||||||
* played later. */
|
* played later. */
|
||||||
class CCSkeletonAnimation: public CCSkeleton {
|
class SkeletonAnimation: public Skeleton {
|
||||||
public:
|
public:
|
||||||
spAnimationState* state;
|
spAnimationState* state;
|
||||||
|
|
||||||
static CCSkeletonAnimation* createWithData (spSkeletonData* skeletonData);
|
static SkeletonAnimation* createWithData (spSkeletonData* skeletonData);
|
||||||
static CCSkeletonAnimation* createWithFile (const char* skeletonDataFile, spAtlas* atlas, float scale = 0);
|
static SkeletonAnimation* createWithFile (const char* skeletonDataFile, spAtlas* atlas, float scale = 0);
|
||||||
static CCSkeletonAnimation* createWithFile (const char* skeletonDataFile, const char* atlasFile, float scale = 0);
|
static SkeletonAnimation* createWithFile (const char* skeletonDataFile, const char* atlasFile, float scale = 0);
|
||||||
|
|
||||||
CCSkeletonAnimation (spSkeletonData* skeletonData);
|
SkeletonAnimation (spSkeletonData* skeletonData);
|
||||||
CCSkeletonAnimation (const char* skeletonDataFile, spAtlas* atlas, float scale = 0);
|
SkeletonAnimation (const char* skeletonDataFile, spAtlas* atlas, float scale = 0);
|
||||||
CCSkeletonAnimation (const char* skeletonDataFile, const char* atlasFile, float scale = 0);
|
SkeletonAnimation (const char* skeletonDataFile, const char* atlasFile, float scale = 0);
|
||||||
|
|
||||||
virtual ~CCSkeletonAnimation ();
|
virtual ~SkeletonAnimation ();
|
||||||
|
|
||||||
virtual void update (float deltaTime);
|
virtual void update (float deltaTime);
|
||||||
|
|
||||||
|
@ -75,10 +75,10 @@ public:
|
||||||
virtual void onAnimationStateEvent (int trackIndex, spEventType type, spEvent* event, int loopCount);
|
virtual void onAnimationStateEvent (int trackIndex, spEventType type, spEvent* event, int loopCount);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CCSkeletonAnimation ();
|
SkeletonAnimation ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef CCSkeleton super;
|
typedef Skeleton super;
|
||||||
cocos2d::Object* listenerInstance;
|
cocos2d::Object* listenerInstance;
|
||||||
SEL_AnimationStateEvent listenerMethod;
|
SEL_AnimationStateEvent listenerMethod;
|
||||||
bool ownsAnimationStateData;
|
bool ownsAnimationStateData;
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 46d0b761304efa3f22b768aaa61577a99a82c02d
|
Subproject commit 2f60892e1053a2e7dabfbab9da1058063475eb97
|
|
@ -49,7 +49,7 @@ void SpineTestScene::runThisTest()
|
||||||
bool SpineTestLayer::init () {
|
bool SpineTestLayer::init () {
|
||||||
if (!Layer::init()) return false;
|
if (!Layer::init()) return false;
|
||||||
|
|
||||||
skeletonNode = CCSkeletonAnimation::createWithFile("spine/spineboy.json", "spine/spineboy.atlas");
|
skeletonNode = SkeletonAnimation::createWithFile("spine/spineboy.json", "spine/spineboy.atlas");
|
||||||
skeletonNode->setMix("walk", "jump", 0.2f);
|
skeletonNode->setMix("walk", "jump", 0.2f);
|
||||||
skeletonNode->setMix("jump", "walk", 0.4f);
|
skeletonNode->setMix("jump", "walk", 0.4f);
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ void SpineTestLayer::update (float deltaTime) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpineTestLayer::animationStateEvent (CCSkeletonAnimation* node, int trackIndex, spEventType type, spEvent* event, int loopCount) {
|
void SpineTestLayer::animationStateEvent (SkeletonAnimation* node, int trackIndex, spEventType type, spEvent* event, int loopCount) {
|
||||||
spTrackEntry* entry = spAnimationState_getCurrent(node->state, trackIndex);
|
spTrackEntry* entry = spAnimationState_getCurrent(node->state, trackIndex);
|
||||||
const char* animationName = (entry && entry->animation) ? entry->animation->name : 0;
|
const char* animationName = (entry && entry->animation) ? entry->animation->name : 0;
|
||||||
|
|
||||||
|
|
|
@ -38,13 +38,13 @@ public:
|
||||||
|
|
||||||
class SpineTestLayer: public cocos2d::Layer {
|
class SpineTestLayer: public cocos2d::Layer {
|
||||||
private:
|
private:
|
||||||
spine::CCSkeletonAnimation* skeletonNode;
|
spine::SkeletonAnimation* skeletonNode;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual bool init ();
|
virtual bool init ();
|
||||||
virtual void update (float deltaTime);
|
virtual void update (float deltaTime);
|
||||||
void animationStateEvent (spine::CCSkeletonAnimation* node, int trackIndex, spEventType type, spEvent* event, int loopCount);
|
void animationStateEvent (spine::SkeletonAnimation* node, int trackIndex, spEventType type, spEvent* event, int loopCount);
|
||||||
|
|
||||||
CREATE_FUNC (SpineTestLayer);
|
CREATE_FUNC (SpineTestLayer);
|
||||||
};
|
};
|
||||||
|
|
|
@ -76,7 +76,7 @@
|
||||||
<PrecompiledHeader>
|
<PrecompiledHeader>
|
||||||
</PrecompiledHeader>
|
</PrecompiledHeader>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
<DebugInformationFormat>OldStyle</DebugInformationFormat>
|
||||||
<DisableSpecificWarnings>4267;4251;4244;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
<DisableSpecificWarnings>4267;4251;4244;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit fda861cde4387948e95811966d9c4ceea04dc758
|
Subproject commit ff3a95b059be8421677ed6817b73ae2ac577781d
|
|
@ -1,7 +1,7 @@
|
||||||
[cocos2dx_spine]
|
[cocos2dx_spine]
|
||||||
prefix = cocos2dx_spine
|
prefix = cocos2dx_spine
|
||||||
|
|
||||||
target_namespace = cc
|
target_namespace = sp
|
||||||
|
|
||||||
android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include
|
android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include
|
||||||
android_flags = -D_SIZE_T_DEFINED_
|
android_flags = -D_SIZE_T_DEFINED_
|
||||||
|
@ -20,12 +20,12 @@ extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s
|
||||||
|
|
||||||
headers = %(cocosdir)s/cocos/editor-support/spine/spine-cocos2dx.h
|
headers = %(cocosdir)s/cocos/editor-support/spine/spine-cocos2dx.h
|
||||||
|
|
||||||
skip = CCSkeleton::[createWithData],
|
skip = Skeleton::[createWithData],
|
||||||
CCSkeletonAnimation::[createWithData]
|
SkeletonAnimation::[createWithData]
|
||||||
|
|
||||||
classes = CCSkeleton CCSkeletonAnimation
|
classes = Skeleton SkeletonAnimation
|
||||||
|
|
||||||
remove_prefix = CC
|
remove_prefix =
|
||||||
|
|
||||||
classes_have_no_parents =
|
classes_have_no_parents =
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue