void example_init() { //load xml file with resources definition gameResources.loadXML("res.xml"); Resources::registerResourceType(ResKeyframeAnimation::create, "keyframe_anim"); animResources.loadXML("godscores_res.xml"); // temporary solution // here we are connecting string resources names to real ResAnims int res_count = animResources.getCount(); for (int ind = 0; ind < res_count; ++ind) { Resource * res = animResources.get(ind); ResKeyframeAnimation * res_ka = dynamic_cast<ResKeyframeAnimation *>(res); if (res_ka) res_ka->linkWithResAnims(&animResources); } spAnimatedActor anim = new AnimatedActor(); anim->setName("anim"); anim->setPosition(250, 80); anim->setResAnim(animResources.getT<ResKeyframeAnimation>("godscores")); anim->play(); RootActor::instance->addChild(anim); //create Play/Stop button spButton button = new Button(); button->setName("btn"); button->setResAnim(gameResources.getResAnim("button")); button->setPosition(50, VirtualHeight - 10); button->setAnchor(Vector2(0.0, 1.0)); button->setInputChildrenEnabled(false); EventCallback cb = CLOSURE(&a, &ab::clicked); button->addEventListener(TouchEvent::CLICK, cb); RootActor::instance->addChild(button); //create Actor with Text and it to button as child spTextActor caption = new TextActor(); caption->setName("caption"); TextStyle style; style.font = gameResources.getResFont("main")->getFont(); style.color = Color(255, 255, 139, 255); style.vAlign = TextStyle::VALIGN_MIDDLE; style.hAlign = TextStyle::HALIGN_CENTER; caption->setStyle(style); caption->setSize(button->getSize()); caption->setText(L"Pause"); button->setScale(0.8f); button->addChild(caption); // create frame counter spTextActor frame_text = new TextActor(); frame_text->setName("frame"); TextStyle style2; style2.font = gameResources.getResFont("main")->getFont(); style2.color = Color(255, 255, 139, 255); style2.vAlign = TextStyle::VALIGN_TOP; frame_text->setStyle(style2); frame_text->setPosition(10, 10); frame_text->setScale(0.6f); frame_text->setSize(200, 30); RootActor::instance->addChild(frame_text); }