mirror of https://github.com/axmolengine/axmol.git
More warning fixes.
This commit is contained in:
parent
581ba49399
commit
7719c692b8
|
@ -688,7 +688,7 @@ void Sprite::updateQuadVertices()
|
|||
long offset = 0;
|
||||
setGLBufferData(&_quad, 4 * kQuadSize, 0);
|
||||
#else
|
||||
size_t offset = (size_t)&_quad;
|
||||
// size_t offset = (size_t)&_quad;
|
||||
#endif // EMSCRIPTEN
|
||||
|
||||
//TODO optimize the performance cache affineTransformation
|
||||
|
|
|
@ -32,26 +32,23 @@ bool ControlButtonTest_HelloVariableSize::init()
|
|||
auto screenSize = Director::getInstance()->getWinSize();
|
||||
|
||||
// Defines an array of title to create buttons dynamically
|
||||
auto stringArray = Array::create(
|
||||
ccs("Hello"),
|
||||
ccs("Variable"),
|
||||
ccs("Size"),
|
||||
ccs("!"),
|
||||
NULL);
|
||||
std::vector<std::string> vec;
|
||||
vec.push_back("Hello");
|
||||
vec.push_back("Variable");
|
||||
vec.push_back("Size");
|
||||
vec.push_back("!");
|
||||
|
||||
auto layer = Node::create();
|
||||
addChild(layer, 1);
|
||||
|
||||
double total_width = 0, height = 0;
|
||||
|
||||
// For each title in the array
|
||||
Object* pObj = NULL;
|
||||
int i = 0;
|
||||
CCARRAY_FOREACH(stringArray, pObj)
|
||||
|
||||
for (auto& title : vec)
|
||||
{
|
||||
auto title = static_cast<String*>(pObj);
|
||||
// Creates a button with this string as title
|
||||
ControlButton *button = standardButtonWithTitle(title->getCString());
|
||||
ControlButton *button = standardButtonWithTitle(title.c_str());
|
||||
if (i == 0)
|
||||
{
|
||||
button->setOpacity(50);
|
||||
|
|
|
@ -1369,12 +1369,11 @@ std::string BMFontOneAtlas::subtitle()
|
|||
/// BMFontUnicode
|
||||
BMFontUnicode::BMFontUnicode()
|
||||
{
|
||||
auto strings = Dictionary::createWithContentsOfFile("fonts/strings.xml");
|
||||
|
||||
const char *chinese = static_cast<String*>(strings->objectForKey("chinese1"))->_string.c_str();
|
||||
const char *japanese = static_cast<String*>(strings->objectForKey("japanese"))->_string.c_str();
|
||||
const char *russian = static_cast<String*>(strings->objectForKey("russian"))->_string.c_str();
|
||||
const char *spanish = static_cast<String*>(strings->objectForKey("spanish"))->_string.c_str();
|
||||
auto strings = FileUtils::getInstance()->getValueMapFromFile("fonts/strings.xml");
|
||||
std::string chinese = strings["chinese1"].asString();
|
||||
std::string russian = strings["russian"].asString();
|
||||
std::string spanish = strings["spanish"].asString();
|
||||
std::string japanese = strings["japanese"].asString();
|
||||
|
||||
auto s = Director::getInstance()->getWinSize();
|
||||
|
||||
|
|
|
@ -832,12 +832,11 @@ void LabelFNTMultiLineAlignment::snapArrowsToEdge()
|
|||
/// BMFontUnicodeNew
|
||||
LabelFNTUNICODELanguages::LabelFNTUNICODELanguages()
|
||||
{
|
||||
auto strings = Dictionary::createWithContentsOfFile("fonts/strings.xml");
|
||||
|
||||
const char *chinese = static_cast<String*>(strings->objectForKey("chinese1"))->_string.c_str();
|
||||
const char *japanese = static_cast<String*>(strings->objectForKey("japanese"))->_string.c_str();
|
||||
const char *russian = static_cast<String*>(strings->objectForKey("russian"))->_string.c_str();
|
||||
const char *spanish = static_cast<String*>(strings->objectForKey("spanish"))->_string.c_str();
|
||||
auto strings = FileUtils::getInstance()->getValueMapFromFile("fonts/strings.xml");
|
||||
std::string chinese = strings["chinese1"].asString();
|
||||
std::string russian = strings["russian"].asString();
|
||||
std::string spanish = strings["spanish"].asString();
|
||||
std::string japanese = strings["japanese"].asString();
|
||||
|
||||
auto s = Director::getInstance()->getWinSize();
|
||||
|
||||
|
@ -1035,12 +1034,12 @@ std::string LabelTTFDynamicAlignment::subtitle()
|
|||
//
|
||||
LabelTTFUnicodeNew::LabelTTFUnicodeNew()
|
||||
{
|
||||
auto strings = Dictionary::createWithContentsOfFile("fonts/strings.xml");
|
||||
const char *chinese = static_cast<String*>(strings->objectForKey("chinese1"))->_string.c_str();
|
||||
auto strings = FileUtils::getInstance()->getValueMapFromFile("fonts/strings.xml");
|
||||
std::string chinese = strings["chinese1"].asString();
|
||||
|
||||
//const char *russian = static_cast<String*>(strings->objectForKey("russian"))->_string.c_str();
|
||||
//const char *spanish = static_cast<String*>(strings->objectForKey("spanish"))->_string.c_str();
|
||||
//const char *japanese = static_cast<String*>(strings->objectForKey("japanese"))->_string.c_str();
|
||||
// std::string russian = strings["russian"].asString();
|
||||
// std::string spanish = strings["spanish"].asString();
|
||||
// std::string japanese = strings["japanese"].asString();
|
||||
|
||||
auto size = Director::getInstance()->getWinSize();
|
||||
|
||||
|
@ -1061,7 +1060,7 @@ LabelTTFUnicodeNew::LabelTTFUnicodeNew()
|
|||
addChild(label2);
|
||||
|
||||
// chinese
|
||||
auto label3 = Label::createWithTTF(chinese, "fonts/wt021.ttf", 45, size.width, TextHAlignment::CENTER, GlyphCollection::CUSTOM, chinese);
|
||||
auto label3 = Label::createWithTTF(chinese, "fonts/wt021.ttf", 45, size.width, TextHAlignment::CENTER, GlyphCollection::CUSTOM, chinese.c_str());
|
||||
label3->setPosition( Point(size.width/2, vSize - (vStep * 6.5)) );
|
||||
label3->setAnchorPoint(Point(0.5, 0.5));
|
||||
addChild(label3);
|
||||
|
|
|
@ -71,7 +71,7 @@ bool MutiTouchTestLayer::init()
|
|||
return false;
|
||||
}
|
||||
|
||||
static Dictionary s_dic;
|
||||
static Map<int, TouchPoint*> s_map;
|
||||
|
||||
void MutiTouchTestLayer::onTouchesBegan(const std::vector<Touch*>& touches, Event *event)
|
||||
{
|
||||
|
@ -85,7 +85,7 @@ void MutiTouchTestLayer::onTouchesBegan(const std::vector<Touch*>& touches, Even
|
|||
touchPoint->setTouchColor(*s_TouchColors[touch->getID()]);
|
||||
|
||||
addChild(touchPoint);
|
||||
s_dic.setObject(touchPoint, touch->getID());
|
||||
s_map.insert(touch->getID(), touchPoint);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ void MutiTouchTestLayer::onTouchesMoved(const std::vector<Touch*>& touches, Even
|
|||
for( auto &item: touches)
|
||||
{
|
||||
auto touch = item;
|
||||
auto pTP = static_cast<TouchPoint*>(s_dic.objectForKey(touch->getID()));
|
||||
auto pTP = s_map.at(touch->getID());
|
||||
auto location = touch->getLocation();
|
||||
pTP->setTouchPos(location);
|
||||
}
|
||||
|
@ -105,9 +105,9 @@ void MutiTouchTestLayer::onTouchesEnded(const std::vector<Touch*>& touches, Even
|
|||
for ( auto &item: touches )
|
||||
{
|
||||
auto touch = item;
|
||||
auto pTP = static_cast<TouchPoint*>(s_dic.objectForKey(touch->getID()));
|
||||
auto pTP = s_map.at(touch->getID());
|
||||
removeChild(pTP, true);
|
||||
s_dic.removeObjectForKey(touch->getID());
|
||||
s_map.erase(touch->getID());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -283,7 +283,7 @@ const char* IterateSpriteSheet::testName()
|
|||
void IterateSpriteSheetForLoop::update(float dt)
|
||||
{
|
||||
// iterate using fast enumeration protocol
|
||||
auto children = batchNode->getChildren();
|
||||
auto& children = batchNode->getChildren();
|
||||
|
||||
CC_PROFILER_START(this->profilerName());
|
||||
|
||||
|
@ -320,7 +320,7 @@ const char* IterateSpriteSheetForLoop::testName()
|
|||
void IterateSpriteSheetCArray::update(float dt)
|
||||
{
|
||||
// iterate using fast enumeration protocol
|
||||
auto children = batchNode->getChildren();
|
||||
auto& children = batchNode->getChildren();
|
||||
// Object* object = NULL;
|
||||
|
||||
CC_PROFILER_START(this->profilerName());
|
||||
|
@ -358,7 +358,7 @@ const char* IterateSpriteSheetCArray::testName()
|
|||
void IterateSpriteSheetIterator::update(float dt)
|
||||
{
|
||||
// iterate using fast enumeration protocol
|
||||
auto children = batchNode->getChildren();
|
||||
auto& children = batchNode->getChildren();
|
||||
|
||||
CC_PROFILER_START(this->profilerName());
|
||||
|
||||
|
|
|
@ -594,22 +594,20 @@ void SchedulerSchedulesAndRemove::scheduleAndUnschedule(float dt)
|
|||
// TestNode
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
void TestNode::initWithString(String* pStr, int priority)
|
||||
void TestNode::initWithString(const std::string& str, int priority)
|
||||
{
|
||||
_pstring = pStr;
|
||||
_pstring->retain();
|
||||
_string = str;
|
||||
scheduleUpdateWithPriority(priority);
|
||||
}
|
||||
|
||||
TestNode::~TestNode()
|
||||
{
|
||||
_pstring->release();
|
||||
}
|
||||
|
||||
void TestNode::update(float dt)
|
||||
{
|
||||
CC_UNUSED_PARAM(dt);
|
||||
log("%s", _pstring->getCString());
|
||||
log("%s", _string.c_str());
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
|
@ -622,44 +620,32 @@ void SchedulerUpdate::onEnter()
|
|||
SchedulerTestLayer::onEnter();
|
||||
|
||||
auto d = new TestNode();
|
||||
auto pStr = new String("---");
|
||||
d->initWithString(pStr, 50);
|
||||
pStr->release();
|
||||
d->initWithString("---", 50);
|
||||
addChild(d);
|
||||
d->release();
|
||||
|
||||
auto b = new TestNode();
|
||||
pStr = new String("3rd");
|
||||
b->initWithString(pStr, 0);
|
||||
pStr->release();
|
||||
b->initWithString("3rd", 0);
|
||||
addChild(b);
|
||||
b->release();
|
||||
|
||||
auto a = new TestNode();
|
||||
pStr = new String("1st");
|
||||
a->initWithString(pStr, -10);
|
||||
pStr->release();
|
||||
a->initWithString("1st", -10);
|
||||
addChild(a);
|
||||
a->release();
|
||||
|
||||
auto c = new TestNode();
|
||||
pStr = new String("4th");
|
||||
c->initWithString(pStr, 10);
|
||||
pStr->release();
|
||||
c->initWithString("4th", 10);
|
||||
addChild(c);
|
||||
c->release();
|
||||
|
||||
auto e = new TestNode();
|
||||
pStr = new String("5th");
|
||||
e->initWithString(pStr, 20);
|
||||
pStr->release();
|
||||
e->initWithString("5th", 20);
|
||||
addChild(e);
|
||||
e->release();
|
||||
|
||||
auto f = new TestNode();
|
||||
pStr = new String("2nd");
|
||||
f->initWithString(pStr, -5);
|
||||
pStr->release();
|
||||
f->initWithString("2nd", -5);
|
||||
addChild(f);
|
||||
f->release();
|
||||
|
||||
|
|
|
@ -216,10 +216,10 @@ public:
|
|||
|
||||
~TestNode();
|
||||
|
||||
void initWithString(String* pStr, int priority);
|
||||
void initWithString(const std::string& str, int priority);
|
||||
virtual void update(float dt);
|
||||
private:
|
||||
String* _pstring;
|
||||
std::string _string;
|
||||
};
|
||||
|
||||
class RescheduleSelector : public SchedulerTestLayer
|
||||
|
|
|
@ -588,19 +588,11 @@ TMXOrthoObjectsTest::TMXOrthoObjectsTest()
|
|||
Size CC_UNUSED s = map->getContentSize();
|
||||
CCLOG("ContentSize: %f, %f", s.width,s.height);
|
||||
|
||||
////----CCLOG("----> Iterating over all the group objets");
|
||||
auto group = map->getObjectGroup("Object Group 1");
|
||||
auto& objects = group->getObjects();
|
||||
|
||||
for (auto& obj : objects)
|
||||
{
|
||||
ValueMap& dict = obj.asValueMap();
|
||||
////----CCLOG("object: %x", dict);
|
||||
}
|
||||
|
||||
////----CCLOG("----> Fetching 1 object by name");
|
||||
// auto platform = group->objectNamed("platform");
|
||||
////----CCLOG("platform: %x", platform);
|
||||
Value objectsVal = Value(objects);
|
||||
CCLOG("%s", objectsVal.getDescription().c_str());
|
||||
}
|
||||
|
||||
void TMXOrthoObjectsTest::draw()
|
||||
|
@ -657,15 +649,10 @@ TMXIsoObjectsTest::TMXIsoObjectsTest()
|
|||
|
||||
auto group = map->getObjectGroup("Object Group 1");
|
||||
|
||||
//auto objects = group->objects();
|
||||
auto& objects = group->getObjects();
|
||||
//UxMutableDictionary<std::string>* dict;
|
||||
for (auto& obj : objects)
|
||||
{
|
||||
ValueMap& dict = obj.asValueMap();
|
||||
|
||||
////----CCLOG("object: %x", dict);
|
||||
}
|
||||
|
||||
Value objectsVal = Value(objects);
|
||||
CCLOG("%s", objectsVal.getDescription().c_str());
|
||||
}
|
||||
|
||||
void TMXIsoObjectsTest::draw()
|
||||
|
|
Loading…
Reference in New Issue