diff --git a/cocos/2d/CCSprite.cpp b/cocos/2d/CCSprite.cpp index d48ced1a8d..e60e4154c9 100644 --- a/cocos/2d/CCSprite.cpp +++ b/cocos/2d/CCSprite.cpp @@ -431,7 +431,7 @@ void Sprite::setTextureRect(const Rect& rect, bool rotated, const Size& untrimme void Sprite::debugDraw(bool on) { if (_batchNode) { - log("Sprite doesn't support denbug draw when using SpriteBatchNode"); + log("Sprite doesn't support debug draw when using SpriteBatchNode"); return ; } DrawNode* draw = getChildByName("debugDraw"); diff --git a/cocos/platform/mac/CCDevice-mac.mm b/cocos/platform/mac/CCDevice-mac.mm index 09d6c17a9e..7614776d7c 100644 --- a/cocos/platform/mac/CCDevice-mac.mm +++ b/cocos/platform/mac/CCDevice-mac.mm @@ -36,8 +36,12 @@ NS_CC_BEGIN int Device::getDPI() { - //TODO: return correct DPI - return 160; + NSScreen *screen = [NSScreen mainScreen]; + NSDictionary *description = [screen deviceDescription]; + NSSize displayPixelSize = [[description objectForKey:NSDeviceSize] sizeValue]; + CGSize displayPhysicalSize = CGDisplayScreenSize([[description objectForKey:@"NSScreenNumber"] unsignedIntValue]); + + return ((displayPixelSize.width / displayPhysicalSize.width) * 25.4f); } void Device::setAccelerometerEnabled(bool isEnabled) diff --git a/cocos/scripting/js-bindings/script/studio/parsers/action-2.x.js b/cocos/scripting/js-bindings/script/studio/parsers/action-2.x.js index b4f4a89b32..dcf168a218 100644 --- a/cocos/scripting/js-bindings/script/studio/parsers/action-2.x.js +++ b/cocos/scripting/js-bindings/script/studio/parsers/action-2.x.js @@ -113,7 +113,7 @@ name: "Rotation", handle: function(options){ var frame = new ccs.RotationFrame(); - var rotation = options["Rotation"]; + var rotation = options["Rotation"] || options["Value"] || 0; frame.setRotation(rotation); return frame; } diff --git a/cocos/scripting/js-bindings/script/studio/parsers/timelineParser-2.x.js b/cocos/scripting/js-bindings/script/studio/parsers/timelineParser-2.x.js index 0957cfb853..2c1a667455 100644 --- a/cocos/scripting/js-bindings/script/studio/parsers/timelineParser-2.x.js +++ b/cocos/scripting/js-bindings/script/studio/parsers/timelineParser-2.x.js @@ -104,7 +104,9 @@ var visible = getParam(json["VisibleForFrame"], true); node.setVisible(visible); - setContentSize(node, json["Size"]); + var size = json["Size"]; + if(size) + setContentSize(node, size); if (json["Alpha"] != null) node.setOpacity(json["Alpha"]); @@ -118,9 +120,7 @@ extensionData.setCustomProperty(customProperty); extensionData.setActionTag(actionTag); if (node.getComponent("ComExtensionData")) - { node.removeComponent("ComExtensionData"); - } node.addComponent(extensionData); node.setCascadeColorEnabled(true); @@ -294,9 +294,7 @@ extensionData.setCustomProperty(customProperty); extensionData.setActionTag(actionTag); if (widget.getComponent("ComExtensionData")) - { widget.removeComponent("ComExtensionData"); - } widget.addComponent(extensionData); var rotationSkewX = json["RotationSkewX"]; diff --git a/extensions/assets-manager/AssetsManagerEx.cpp b/extensions/assets-manager/AssetsManagerEx.cpp index 25fcdcb157..1af35b52c6 100644 --- a/extensions/assets-manager/AssetsManagerEx.cpp +++ b/extensions/assets-manager/AssetsManagerEx.cpp @@ -81,7 +81,7 @@ AssetsManagerEx::AssetsManagerEx(const std::string& manifestUrl, const std::stri _fileUtils = FileUtils::getInstance(); _updateState = State::UNCHECKED; - _downloader = std::make_shared(); + _downloader = std::shared_ptr(new Downloader); _downloader->setConnectionTimeout(DEFAULT_CONNECTION_TIMEOUT); _downloader->_onError = std::bind(&AssetsManagerEx::onError, this, std::placeholders::_1); _downloader->_onProgress = std::bind(&AssetsManagerEx::onProgress, diff --git a/extensions/assets-manager/Downloader.cpp b/extensions/assets-manager/Downloader.cpp index 3187b19762..7025a32e5b 100644 --- a/extensions/assets-manager/Downloader.cpp +++ b/extensions/assets-manager/Downloader.cpp @@ -392,6 +392,7 @@ void Downloader::downloadToBufferSync(const std::string &srcUrl, unsigned char * void Downloader::downloadToBuffer(const std::string &srcUrl, const std::string &customId, const StreamData &buffer, const ProgressData &data) { std::weak_ptr ptr = shared_from_this(); + std::shared_ptr shared = ptr.lock(); CURL *curl = curl_easy_init(); if (!curl) { @@ -463,6 +464,7 @@ void Downloader::downloadSync(const std::string &srcUrl, const std::string &stor void Downloader::download(const std::string &srcUrl, const std::string &customId, const FileDescriptor &fDesc, const ProgressData &data) { std::weak_ptr ptr = shared_from_this(); + std::shared_ptr shared = ptr.lock(); CURL *curl = curl_easy_init(); if (!curl) { @@ -524,6 +526,7 @@ void Downloader::batchDownloadSync(const DownloadUnits &units, const std::string { // Make sure downloader won't be released std::weak_ptr ptr = shared_from_this(); + std::shared_ptr shared = ptr.lock(); if (units.size() != 0) { diff --git a/templates/js-template-default/frameworks/runtime-src/Classes/AppDelegate.cpp b/templates/js-template-default/frameworks/runtime-src/Classes/AppDelegate.cpp index 5e66c88321..b2dfc0e959 100644 --- a/templates/js-template-default/frameworks/runtime-src/Classes/AppDelegate.cpp +++ b/templates/js-template-default/frameworks/runtime-src/Classes/AppDelegate.cpp @@ -152,6 +152,9 @@ bool AppDelegate::applicationDidFinishLaunching() #endif sc->start(); sc->runScript("script/jsb_boot.js"); +#if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0) + sc->enableDebugger(); +#endif ScriptEngineProtocol *engine = ScriptingCore::getInstance(); ScriptEngineManager::getInstance()->setScriptEngine(engine); ScriptingCore::getInstance()->runScript("main.js"); diff --git a/templates/js-template-runtime/frameworks/runtime-src/Classes/AppDelegate.cpp b/templates/js-template-runtime/frameworks/runtime-src/Classes/AppDelegate.cpp index 81a01e10c2..bf11d78bb0 100644 --- a/templates/js-template-runtime/frameworks/runtime-src/Classes/AppDelegate.cpp +++ b/templates/js-template-runtime/frameworks/runtime-src/Classes/AppDelegate.cpp @@ -68,13 +68,16 @@ bool AppDelegate::applicationDidFinishLaunching() jsRuntime->startWithDebugger(); } #else - js_module_register(); - ScriptingCore* sc = ScriptingCore::getInstance(); - sc->start(); - sc->runScript("script/jsb_boot.js"); - ScriptEngineProtocol *engine = ScriptingCore::getInstance(); - ScriptEngineManager::getInstance()->setScriptEngine(engine); - ScriptingCore::getInstance()->runScript("main.js"); + js_module_register(); + ScriptingCore* sc = ScriptingCore::getInstance(); + sc->start(); + sc->runScript("script/jsb_boot.js"); +#if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0) + sc->enableDebugger(); +#endif + ScriptEngineProtocol *engine = ScriptingCore::getInstance(); + ScriptEngineManager::getInstance()->setScriptEngine(engine); + ScriptingCore::getInstance()->runScript("main.js"); #endif return true; diff --git a/tools/cocos2d-console b/tools/cocos2d-console index f3768083be..99ea6cb519 160000 --- a/tools/cocos2d-console +++ b/tools/cocos2d-console @@ -1 +1 @@ -Subproject commit f3768083be951e019a2983703847e05b2e284e7d +Subproject commit 99ea6cb519c1b11567985684d0d08d2205ae5607 diff --git a/tools/simulator/libsimulator/lib/runtime/RuntimeCCSImpl.cpp b/tools/simulator/libsimulator/lib/runtime/RuntimeCCSImpl.cpp index 916c7fca3a..120a9ed8f0 100644 --- a/tools/simulator/libsimulator/lib/runtime/RuntimeCCSImpl.cpp +++ b/tools/simulator/libsimulator/lib/runtime/RuntimeCCSImpl.cpp @@ -3,6 +3,7 @@ #include "ConfigParser.h" #include "cocostudio/CocoStudio.h" #include "ui/UIHelper.h" +#include "tinyxml2/tinyxml2.h" //////////////////////////////////////// @@ -58,6 +59,34 @@ void RuntimeCCSImpl::loadCSDProject(const std::string& file) node->setContentSize(frameSize); ui::Helper::doLayout(node); + std::string inFullpath = FileUtils::getInstance()->fullPathForFilename(file).c_str(); + std::string content = FileUtils::getInstance()->getStringFromFile(file); + tinyxml2::XMLDocument* document = new tinyxml2::XMLDocument(); + document->Parse(content.c_str()); + const tinyxml2::XMLElement* rootElement = document->RootElement(); + const tinyxml2::XMLElement* element = rootElement->FirstChildElement(); + + if(element) + { + if (strcmp("PropertyGroup", element->Name()) == 0) + { + const tinyxml2::XMLAttribute* attribute = element->FirstAttribute(); + if (attribute) + { + std::string csdType = attribute->Name(); + if (csdType.compare("Type") == 0) + { + std::string csdValue = attribute->Value(); + if (csdValue.compare("Skeleton") == 0 || csdValue.compare("Node") == 0) + { + node->setPosition(cocos2d::Vec2(frameSize.width / 2.0f, frameSize.height / 2.0f)); + } + } + } + } + + } + if (Director::getInstance()->getRunningScene()) { auto scene = Scene::create();