mirror of https://github.com/axmolengine/axmol.git
commit
cd24f91014
1
AUTHORS
1
AUTHORS
|
@ -820,6 +820,7 @@ Developers:
|
|||
|
||||
aeonmine
|
||||
Fixed ActionObject memory leak in ActionManagerEx::initWithDictionary
|
||||
Fixed memory leak in cocos studiov2.0 reader
|
||||
|
||||
LoungeKatt
|
||||
Corrected a mistake of building android project in README.md
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
cocos2d-x-3.3 ??
|
||||
[NEW] Vec2: added greater than operator
|
||||
|
||||
[FIX] Button: when the dimension of button title is larger than the button, button will scale to fit the dimension of the button title
|
||||
[FIX] Button: when the dimension of button title is larger than the button, button will scale to fit the dimension of the button title
|
||||
[FIX] Camera: does not work correctly when the up is not (0, 1, 0)
|
||||
[FIX] Cocos console: compile failure on windows if using VS express version
|
||||
|
@ -9,7 +10,8 @@ cocos2d-x-3.3 ??
|
|||
[FIX] GLProgramState: enabled GLProgramState restoring on render recreated on WP8
|
||||
[FIX] Label: label shifting when outline feature enabled
|
||||
[FIX] Label: when applying additionalKerning to a Label that displays a string with only 1 character, the character is shifted
|
||||
[FIX] Button: when the dimension of button title is larger than the button, button will scale to fit the dimension of the button title
|
||||
[FIX] Scale9Sprite: will be flipped if both flipX and flipY are false
|
||||
[FIX] Scale9Sprite: if scale and flip property are set at the same time, the result would be wrong.
|
||||
[FIX] Sprite3D: did not create attached sprite from cache
|
||||
[FIX] WP/WinRT: Windows 8.1 universal app support; `UIEditBox` support
|
||||
|
||||
|
|
|
@ -733,11 +733,15 @@ ActionTimeline* ActionTimelineCache::loadAnimationActionWithFileFromXML(const st
|
|||
// xml read
|
||||
std::string fullpath = FileUtils::getInstance()->fullPathForFilename(fileName).c_str();
|
||||
ssize_t size;
|
||||
std::string content =(char*)FileUtils::getInstance()->getFileData(fullpath, "r", &size);
|
||||
|
||||
//fix memory leak for v3.3
|
||||
unsigned char* pByte = FileUtils::getInstance()->getFileData(fullpath, "r", &size);
|
||||
|
||||
// xml parse
|
||||
tinyxml2::XMLDocument* document = new tinyxml2::XMLDocument();
|
||||
document->Parse(content.c_str());
|
||||
document->Parse((const char*)pByte);
|
||||
|
||||
free(pByte);
|
||||
|
||||
const tinyxml2::XMLElement* rootElement = document->RootElement();// Root
|
||||
CCLOG("rootElement name = %s", rootElement->Name());
|
||||
|
|
|
@ -449,7 +449,8 @@ void CSLoader::initNode(Node* node, const rapidjson::Value& json)
|
|||
Node* CSLoader::loadSimpleNode(const rapidjson::Value& json)
|
||||
{
|
||||
Node* node = Node::create();
|
||||
node->retain();
|
||||
// fix memory leak for v3.3
|
||||
//node->retain();
|
||||
initNode(node, json);
|
||||
|
||||
return node;
|
||||
|
@ -468,8 +469,8 @@ Node* CSLoader::loadSubGraph(const rapidjson::Value& json)
|
|||
{
|
||||
node = Node::create();
|
||||
}
|
||||
|
||||
node->retain();
|
||||
// fix memory leak for v3.3
|
||||
//node->retain();
|
||||
|
||||
initNode(node, json);
|
||||
|
||||
|
@ -507,7 +508,8 @@ Node* CSLoader::loadSprite(const rapidjson::Value& json)
|
|||
sprite = Sprite::create();
|
||||
}
|
||||
|
||||
sprite->retain();
|
||||
// fix memory leak for v3.3
|
||||
//sprite->retain();
|
||||
|
||||
initNode(sprite, json);
|
||||
|
||||
|
@ -529,7 +531,8 @@ Node* CSLoader::loadParticle(const rapidjson::Value& json)
|
|||
|
||||
ParticleSystemQuad* particle = ParticleSystemQuad::create(filePath);
|
||||
particle->setTotalParticles(num);
|
||||
particle->retain();
|
||||
// fix memory leak for v3.3
|
||||
//particle->retain();
|
||||
|
||||
initNode(particle, json);
|
||||
|
||||
|
@ -578,7 +581,8 @@ Node* CSLoader::loadWidget(const rapidjson::Value& json)
|
|||
|
||||
std::string guiClassName = getGUIClassName(classname);
|
||||
widget = dynamic_cast<Widget*>(ObjectFactory::getInstance()->createObject(guiClassName));
|
||||
widget->retain();
|
||||
// fix memory leak for v3.3
|
||||
//widget->retain();
|
||||
|
||||
WidgetReaderProtocol* reader = dynamic_cast<WidgetReaderProtocol*>(ObjectFactory::getInstance()->createObject(readerName));
|
||||
|
||||
|
@ -587,7 +591,9 @@ Node* CSLoader::loadWidget(const rapidjson::Value& json)
|
|||
else if (isCustomWidget(classname))
|
||||
{
|
||||
widget = dynamic_cast<Widget*>(ObjectFactory::getInstance()->createObject(classname));
|
||||
widget->retain();
|
||||
|
||||
//fix memory leak for v3.3
|
||||
//widget->retain();
|
||||
|
||||
//
|
||||
// 1st., custom widget parse properties of parent widget with parent widget reader
|
||||
|
@ -826,7 +832,8 @@ Node* CSLoader::nodeFromProtocolBuffers(const protocolbuffers::NodeTree &nodetre
|
|||
readerName.append("Reader");
|
||||
|
||||
Widget* widget = dynamic_cast<Widget*>(ObjectFactory::getInstance()->createObject(guiClassName));
|
||||
widget->retain();
|
||||
//fix memory leak for v3.3
|
||||
//widget->retain();
|
||||
|
||||
WidgetReaderProtocol* reader = dynamic_cast<WidgetReaderProtocol*>(ObjectFactory::getInstance()->createObject(readerName));
|
||||
reader->setPropsFromProtocolBuffers(widget, nodetree);
|
||||
|
@ -840,7 +847,9 @@ Node* CSLoader::nodeFromProtocolBuffers(const protocolbuffers::NodeTree &nodetre
|
|||
else if (isCustomWidget(classname))
|
||||
{
|
||||
Widget* widget = dynamic_cast<Widget*>(ObjectFactory::getInstance()->createObject(classname));
|
||||
widget->retain();
|
||||
|
||||
//fix memory leak for v3.3
|
||||
//widget->retain();
|
||||
|
||||
//
|
||||
// 1st., custom widget parse properties of parent widget with parent widget reader
|
||||
|
@ -1046,8 +1055,8 @@ void CSLoader::setPropsForSpriteFromProtocolBuffers(cocos2d::Node *node,
|
|||
CCLOG("filePath is empty. Create a sprite with no texture");
|
||||
}
|
||||
*/
|
||||
|
||||
sprite->retain();
|
||||
//fix memory leak for v3.3
|
||||
//sprite->retain();
|
||||
|
||||
setPropsForNodeFromProtocolBuffers(sprite, nodeOptions);
|
||||
|
||||
|
@ -1245,11 +1254,15 @@ Node* CSLoader::nodeFromXMLFile(const std::string &fileName)
|
|||
// xml read
|
||||
std::string fullpath = FileUtils::getInstance()->fullPathForFilename(fileName).c_str();
|
||||
ssize_t size;
|
||||
std::string content =(char*)FileUtils::getInstance()->getFileData(fullpath, "r", &size);
|
||||
|
||||
//fix memory leak for v3.3
|
||||
unsigned char* pByte = FileUtils::getInstance()->getFileData(fullpath, "r", &size);
|
||||
|
||||
// xml parse
|
||||
tinyxml2::XMLDocument* document = new tinyxml2::XMLDocument();
|
||||
document->Parse(content.c_str());
|
||||
document->Parse((const char*)pByte);
|
||||
|
||||
free(pByte);
|
||||
|
||||
const tinyxml2::XMLElement* rootElement = document->RootElement();// Root
|
||||
CCLOG("rootElement name = %s", rootElement->Name());
|
||||
|
@ -1408,7 +1421,9 @@ Node* CSLoader::nodeFromXML(const tinyxml2::XMLElement *objectData, const std::s
|
|||
readerName.append("Reader");
|
||||
|
||||
Widget* widget = dynamic_cast<Widget*>(ObjectFactory::getInstance()->createObject(guiClassName));
|
||||
widget->retain();
|
||||
|
||||
//fix memory leak for v3.3
|
||||
//widget->retain();
|
||||
|
||||
WidgetReaderProtocol* reader = dynamic_cast<WidgetReaderProtocol*>(ObjectFactory::getInstance()->createObject(readerName));
|
||||
reader->setPropsFromXML(widget, objectData);
|
||||
|
|
|
@ -330,7 +330,7 @@ void DataReaderHelper::addDataFromFile(const std::string& filePath)
|
|||
DataReaderHelper::addDataFromBinaryCache(contentStr.c_str(),&dataInfo);
|
||||
}
|
||||
|
||||
CC_SAFE_DELETE_ARRAY(pBytes);
|
||||
free(pBytes);
|
||||
}
|
||||
|
||||
void DataReaderHelper::addDataFromFileAsync(const std::string& imagePath, const std::string& plistPath, const std::string& filePath, Ref *target, SEL_SCHEDULE selector)
|
||||
|
@ -429,7 +429,9 @@ void DataReaderHelper::addDataFromFileAsync(const std::string& imagePath, const
|
|||
Data bytecpy;
|
||||
bytecpy.copy(pBytes, size);
|
||||
data->fileContent = std::string((const char*)bytecpy.getBytes(), size);
|
||||
CC_SAFE_DELETE_ARRAY(pBytes);
|
||||
|
||||
// fix memory leak for v3.3
|
||||
free(pBytes);
|
||||
|
||||
if (str == ".xml")
|
||||
{
|
||||
|
|
|
@ -259,6 +259,30 @@
|
|||
-- @param self
|
||||
-- @param #vec2_table anchorPoint
|
||||
|
||||
--------------------------------
|
||||
--
|
||||
-- @function [parent=#Scale9Sprite] setScaleY
|
||||
-- @param self
|
||||
-- @param #float scaleY
|
||||
|
||||
--------------------------------
|
||||
--
|
||||
-- @function [parent=#Scale9Sprite] setScaleX
|
||||
-- @param self
|
||||
-- @param #float scaleX
|
||||
|
||||
--------------------------------
|
||||
--
|
||||
-- @function [parent=#Scale9Sprite] getScaleY
|
||||
-- @param self
|
||||
-- @return float#float ret (return value: float)
|
||||
|
||||
--------------------------------
|
||||
--
|
||||
-- @function [parent=#Scale9Sprite] getScaleX
|
||||
-- @param self
|
||||
-- @return float#float ret (return value: float)
|
||||
|
||||
--------------------------------
|
||||
--
|
||||
-- @function [parent=#Scale9Sprite] updateDisplayedOpacity
|
||||
|
@ -270,6 +294,14 @@
|
|||
-- @function [parent=#Scale9Sprite] cleanup
|
||||
-- @param self
|
||||
|
||||
--------------------------------
|
||||
-- @overload self, float, float
|
||||
-- @overload self, float
|
||||
-- @function [parent=#Scale9Sprite] setScale
|
||||
-- @param self
|
||||
-- @param #float scalex
|
||||
-- @param #float scaley
|
||||
|
||||
--------------------------------
|
||||
--
|
||||
-- @function [parent=#Scale9Sprite] updateDisplayedColor
|
||||
|
@ -282,6 +314,12 @@
|
|||
-- @param self
|
||||
-- @param #size_table size
|
||||
|
||||
--------------------------------
|
||||
--
|
||||
-- @function [parent=#Scale9Sprite] getScale
|
||||
-- @param self
|
||||
-- @return float#float ret (return value: float)
|
||||
|
||||
--------------------------------
|
||||
-- js ctor
|
||||
-- @function [parent=#Scale9Sprite] Scale9Sprite
|
||||
|
|
|
@ -34,6 +34,12 @@
|
|||
-- @param self
|
||||
-- @return Mesh#Mesh ret (return value: cc.Mesh)
|
||||
|
||||
--------------------------------
|
||||
--
|
||||
-- @function [parent=#Sprite3D] setCullFace
|
||||
-- @param self
|
||||
-- @param #unsigned int cullFace
|
||||
|
||||
--------------------------------
|
||||
-- light mask getter & setter, light works only when _lightmask & light's flag is true, default value of _lightmask is 0xffff
|
||||
-- @function [parent=#Sprite3D] setLightMask
|
||||
|
@ -60,30 +66,24 @@
|
|||
|
||||
--------------------------------
|
||||
--
|
||||
-- @function [parent=#Sprite3D] setCullFace
|
||||
-- @function [parent=#Sprite3D] getSkeleton
|
||||
-- @param self
|
||||
-- @param #unsigned int cullFace
|
||||
-- @return Skeleton3D#Skeleton3D ret (return value: cc.Skeleton3D)
|
||||
|
||||
--------------------------------
|
||||
-- get SubMeshState by index
|
||||
-- get Mesh by index
|
||||
-- @function [parent=#Sprite3D] getMeshByIndex
|
||||
-- @param self
|
||||
-- @param #int index
|
||||
-- @return Mesh#Mesh ret (return value: cc.Mesh)
|
||||
|
||||
--------------------------------
|
||||
-- get SubMeshState by Name
|
||||
-- get Mesh by Name, it returns the first one if there are more than one mesh with the same name
|
||||
-- @function [parent=#Sprite3D] getMeshByName
|
||||
-- @param self
|
||||
-- @param #string name
|
||||
-- @return Mesh#Mesh ret (return value: cc.Mesh)
|
||||
|
||||
--------------------------------
|
||||
--
|
||||
-- @function [parent=#Sprite3D] getSkeleton
|
||||
-- @param self
|
||||
-- @return Skeleton3D#Skeleton3D ret (return value: cc.Skeleton3D)
|
||||
|
||||
--------------------------------
|
||||
-- get AttachNode by bone name, return nullptr if not exist
|
||||
-- @function [parent=#Sprite3D] getAttachNode
|
||||
|
|
|
@ -580,6 +580,52 @@ int lua_cocos2dx_3d_Sprite3D_getMesh(lua_State* tolua_S)
|
|||
|
||||
return 0;
|
||||
}
|
||||
int lua_cocos2dx_3d_Sprite3D_setCullFace(lua_State* tolua_S)
|
||||
{
|
||||
int argc = 0;
|
||||
cocos2d::Sprite3D* cobj = nullptr;
|
||||
bool ok = true;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
#endif
|
||||
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isusertype(tolua_S,1,"cc.Sprite3D",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
cobj = (cocos2d::Sprite3D*)tolua_tousertype(tolua_S,1,0);
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!cobj)
|
||||
{
|
||||
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Sprite3D_setCullFace'", nullptr);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(tolua_S)-1;
|
||||
if (argc == 1)
|
||||
{
|
||||
unsigned int arg0;
|
||||
|
||||
ok &= luaval_to_uint32(tolua_S, 2,&arg0, "cc.Sprite3D:setCullFace");
|
||||
if(!ok)
|
||||
return 0;
|
||||
cobj->setCullFace(arg0);
|
||||
return 0;
|
||||
}
|
||||
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.Sprite3D:setCullFace",argc, 1);
|
||||
return 0;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3D_setCullFace'.",&tolua_err);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
int lua_cocos2dx_3d_Sprite3D_setLightMask(lua_State* tolua_S)
|
||||
{
|
||||
int argc = 0;
|
||||
|
@ -760,7 +806,7 @@ int lua_cocos2dx_3d_Sprite3D_removeAttachNode(lua_State* tolua_S)
|
|||
|
||||
return 0;
|
||||
}
|
||||
int lua_cocos2dx_3d_Sprite3D_setCullFace(lua_State* tolua_S)
|
||||
int lua_cocos2dx_3d_Sprite3D_getSkeleton(lua_State* tolua_S)
|
||||
{
|
||||
int argc = 0;
|
||||
cocos2d::Sprite3D* cobj = nullptr;
|
||||
|
@ -780,28 +826,26 @@ int lua_cocos2dx_3d_Sprite3D_setCullFace(lua_State* tolua_S)
|
|||
#if COCOS2D_DEBUG >= 1
|
||||
if (!cobj)
|
||||
{
|
||||
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Sprite3D_setCullFace'", nullptr);
|
||||
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Sprite3D_getSkeleton'", nullptr);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(tolua_S)-1;
|
||||
if (argc == 1)
|
||||
if (argc == 0)
|
||||
{
|
||||
unsigned int arg0;
|
||||
|
||||
ok &= luaval_to_uint32(tolua_S, 2,&arg0, "cc.Sprite3D:setCullFace");
|
||||
if(!ok)
|
||||
return 0;
|
||||
cobj->setCullFace(arg0);
|
||||
return 0;
|
||||
cocos2d::Skeleton3D* ret = cobj->getSkeleton();
|
||||
object_to_luaval<cocos2d::Skeleton3D>(tolua_S, "cc.Skeleton3D",(cocos2d::Skeleton3D*)ret);
|
||||
return 1;
|
||||
}
|
||||
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.Sprite3D:setCullFace",argc, 1);
|
||||
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.Sprite3D:getSkeleton",argc, 0);
|
||||
return 0;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3D_setCullFace'.",&tolua_err);
|
||||
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3D_getSkeleton'.",&tolua_err);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
@ -900,50 +944,6 @@ int lua_cocos2dx_3d_Sprite3D_getMeshByName(lua_State* tolua_S)
|
|||
|
||||
return 0;
|
||||
}
|
||||
int lua_cocos2dx_3d_Sprite3D_getSkeleton(lua_State* tolua_S)
|
||||
{
|
||||
int argc = 0;
|
||||
cocos2d::Sprite3D* cobj = nullptr;
|
||||
bool ok = true;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
#endif
|
||||
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isusertype(tolua_S,1,"cc.Sprite3D",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
cobj = (cocos2d::Sprite3D*)tolua_tousertype(tolua_S,1,0);
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!cobj)
|
||||
{
|
||||
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Sprite3D_getSkeleton'", nullptr);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(tolua_S)-1;
|
||||
if (argc == 0)
|
||||
{
|
||||
if(!ok)
|
||||
return 0;
|
||||
cocos2d::Skeleton3D* ret = cobj->getSkeleton();
|
||||
object_to_luaval<cocos2d::Skeleton3D>(tolua_S, "cc.Skeleton3D",(cocos2d::Skeleton3D*)ret);
|
||||
return 1;
|
||||
}
|
||||
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.Sprite3D:getSkeleton",argc, 0);
|
||||
return 0;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3D_getSkeleton'.",&tolua_err);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
int lua_cocos2dx_3d_Sprite3D_getAttachNode(lua_State* tolua_S)
|
||||
{
|
||||
int argc = 0;
|
||||
|
@ -1059,14 +1059,14 @@ int lua_register_cocos2dx_3d_Sprite3D(lua_State* tolua_S)
|
|||
tolua_function(tolua_S,"getLightMask",lua_cocos2dx_3d_Sprite3D_getLightMask);
|
||||
tolua_function(tolua_S,"removeAllAttachNode",lua_cocos2dx_3d_Sprite3D_removeAllAttachNode);
|
||||
tolua_function(tolua_S,"getMesh",lua_cocos2dx_3d_Sprite3D_getMesh);
|
||||
tolua_function(tolua_S,"setCullFace",lua_cocos2dx_3d_Sprite3D_setCullFace);
|
||||
tolua_function(tolua_S,"setLightMask",lua_cocos2dx_3d_Sprite3D_setLightMask);
|
||||
tolua_function(tolua_S,"getBlendFunc",lua_cocos2dx_3d_Sprite3D_getBlendFunc);
|
||||
tolua_function(tolua_S,"getMeshCount",lua_cocos2dx_3d_Sprite3D_getMeshCount);
|
||||
tolua_function(tolua_S,"removeAttachNode",lua_cocos2dx_3d_Sprite3D_removeAttachNode);
|
||||
tolua_function(tolua_S,"setCullFace",lua_cocos2dx_3d_Sprite3D_setCullFace);
|
||||
tolua_function(tolua_S,"getSkeleton",lua_cocos2dx_3d_Sprite3D_getSkeleton);
|
||||
tolua_function(tolua_S,"getMeshByIndex",lua_cocos2dx_3d_Sprite3D_getMeshByIndex);
|
||||
tolua_function(tolua_S,"getMeshByName",lua_cocos2dx_3d_Sprite3D_getMeshByName);
|
||||
tolua_function(tolua_S,"getSkeleton",lua_cocos2dx_3d_Sprite3D_getSkeleton);
|
||||
tolua_function(tolua_S,"getAttachNode",lua_cocos2dx_3d_Sprite3D_getAttachNode);
|
||||
tolua_function(tolua_S,"create", lua_cocos2dx_3d_Sprite3D_create);
|
||||
tolua_endmodule(tolua_S);
|
||||
|
|
|
@ -773,7 +773,7 @@ int LuaStack::luaLoadChunksFromZIP(lua_State *L)
|
|||
(unsigned char*)stack->_xxteaKey,
|
||||
(xxtea_long)stack->_xxteaKeyLen,
|
||||
&len);
|
||||
delete []zipFileData;
|
||||
free(zipFileData);
|
||||
zipFileData = nullptr;
|
||||
zip = ZipFile::createWithBuffer(buffer, len);
|
||||
} else {
|
||||
|
@ -797,7 +797,7 @@ int LuaStack::luaLoadChunksFromZIP(lua_State *L)
|
|||
lua_setfield(L, -2, filename.c_str());
|
||||
++count;
|
||||
}
|
||||
delete []zbuffer;
|
||||
free(zbuffer);
|
||||
}
|
||||
filename = zip->getNextFilename();
|
||||
}
|
||||
|
@ -812,7 +812,7 @@ int LuaStack::luaLoadChunksFromZIP(lua_State *L)
|
|||
}
|
||||
|
||||
if (zipFileData) {
|
||||
delete []zipFileData;
|
||||
free(zipFileData);
|
||||
}
|
||||
|
||||
if (buffer) {
|
||||
|
|
|
@ -108,7 +108,7 @@ extern "C"
|
|||
{
|
||||
LuaStack* stack = LuaEngine::getInstance()->getLuaStack();
|
||||
stack->luaLoadBuffer(L, (char*)chunk, (int)chunkSize, chunkName.c_str());
|
||||
delete []chunk;
|
||||
free(chunk);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -102,14 +102,14 @@ void LoadingBar::setDirection(cocos2d::ui::LoadingBar::Direction direction)
|
|||
_barRenderer->setAnchorPoint(Vec2(0.0f,0.5f));
|
||||
_barRenderer->setPosition(Vec2(0,_contentSize.height*0.5f));
|
||||
if (!_scale9Enabled) {
|
||||
_barRenderer->setFlippedX(false);
|
||||
_barRenderer->getSprite()->setFlippedX(false);
|
||||
}
|
||||
break;
|
||||
case Direction::RIGHT:
|
||||
_barRenderer->setAnchorPoint(Vec2(1.0f,0.5f));
|
||||
_barRenderer->setPosition(Vec2(_totalLength,_contentSize.height*0.5f));
|
||||
if (!_scale9Enabled) {
|
||||
_barRenderer->setFlippedX(true);
|
||||
_barRenderer->getSprite()->setFlippedX(true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -50,6 +50,9 @@ namespace ui {
|
|||
, _insetTop(0)
|
||||
, _insetRight(0)
|
||||
, _insetBottom(0)
|
||||
,_flippedX(false)
|
||||
,_flippedY(false)
|
||||
|
||||
{
|
||||
this->setAnchorPoint(Vec2(0.5,0.5));
|
||||
}
|
||||
|
@ -1021,6 +1024,9 @@ y+=ytranslate; \
|
|||
this->cleanupSlicedSprites();
|
||||
_protectedChildren.clear();
|
||||
|
||||
//we must invalide the transform when toggling scale9enabled
|
||||
_transformUpdated = _transformDirty = _inverseDirty = true;
|
||||
|
||||
if (_scale9Enabled)
|
||||
{
|
||||
if (_scale9Image)
|
||||
|
@ -1208,34 +1214,17 @@ y+=ytranslate; \
|
|||
|
||||
void Scale9Sprite::setFlippedX(bool flippedX)
|
||||
{
|
||||
|
||||
float realScale = this->getScaleX();
|
||||
_flippedX = flippedX;
|
||||
if (_scale9Enabled)
|
||||
{
|
||||
this->setScaleX(-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_scale9Image)
|
||||
{
|
||||
_scale9Image->setFlippedX(flippedX);
|
||||
}
|
||||
}
|
||||
this->setScaleX(realScale);
|
||||
}
|
||||
|
||||
void Scale9Sprite::setFlippedY(bool flippedY)
|
||||
{
|
||||
float realScale = this->getScaleY();
|
||||
_flippedY = flippedY;
|
||||
if (_scale9Enabled)
|
||||
{
|
||||
this->setScaleY(-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_scale9Image)
|
||||
{
|
||||
_scale9Image->setFlippedY(flippedY);
|
||||
}
|
||||
}
|
||||
this->setScaleY(realScale);
|
||||
}
|
||||
|
||||
bool Scale9Sprite::isFlippedX()const
|
||||
|
@ -1247,4 +1236,60 @@ y+=ytranslate; \
|
|||
{
|
||||
return _flippedY;
|
||||
}
|
||||
|
||||
void Scale9Sprite::setScaleX(float scaleX)
|
||||
{
|
||||
if (_flippedX) {
|
||||
scaleX = scaleX * -1;
|
||||
}
|
||||
Node::setScaleX(scaleX);
|
||||
}
|
||||
|
||||
void Scale9Sprite::setScaleY(float scaleY)
|
||||
{
|
||||
if (_flippedY) {
|
||||
scaleY = scaleY * -1;
|
||||
}
|
||||
Node::setScaleY(scaleY);
|
||||
}
|
||||
|
||||
void Scale9Sprite::setScale(float scale)
|
||||
{
|
||||
this->setScaleX(scale);
|
||||
this->setScaleY(scale);
|
||||
this->setScaleZ(scale);
|
||||
}
|
||||
|
||||
void Scale9Sprite::setScale(float scaleX, float scaleY)
|
||||
{
|
||||
this->setScaleX(scaleX);
|
||||
this->setScaleY(scaleY);
|
||||
}
|
||||
|
||||
float Scale9Sprite::getScaleX()const
|
||||
{
|
||||
float originalScale = Node::getScaleX();
|
||||
if (_flippedX)
|
||||
{
|
||||
originalScale = originalScale * -1.0;
|
||||
}
|
||||
return originalScale;
|
||||
}
|
||||
|
||||
float Scale9Sprite::getScaleY()const
|
||||
{
|
||||
float originalScale = Node::getScaleY();
|
||||
if (_flippedY)
|
||||
{
|
||||
originalScale = originalScale * -1.0;
|
||||
}
|
||||
return originalScale;
|
||||
}
|
||||
|
||||
float Scale9Sprite::getScale()const
|
||||
{
|
||||
CCASSERT(this->getScaleX() == this->getScaleY(), "Scale9Sprite#scale. ScaleX != ScaleY. Don't know which one to return");
|
||||
return this->getScaleX();
|
||||
}
|
||||
|
||||
}}
|
||||
|
|
|
@ -354,6 +354,16 @@ namespace ui {
|
|||
*/
|
||||
virtual bool isFlippedY()const;
|
||||
|
||||
//override the setScale function of Node
|
||||
virtual void setScaleX(float scaleX) override;
|
||||
virtual void setScaleY(float scaleY) override;
|
||||
virtual void setScale(float scale) override;
|
||||
virtual void setScale(float scalex, float scaley) override;
|
||||
using Node::setScaleZ;
|
||||
virtual float getScaleX() const override;
|
||||
virtual float getScaleY() const override;
|
||||
virtual float getScale() const override;
|
||||
using Node::getScaleZ;
|
||||
protected:
|
||||
void updateCapInset();
|
||||
void updatePositions();
|
||||
|
|
|
@ -1154,9 +1154,11 @@
|
|||
"cocos/ui/proj.win32/libui.vcxproj",
|
||||
"cocos/ui/proj.win32/libui.vcxproj.filters",
|
||||
"docs/CODING_STYLE.md",
|
||||
"docs/CONTRIBUTE.md",
|
||||
"docs/Groups.h",
|
||||
"docs/MainPage.h",
|
||||
"docs/RELEASE_NOTES.md",
|
||||
"docs/RELEASING_RULES.md",
|
||||
"docs/cocos2dx_portrait.png",
|
||||
"docs/doxygen.config",
|
||||
"download-deps.py",
|
||||
|
|
|
@ -44,13 +44,14 @@ bool UIScale9SpriteTest::init()
|
|||
auto moveTo = MoveBy::create(1.0, Vec2(30,0));
|
||||
auto moveBack = moveTo->reverse();
|
||||
auto rotateBy = RotateBy::create(1.0, 180);
|
||||
auto action = Sequence::create(moveTo,moveBack, rotateBy, NULL);
|
||||
auto scaleBy = ScaleTo::create(1.0, -2.0);
|
||||
auto action = Sequence::create(moveTo,moveBack, rotateBy,scaleBy, NULL);
|
||||
|
||||
|
||||
Sprite *normalSprite1 = Sprite::create("cocosui/animationbuttonnormal.png");
|
||||
normalSprite1->setPosition(100, 270);
|
||||
// normalSprite1->setAnchorPoint(Vec2(0.5,0.5));
|
||||
// normalSprite1->setContentSize(Size(100,100));
|
||||
normalSprite1->setFlippedY(true);
|
||||
|
||||
|
||||
this->addChild(normalSprite1);
|
||||
normalSprite1->runAction((FiniteTimeAction*)action->clone());
|
||||
|
@ -107,7 +108,8 @@ bool UIScale9SpriteHierarchialTest::init()
|
|||
auto moveBack = moveTo->reverse();
|
||||
auto rotateBy = RotateBy::create(1.0f, 180);
|
||||
auto fadeOut = FadeOut::create(2.0f);
|
||||
auto action = Sequence::create(moveTo,moveBack, rotateBy,fadeOut, NULL);
|
||||
auto scaleTo = ScaleTo::create(1.0, 2.0);
|
||||
auto action = Sequence::create(moveTo,moveBack, rotateBy,fadeOut,scaleTo, NULL);
|
||||
|
||||
Sprite *normalSprite1 = Sprite::create("cocosui/animationbuttonnormal.png");
|
||||
normalSprite1->setPosition(100, 270);
|
||||
|
@ -135,6 +137,7 @@ bool UIScale9SpriteHierarchialTest::init()
|
|||
cocos2d::ui::Scale9Sprite *sp2 = ui::Scale9Sprite::create("cocosui/animationbuttonnormal.png");
|
||||
sp2->setPreferredSize(sp1->getContentSize() * 1.2f);
|
||||
sp2->setColor(Color3B::GREEN);
|
||||
sp2->setFlippedX(true);
|
||||
sp2->setContentSize(Size(100,100));
|
||||
|
||||
sp1->addChild(sp2);
|
||||
|
@ -163,15 +166,13 @@ bool UIScale9SpriteTouchTest::init()
|
|||
|
||||
auto containerForSprite1 = Node::create();
|
||||
auto sprite1 = cocos2d::ui::Scale9Sprite::create("Images/CyanSquare.png");
|
||||
// sprite1->setScale9Enabled(false);
|
||||
sprite1->setPosition(origin+Vec2(size.width/2, size.height/2) + Vec2(-80, 80));
|
||||
containerForSprite1->addChild(sprite1);
|
||||
addChild(containerForSprite1, 10);
|
||||
|
||||
auto sprite2 = ui::Scale9Sprite::create("Images/MagentaSquare.png");
|
||||
sprite2->setPosition(origin+Vec2(size.width/2, size.height/2));
|
||||
// sprite2->setCascadeOpacityEnabled(false);
|
||||
// sprite2->setScale9Enabled(false);
|
||||
|
||||
|
||||
addChild(sprite2, 20);
|
||||
|
||||
|
@ -179,7 +180,6 @@ bool UIScale9SpriteTouchTest::init()
|
|||
sprite3->setPosition(Vec2(0, 0));
|
||||
sprite3->setCascadeOpacityEnabled(false);
|
||||
sprite2->addChild(sprite3, 1);
|
||||
// sprite3->setScale9Enabled(false);
|
||||
|
||||
|
||||
// Make sprite1 touchable
|
||||
|
@ -647,6 +647,9 @@ bool UIS9Flip::init()
|
|||
float x = winSize.width / 2;
|
||||
float y = 0 + (winSize.height / 2);
|
||||
|
||||
auto statusLabel = Label::createWithSystemFont("Scale9Enabled", "Arial", 10);
|
||||
statusLabel->setPosition(Vec2(x, winSize.height - statusLabel->getContentSize().height - 40));
|
||||
this->addChild(statusLabel);
|
||||
|
||||
auto normalSprite = ui::Scale9Sprite::createWithSpriteFrameName("blocks9r.png");
|
||||
|
||||
|
@ -663,11 +666,11 @@ bool UIS9Flip::init()
|
|||
auto flipXSprite = ui::Scale9Sprite::createWithSpriteFrameName("blocks9r.png");
|
||||
|
||||
flipXSprite->setPosition(Vec2(x - 120, y ));
|
||||
flipXSprite->setScale(1.2);
|
||||
this->addChild(flipXSprite);
|
||||
flipXSprite->setFlippedX(false);
|
||||
|
||||
flipXSprite->setFlippedX(true);
|
||||
|
||||
auto flipXLabel = Label::createWithSystemFont("Sprite FlipX","Airal",10);
|
||||
auto flipXLabel = Label::createWithSystemFont("sprite is not flipped!","Airal",10);
|
||||
flipXLabel->setPosition(flipXSprite->getPosition() + Vec2(0, flipXSprite->getContentSize().height/2 + 10));
|
||||
this->addChild(flipXLabel);
|
||||
|
||||
|
@ -677,12 +680,80 @@ bool UIS9Flip::init()
|
|||
flipYSprite->setPosition(Vec2(x + 120, y));
|
||||
this->addChild(flipYSprite);
|
||||
|
||||
flipYSprite->setScale(0.8);
|
||||
flipYSprite->setFlippedY(true);
|
||||
|
||||
auto flipYLabel = Label::createWithSystemFont("Sprite FlipY","Airal",10);
|
||||
auto flipYLabel = Label::createWithSystemFont("sprite is flipped!","Airal",10);
|
||||
flipYLabel->setPosition(flipYSprite->getPosition() + Vec2(0, flipYSprite->getContentSize().height/2 + 10));
|
||||
this->addChild(flipYLabel);
|
||||
|
||||
|
||||
auto toggleFlipXButton = Button::create();
|
||||
toggleFlipXButton->setTitleText("Toggle FlipX");
|
||||
toggleFlipXButton->setPosition(flipXSprite->getPosition() + Vec2(0, - 20 - flipXSprite->getContentSize().height/2));
|
||||
toggleFlipXButton->addClickEventListener([=](Ref*){
|
||||
flipXSprite->setFlippedX(! flipXSprite->isFlippedX());
|
||||
if (flipXSprite->isFlippedX()) {
|
||||
flipXLabel->setString("sprite is flipped!");
|
||||
}
|
||||
else{
|
||||
flipXLabel->setString("sprite is not flipped!");
|
||||
}
|
||||
});
|
||||
this->addChild(toggleFlipXButton);
|
||||
|
||||
auto toggleFlipYButton = Button::create();
|
||||
toggleFlipYButton->setTitleText("Toggle FlipY");
|
||||
toggleFlipYButton->setPosition(flipYSprite->getPosition() + Vec2(0, -20 - flipYSprite->getContentSize().height/2));
|
||||
toggleFlipYButton->addClickEventListener([=](Ref*){
|
||||
flipYSprite->setFlippedY(!flipYSprite->isFlippedY());
|
||||
if (flipYSprite->isFlippedY()) {
|
||||
flipYLabel->setString("sprite is flipped!");
|
||||
}
|
||||
else{
|
||||
flipYLabel->setString("sprpite is not flipped!");
|
||||
}
|
||||
});
|
||||
this->addChild(toggleFlipYButton);
|
||||
|
||||
auto toggleScale9Button = Button::create();
|
||||
toggleScale9Button->setTitleText("Toggle Scale9");
|
||||
toggleScale9Button->setPosition(normalSprite->getPosition() + Vec2(0, -20 - normalSprite->getContentSize().height/2));
|
||||
toggleScale9Button->addClickEventListener([=](Ref*){
|
||||
flipXSprite->setScale9Enabled(!flipXSprite->isScale9Enabled());
|
||||
flipYSprite->setScale9Enabled(!flipYSprite->isScale9Enabled());
|
||||
if (flipXSprite->isScale9Enabled()) {
|
||||
statusLabel->setString("Scale9Enabled");
|
||||
}else{
|
||||
statusLabel->setString("Scale9Disabled");
|
||||
}
|
||||
|
||||
CCLOG("scaleX = %f", flipXSprite->getScaleX());
|
||||
CCLOG("scaleY = %f", flipYSprite->getScale());
|
||||
if (flipXSprite->isFlippedX()) {
|
||||
CCLOG("xxxxxxx");
|
||||
}
|
||||
if (flipYSprite->isFlippedY()) {
|
||||
CCLOG("YYYYYY");
|
||||
}
|
||||
|
||||
if (flipXSprite->isFlippedX()) {
|
||||
flipXLabel->setString("sprite is flipped!");
|
||||
}
|
||||
else{
|
||||
flipXLabel->setString("sprite is not flipped!");
|
||||
}
|
||||
|
||||
if (flipYSprite->isFlippedY()) {
|
||||
flipYLabel->setString("sprite is flipped!");
|
||||
}
|
||||
else{
|
||||
flipYLabel->setString("sprpite is not flipped!");
|
||||
}
|
||||
|
||||
});
|
||||
this->addChild(toggleScale9Button);
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
Loading…
Reference in New Issue