Merge pull request #1 from cocos2d/v3

keep synced
This commit is contained in:
Jeff Wang 2015-08-05 07:05:13 +08:00
commit 4d0adf4435
10 changed files with 58 additions and 18 deletions

View File

@ -431,7 +431,7 @@ void Sprite::setTextureRect(const Rect& rect, bool rotated, const Size& untrimme
void Sprite::debugDraw(bool on) void Sprite::debugDraw(bool on)
{ {
if (_batchNode) { if (_batchNode) {
log("Sprite doesn't support denbug draw when using SpriteBatchNode"); log("Sprite doesn't support debug draw when using SpriteBatchNode");
return ; return ;
} }
DrawNode* draw = getChildByName<DrawNode*>("debugDraw"); DrawNode* draw = getChildByName<DrawNode*>("debugDraw");

View File

@ -36,8 +36,12 @@ NS_CC_BEGIN
int Device::getDPI() int Device::getDPI()
{ {
//TODO: return correct DPI NSScreen *screen = [NSScreen mainScreen];
return 160; 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) void Device::setAccelerometerEnabled(bool isEnabled)

View File

@ -113,7 +113,7 @@
name: "Rotation", name: "Rotation",
handle: function(options){ handle: function(options){
var frame = new ccs.RotationFrame(); var frame = new ccs.RotationFrame();
var rotation = options["Rotation"]; var rotation = options["Rotation"] || options["Value"] || 0;
frame.setRotation(rotation); frame.setRotation(rotation);
return frame; return frame;
} }

View File

@ -104,7 +104,9 @@
var visible = getParam(json["VisibleForFrame"], true); var visible = getParam(json["VisibleForFrame"], true);
node.setVisible(visible); node.setVisible(visible);
setContentSize(node, json["Size"]); var size = json["Size"];
if(size)
setContentSize(node, size);
if (json["Alpha"] != null) if (json["Alpha"] != null)
node.setOpacity(json["Alpha"]); node.setOpacity(json["Alpha"]);
@ -118,9 +120,7 @@
extensionData.setCustomProperty(customProperty); extensionData.setCustomProperty(customProperty);
extensionData.setActionTag(actionTag); extensionData.setActionTag(actionTag);
if (node.getComponent("ComExtensionData")) if (node.getComponent("ComExtensionData"))
{
node.removeComponent("ComExtensionData"); node.removeComponent("ComExtensionData");
}
node.addComponent(extensionData); node.addComponent(extensionData);
node.setCascadeColorEnabled(true); node.setCascadeColorEnabled(true);
@ -294,9 +294,7 @@
extensionData.setCustomProperty(customProperty); extensionData.setCustomProperty(customProperty);
extensionData.setActionTag(actionTag); extensionData.setActionTag(actionTag);
if (widget.getComponent("ComExtensionData")) if (widget.getComponent("ComExtensionData"))
{
widget.removeComponent("ComExtensionData"); widget.removeComponent("ComExtensionData");
}
widget.addComponent(extensionData); widget.addComponent(extensionData);
var rotationSkewX = json["RotationSkewX"]; var rotationSkewX = json["RotationSkewX"];

View File

@ -81,7 +81,7 @@ AssetsManagerEx::AssetsManagerEx(const std::string& manifestUrl, const std::stri
_fileUtils = FileUtils::getInstance(); _fileUtils = FileUtils::getInstance();
_updateState = State::UNCHECKED; _updateState = State::UNCHECKED;
_downloader = std::make_shared<Downloader>(); _downloader = std::shared_ptr<Downloader>(new Downloader);
_downloader->setConnectionTimeout(DEFAULT_CONNECTION_TIMEOUT); _downloader->setConnectionTimeout(DEFAULT_CONNECTION_TIMEOUT);
_downloader->_onError = std::bind(&AssetsManagerEx::onError, this, std::placeholders::_1); _downloader->_onError = std::bind(&AssetsManagerEx::onError, this, std::placeholders::_1);
_downloader->_onProgress = std::bind(&AssetsManagerEx::onProgress, _downloader->_onProgress = std::bind(&AssetsManagerEx::onProgress,

View File

@ -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) void Downloader::downloadToBuffer(const std::string &srcUrl, const std::string &customId, const StreamData &buffer, const ProgressData &data)
{ {
std::weak_ptr<Downloader> ptr = shared_from_this(); std::weak_ptr<Downloader> ptr = shared_from_this();
std::shared_ptr<Downloader> shared = ptr.lock();
CURL *curl = curl_easy_init(); CURL *curl = curl_easy_init();
if (!curl) 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) void Downloader::download(const std::string &srcUrl, const std::string &customId, const FileDescriptor &fDesc, const ProgressData &data)
{ {
std::weak_ptr<Downloader> ptr = shared_from_this(); std::weak_ptr<Downloader> ptr = shared_from_this();
std::shared_ptr<Downloader> shared = ptr.lock();
CURL *curl = curl_easy_init(); CURL *curl = curl_easy_init();
if (!curl) if (!curl)
{ {
@ -524,6 +526,7 @@ void Downloader::batchDownloadSync(const DownloadUnits &units, const std::string
{ {
// Make sure downloader won't be released // Make sure downloader won't be released
std::weak_ptr<Downloader> ptr = shared_from_this(); std::weak_ptr<Downloader> ptr = shared_from_this();
std::shared_ptr<Downloader> shared = ptr.lock();
if (units.size() != 0) if (units.size() != 0)
{ {

View File

@ -152,6 +152,9 @@ bool AppDelegate::applicationDidFinishLaunching()
#endif #endif
sc->start(); sc->start();
sc->runScript("script/jsb_boot.js"); sc->runScript("script/jsb_boot.js");
#if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0)
sc->enableDebugger();
#endif
ScriptEngineProtocol *engine = ScriptingCore::getInstance(); ScriptEngineProtocol *engine = ScriptingCore::getInstance();
ScriptEngineManager::getInstance()->setScriptEngine(engine); ScriptEngineManager::getInstance()->setScriptEngine(engine);
ScriptingCore::getInstance()->runScript("main.js"); ScriptingCore::getInstance()->runScript("main.js");

View File

@ -72,6 +72,9 @@ bool AppDelegate::applicationDidFinishLaunching()
ScriptingCore* sc = ScriptingCore::getInstance(); ScriptingCore* sc = ScriptingCore::getInstance();
sc->start(); sc->start();
sc->runScript("script/jsb_boot.js"); sc->runScript("script/jsb_boot.js");
#if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0)
sc->enableDebugger();
#endif
ScriptEngineProtocol *engine = ScriptingCore::getInstance(); ScriptEngineProtocol *engine = ScriptingCore::getInstance();
ScriptEngineManager::getInstance()->setScriptEngine(engine); ScriptEngineManager::getInstance()->setScriptEngine(engine);
ScriptingCore::getInstance()->runScript("main.js"); ScriptingCore::getInstance()->runScript("main.js");

@ -1 +1 @@
Subproject commit f3768083be951e019a2983703847e05b2e284e7d Subproject commit 99ea6cb519c1b11567985684d0d08d2205ae5607

View File

@ -3,6 +3,7 @@
#include "ConfigParser.h" #include "ConfigParser.h"
#include "cocostudio/CocoStudio.h" #include "cocostudio/CocoStudio.h"
#include "ui/UIHelper.h" #include "ui/UIHelper.h"
#include "tinyxml2/tinyxml2.h"
//////////////////////////////////////// ////////////////////////////////////////
@ -58,6 +59,34 @@ void RuntimeCCSImpl::loadCSDProject(const std::string& file)
node->setContentSize(frameSize); node->setContentSize(frameSize);
ui::Helper::doLayout(node); 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()) if (Director::getInstance()->getRunningScene())
{ {
auto scene = Scene::create(); auto scene = Scene::create();