;
// Hello World 文本
const auto label = Label::createWithTTF(CommonUtil::GBKToUTF8("第一个程序"), CommonUtil::GetDefaultFontPath(), 24);
// 设置文本位置
label->setPosition(Vec2(origin.x + visibleSize.width / 2, origin.y + visibleSize.height - label->getContentSize().height));
// 文本添加到当前层
this->addChild(label, 1);
// 创建背景图片
const auto sprite = Sprite::create("HelloWorld.png");
// 图片位置
sprite->setPosition(Vec2(visibleSize.width / 2 + origin.x, visibleSize.height / 2 + origin.y));
// 背景图片添加到当前层
this->addChild(sprite, 0);
return true;
}
关于资源复制问题
有时候 Resources
目录下的文件无法复制到输出目录, 此时可以使用生成事件解决这个问题
xcopy /s /f /h /y $(ProjectDir)..\Resources\res $(OutDir)\Resources