Cocos2d-x3.0 文件处理(2)
来源:未知 责任编辑:责任编辑 发表时间:2014-05-20 18:26 点击:次
判断文件是否存在
auto s = Director::getInstance()->getWinSize(); auto sharedFileUtils = FileUtils::getInstance(); Label* pTTF; bool isExist = false; //判断文件是否存在 isExist = sharedFileUtils->isFileExist("grossini.png"); pTTF = Label::createWithSystemFont(isExist ? "Images/grossini.png exists" : "Images/grossini.png doesn't exist", "", 20); pTTF->setPosition(Point(s.width / 2, s.height / 2)); this->addChild(pTTF);
auto s = Director::getInstance()->getWinSize(); auto sharedFileUtils = FileUtils::getInstance(); ValueMap dict; dict["grossini.bmp"] = Value("grossini.png"); dict["grossini.xcf"] = Value("grossini.png"); sharedFileUtils->setFilenameLookupDictionary(dict); auto sprite = Sprite::create("grossini.bmp"); this->addChild(sprite); sprite->setPosition(Point(s.width / 2, s.height / 2));
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>