当前位置: 首页>>代码示例>>C++>>正文


C++ ViewGroup::addView方法代码示例

本文整理汇总了C++中ViewGroup::addView方法的典型用法代码示例。如果您正苦于以下问题:C++ ViewGroup::addView方法的具体用法?C++ ViewGroup::addView怎么用?C++ ViewGroup::addView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ViewGroup的用法示例。


在下文中一共展示了ViewGroup::addView方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Scene

SceneTitle::SceneTitle(ApplicationController *controller) : Scene(controller) {
	LOGD("****SceneTitle");
	index = 0;
	
	//	HttpClient client;
	//	PngData png;
	//	Scene sn(controller);
	//
	//	class ps : public XMLParser {
	//		virtual void startElement(const XML_Char *name, const XML_Char *atts[]) {};
	//		virtual void endElement(const XML_Char *name) {};
	//		virtual void bodyElement(const XML_Char *s, int len) {};
	//	};
	//
	//	ps a;
	
	
	
	TextureManager *mgr = controller->texMgr;
	
	SharedTexture *tex = mgr->getSharedTexture(
											   "texture/chara_texture.png",
											   "texture/chara_texture.txt");
	
	ViewGroup *root = new ViewGroup(controller);
	
	//TextTexture使用サンプル
	//結構メモリを使用するので動的に生成するのはおすすめしない
    GCDrawText("Test", 60, 1.0, 1.0, 1.0);
    GCDrawText("Red", 60, 1.0, 0.0, 0.0);
    GCDrawText("日本語", 40, 1.0, 0.0, 1.0);
	
    //GCGetTextTextureでテクスチャを取得
    PackerTexture *strTexture = GCGetTextTexture();
	
    //TextureManagerにテクスチャを登録する。
    //登録しておかないと復帰時の再ロードが行われない。
    //任意の名前で登録する "TextTexture"
    //登録後は mgr->getSharedTexture("TextTexture",NULL); で取得できる
    mgr->addExtraTexture("TextTexture", strTexture);
	
    ImageView *textLabel = new ImageView(controller);
    textLabel->setFigure(strTexture->makePlate(0, 0));//登録順のインデックスもしくは、 strTexture->makePlate("Test") GCDrawText時の文字列を指定する
    textLabel->setTexture(&strTexture->getTexture());
    textLabel->setPosition(0, 1.0/controller->getAspect()-textLabel->size.y);
    root->addView(textLabel);
    textLabel->release();
	
    ImageView *textLabel2 = new ImageView(controller);
    textLabel2->setFigure(strTexture->makePlate(1, 0));
    textLabel2->setTexture(&strTexture->getTexture());
    textLabel2->setPosition(1.0 - textLabel2->size.x, 1.0/controller->getAspect()-textLabel2->size.y);
    root->addView(textLabel2);
    textLabel2->release();
	
    ImageView *textLabel3 = new ImageView(controller);
    textLabel3->setFigure(strTexture->makePlate(2, 0));
    textLabel3->setTexture(&strTexture->getTexture());
    textLabel3->setPosition(-1.0 + textLabel3->size.x, -1.0/controller->getAspect()+textLabel3->size.y);
    root->addView(textLabel3);
    textLabel3->release();
	
	static const char *filename[] = {
		"chara00.png",
		"chara01.png",
		"chara02.png",
		"chara03.png",
		"chara04.png",
		"chara05.png",
		"chara06.png",
		"chara07.png",
		"chara08.png",
		"chara09.png",
		"chara10.png",
		"chara11.png",
	};
	
	ImageAnimationView *animView = new ImageAnimationView(controller);
	for (int i = 0; i < 12; i++) {
		ImageView *image = new ImageView(controller);
		image->setFigure(tex->makePlate(filename[i]));
		image->setTexture(&tex->getTexture());
		animView->addView(image);
	}
	
	// 下
	animView->addAnimationFrame(1, 0, 0.12);
	animView->addAnimationFrame(1, 2, 0.12);
	// 上
	animView->addAnimationFrame(2, 9, 0.12);
	animView->addAnimationFrame(2, 11, 0.12);
	// 右
	animView->addAnimationFrame(3, 6, 0.12);
	animView->addAnimationFrame(3, 8, 0.12);
	// 左
	animView->addAnimationFrame(4, 3, 0.12);
	animView->addAnimationFrame(4, 5, 0.12);
	
	animView->setAnimationFrameIndex(1);
	animView->setUserID(10);
//.........这里部分代码省略.........
开发者ID:HitoshiHaga,项目名称:GCube,代码行数:101,代码来源:SceneTitle.cpp


注:本文中的ViewGroup::addView方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。