From 1cfd133555dcbf67b5e78683a2a0315338c4e834 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Thu, 1 May 2014 11:51:11 -0700 Subject: [PATCH] fixes tmx maps --- cocos/2d/CCTMXXMLParser.cpp | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/cocos/2d/CCTMXXMLParser.cpp b/cocos/2d/CCTMXXMLParser.cpp index 24dcc6fc9e..f07708117a 100644 --- a/cocos/2d/CCTMXXMLParser.cpp +++ b/cocos/2d/CCTMXXMLParser.cpp @@ -340,18 +340,11 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts) s.height = attributeDict["height"].asFloat(); layer->_layerSize = s; - layer->_visible = attributeDict["visible"].asBool(); + Value& visibleValue = attributeDict["visible"]; + layer->_visible = visibleValue.isNull() ? true : visibleValue.asBool(); Value& opacityValue = attributeDict["opacity"]; - - if( !opacityValue.isNull() ) - { - layer->_opacity = (unsigned char)(255.0f * opacityValue.asFloat()); - } - else - { - layer->_opacity = 255; - } + layer->_opacity = opacityValue.isNull() ? 255 : (unsigned char)(255.0f * opacityValue.asFloat()); float x = attributeDict["x"].asFloat(); float y = attributeDict["y"].asFloat();