Example #1
0
void example_init()
{
	file::setExtendedFolder("ext");

	//load xml file with resources definition
	resources.loadXML("xmls/res.xml");
	resourcesUI.loadXML("xmls/res_ui.xml");
	resourcesUI.loadXML("xmls/fonts.xml");

	spSprite sp = initActor(new Sprite, 
		arg_resAnim = resources.getResAnim("logo2"),
		arg_attachTo = getRoot(),
		arg_priority = 10,
		arg_alpha = 128
		);

	sp->setX(getRoot()->getWidth() - sp->getWidth());
	sp->setY(getRoot()->getHeight() - sp->getHeight());

	_tests = new TestActor;
	RootActor::instance->addChild(_tests);
}
//called from entry_point.cpp
void example_init()
{
	//load xml file with resources definition
	gameResources.loadXML("res.xml");
		

	//lets create our client code simple actor
	//spMainActor was defined above as smart intrusive pointer (read more: http://www.boost.org/doc/libs/1_57_0/libs/smart_ptr/intrusive_ptr.html)
	spMainActor actor = new MainActor;

	//and add it to Stage as child
	getStage()->addChild(actor);
}
void example_init()
{
	animals.loadXML("animals.xml");

	spSprite dog = new Sprite;
	dog->setResAnim(animals.getResAnim("dog"));	
	dog->setPosition(200, 300);
	dog->attachTo(getStage());

	spSprite cat = new Sprite;
	cat->setResAnim(animals.getResAnim("cat"));
	cat->setPosition(600, 300);
	cat->attachTo(getStage());
}
Example #4
0
void example_init()
{
    //Load resources in xml file
    resources.loadXML("xmls/res.xml");
    Test::init();

    Test::instance = new TestActor;
    getStage()->addChild(Test::instance);

    //Initialize http requests
    HttpRequestTask::init();


#if MULTIWINDOW
    SDL_Window* window2 = SDL_CreateWindow("Second Oxygine Window", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, getStage()->getWidth(), getStage()->getHeight(), SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN);
    stage2 = new Stage(false);
    stage2->setSize(getStage()->getSize());
    stage2->associateWithWindow(window2);
#endif
}
Example #5
0
 void load()
 {
     //load our resources
     ui.loadXML("xmls/ui.xml");
 }
Example #6
0
 void initOnlyRes(string path)
 {
     resources.loadXML(path);
 }
Example #7
0
 void init(string path)
 {
     resources.loadXML(path);
 }
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);
}