コード例 #1
0
        TextureLine(spNativeTexture t)
        {
            setVerticalMode(Box9Sprite::TILING_FULL);
            setHorizontalMode(Box9Sprite::TILING_FULL);
            Sprite::setResAnim(DebugActor::resSystem->getResAnim("checker"));

            AnimationFrame f;
            Vector2 s = fitSize(itemSize, Vector2((float)t->getWidth(), (float)t->getHeight()));

            setSize(s);

            Diffuse df;
            df.base = t;

            f.init(0, df, RectF(0, 0, 1.0f, 1.0f), RectF(0, 0, s.x, s.y), s);
            spSprite image = initActor(new Sprite,
                                       arg_blend = blend_disabled,
                                       arg_resAnim = f);
            addChild(image);

            spColorRectSprite rect = initActor(new ColorRectSprite,
                                               arg_color = Color(Color::White, 255),
                                               arg_attachTo = this);

            rect->addTween(Sprite::TweenColor(Color(Color::White, 0)), 4000, -1, true);

            char path[255];
            path::normalize(t->getName().c_str(), path);

            char txt[255];
            safe_sprintf(txt, "%s\n<div c=\"FF0000\">%s</div>-<div c=\"0000ff\">%dx%d</div>\nid: %d",
                         path,
                         textureFormat2String(t->getFormat()),
                         t->getWidth(), t->getHeight(), t->getObjectID());

            spTextField text = initActor(new TextField,
                                         arg_color = Color::Black,
                                         arg_w = (float)itemSize.x,
                                         arg_vAlign = TextStyle::VALIGN_TOP,
                                         arg_hAlign = TextStyle::HALIGN_LEFT,
                                         arg_multiline = true,
                                         arg_attachTo = rect,
                                         arg_htmlText = txt
                                        );

            text->setBreakLongWords(true);

            rect->setSize(text->getTextRect().size.cast<Vector2>() + Vector2(2, 2));
            rect->setY((itemSize.y - rect->getHeight()) / 2.0f);
        }
コード例 #2
0
GameScene::GameScene()
{
	//create game actor
	_game = new Game;
	_game->init();
	_game->attachTo(_view);

	//Game Actor would have own Clock.
	//clock is internal time of each Actor
	//by default own clock has only Stage
	//clock could be paused and all children of this Actor would be paused to
	_game->setClock(new Clock);

	//create menu button 
	spActor btn = initActor(new MyButton,
		arg_resAnim = res::ui.getResAnim("menu"),
		arg_anchor = Vector2(0.5f, 0.5f),
		arg_attachTo = _view);
	
	//align it to top right
	btn->setX(_view->getWidth() - btn->getWidth()/2);
	btn->setY(btn->getHeight()/2);

	//handle click to menu
	btn->addEventListener(TouchEvent::CLICK, CLOSURE(this, &GameScene::onEvent));

	//subscribe to Hidden Event from GameMenu
	GameMenu::instance->addEventListener(GameScene::HiddenEvent::EVENT, CLOSURE(this, &GameScene::onEvent));
}
コード例 #3
0
ファイル: lab1.cpp プロジェクト: semajrolyat/gwucs6555
//------------------------------------------------------------------------------
void init(void)
{

   glClearColor (0.0, 0.0, 0.0, 0.0);
   glClearDepth (1.0);
   glShadeModel (GL_SMOOTH);
   glEnable( GL_LINE_SMOOTH );

   initCamera();
   initActor();
}
コード例 #4
0
	void DebugActor::addButton(float &x, const char *name, const char *anim)
	{
		spButton btn;
		btn = initActor(new Button,
			arg_resAnim = resSystem->getResAnim(anim),
			arg_y = 1,
			arg_name = name,
			arg_attachTo = this);
		x = x - btn->getWidth();
		btn->setX(x);
		btn->addEventListener(TouchEvent::CLICK, CLOSURE(this, &DebugActor::_btnClicked));
	}
コード例 #5
0
ファイル: MemoryOneModeNetwork.cpp プロジェクト: cran/NetSim
void MemoryOneModeNetwork::init(int size, bool directed, bool reflexive){

	_size = size; // updated by addActor function
	_directed = directed;
	_reflexive = reflexive;

	// initialize lookup maps
	for (int i = 0; i < size; i++){
		initActor(i);
	}

}
コード例 #6
0
ファイル: test.cpp プロジェクト: Yahor10/oxygine-framework
void Test::addToggle(std::string id, const toggle* t, int num)
{
    spButton button = createButtonHelper(new Toggle(t, num), t[0].text, CLOSURE(this, &Test::_toggleClicked));
    initActor(button.get(),
              arg_name = id,
              arg_attachTo = ui,
              arg_anchor = Vector2(0.5f, 0.0f),
              arg_pos = Vector2(_x, _y));

    _y += button->getHeight() + 2.0f;

    if (_y + button->getHeight() >= getHeight())
    {
        _y = 0;
        _x += button->getWidth() + 70;
    }
}
コード例 #7
0
GameScene::GameScene()
{
    //create game actor
    _game = new Game;
    _game->init();
    _game->attachTo(_view);

    //create menu button
    spActor btn = initActor(new MyButton,
                            arg_resAnim = res::ui.getResAnim("menu"),
                            arg_anchor = Vector2(0.5f, 0.5f),
                            arg_attachTo = _view);

    //align it to top right
    btn->setX(_view->getWidth() - btn->getWidth() / 2);
    btn->setY(btn->getHeight() / 2);

    btn->addEventListener(TouchEvent::CLICK, CLOSURE(this, &GameScene::onEvent));
}
コード例 #8
0
ファイル: test.cpp プロジェクト: CoolDm/oxygine-billing
spButton Test::addButton(std::string id, std::string txt)
{
    spButton button = createButtonHelper(new Button, txt, CLOSURE(this, &Test::_clicked));
    initActor(button.get(),
              arg_name = id,
              arg_attachTo = ui,
              arg_anchor = Vector2(0.5f, 0.0f),
              arg_pos = Vector2(_x, _y));

    _y += button->getHeight() + 2.0f;

    if (_y + button->getHeight() >= getHeight())
    {
        _y = 0;
        _x += button->getWidth() + 70;
    }

    return button;
}
コード例 #9
0
void MyButton::setText(const string& txt)
{
    if (!_text)
    {
        //create TextField if it wasn't created yet
        TextStyle style;
        style.font = res::ui.getResFont("normal")->getFont();
        style.vAlign = TextStyle::VALIGN_MIDDLE;
        style.hAlign = TextStyle::HALIGN_CENTER;

        //attach it to MyButton and set the same size as button
        //text would be centered
        _text = initActor(new TextField,
                          arg_style = style,
                          arg_size = getSize(),
                          arg_addTo = this);
    }

    _text->setText(txt);
}
コード例 #10
0
ファイル: DeveloperMenu.cpp プロジェクト: gotonis/danmake
	void DeveloperMenu::init(const Vector2 &size, const char *text, spActor data, const Color &color)
	{
		const float BORDER = 3;

		float offset = 24;

		setSize(size);
		setWidth(data->getWidth() + BORDER * 2);
		setHeight(size.y + offset);
		//setSize(data->getSize() + Point(0, offset));

		spColorRectSprite top = new ColorRectSprite();
		top->setWidth(getWidth());
		top->setSize(size);


		_topDrag.init(top.get());
		_topDrag.setDragClient(this);
		
		addChild(top);

		

		top->setColor(windowColor);
		top->setSize(Vector2(getWidth(), offset));
		top->setPriority(100);

		spColorRectSprite body = new ColorRectSprite();
		body->setColor(color);
		addChild(body);

		

		body->setSize(Vector2(getWidth() - BORDER * 2, getHeight()));
		body->setX(BORDER);
		body->setY((float)offset);


		_body = body;	


		TextStyle style;
		style.font = _resSystem->getResFont("system")->getFont();
		style.vAlign = TextStyle::VALIGN_TOP;

		spButton close = initActor(new Button,
			arg_y = offset/2,
			arg_x = offset/2,
			arg_anchor = Vector2(0.5f, 0.5f),
			arg_resAnim = _resSystem->getResAnim("remove"),
			arg_attachTo = top);
		close->addEventListener(TouchEvent::CLICK, CLOSURE(this, &DeveloperMenu::close));


		spTextField title = initActor(new TextField,
			arg_style = style,
			arg_hAlign = TextStyle::HALIGN_MIDDLE,
			arg_vAlign = TextStyle::VALIGN_MIDDLE,
			arg_text = text,
			arg_width = top->getWidth(),
			arg_height = top->getHeight(),
			arg_input = false,
			arg_attachTo = top);

		//title->setSize(close->getTextRect().size);
		title->addEventListener(TouchEvent::CLICK, CLOSURE(this, &DeveloperMenu::close));

		data->attachTo(body);
	}
コード例 #11
0
ファイル: GameMap.cpp プロジェクト: duongbadu/chessgame
void GameMap::extraInit()
{
	floorLayer = this->getLayer("floor");
	initWall();
	initActor();
}
コード例 #12
0
ファイル: MemoryOneModeNetwork.cpp プロジェクト: cran/NetSim
void MemoryOneModeNetwork::addActor(size_t id) {
	initActor(id);
	_size++;
}
コード例 #13
0
    TexturesInspector::TexturesInspector(const Vector2& size)
    {
        setSize(size);

        spSlidingActor slide = new SlidingActor;
        slide->setSize(size);
        addChild(slide);


        float offsetY = 0;

        std::vector<spNativeTexture> textures = NativeTexture::getCreatedTextures();


        spTextField text = initActor(new TextField,
                                     arg_color = Color::White,
                                     arg_pos = Vector2(1, 1),
                                     arg_w = itemSize.x * 3.0f,
                                     arg_h = 30.0f,
                                     arg_vAlign = TextStyle::VALIGN_TOP,
                                     arg_hAlign = TextStyle::HALIGN_LEFT,
                                     arg_multiline = true,
                                     arg_attachTo = slide
                                    );


        offsetY += text->getTextRect().getBottom() + 5;

        spActor content = new Actor;
        content->setX(2);


        int numX = (int)(size.x / itemSize.x);

        int n = 0;
        int mem = 0;
        for (std::vector<spNativeTexture>::iterator i = textures.begin(); i != textures.end(); ++i)
        {
            spNativeTexture t = *i;
            TextureLine* line = new TextureLine(t);

            float x = (n % numX) * (itemSize.x + 5.0f);
            float y = (n / numX) * (itemSize.y + 5.0f);
            line->setX(x);
            line->setY(y + offsetY);
            content->addChild(line);
            ++n;

            mem += t->getSizeVRAM();
        }

        char txt[255];
        safe_sprintf(txt, "created textures: %d, vram: %d kb", textures.size(), mem / 1024);

        text->setText(txt);
        if (numX > n)
            numX = n;

        content->setSize(
            (itemSize.x + 5.0f) * numX,
            (itemSize.y + 5.0f) * (n + numX - 1.0f) / numX + offsetY);

        setWidth(content->getWidth());
        slide->setWidth(content->getWidth());

        //slide->setSize()
        slide->setContent(content);
    }
コード例 #14
0
    TexturesInspector::TexturesInspector(const Vector2& size)
    {
        setSize(size);

        spSlidingActor slide = new SlidingActor;
        slide->setSize(size);
        addChild(slide);


        float offsetY = 0;

        std::vector<spNativeTexture> textures = NativeTexture::getCreatedTextures();


        spTextField text = initActor(new TextField,
                                     arg_color = Color::White,
                                     arg_pos = Vector2(1, 1),
                                     arg_w = itemSize.x * 3.0f,
                                     arg_h = 30.0f,
                                     arg_vAlign = TextStyle::VALIGN_TOP,
                                     arg_hAlign = TextStyle::HALIGN_LEFT,
                                     arg_multiline = true,
                                     arg_attachTo = slide
                                    );


        offsetY += text->getTextRect().getBottom() + 5;

        spActor content = new Actor;
        content->setX(2);


        int numX = (int)(size.x / itemSize.x);

        int n = 0;
        int mem = 0;
        for (std::vector<spNativeTexture>::reverse_iterator i = textures.rbegin(); i != textures.rend(); ++i)
        {
            spNativeTexture t = *i;
            TextureLine* line = new TextureLine(t);

            float x = (n % numX) * (itemSize.x + 5.0f);
            float y = (n / numX) * (itemSize.y + 5.0f);
            line->setX(x);
            line->setY(y + offsetY);
            content->addChild(line);
            ++n;

            if (t->getHandle())
            {
                TextureFormat fmt = t->getFormat();
                int ram = t->getWidth() * t->getHeight();
                if (isCompressedFormat(fmt))
                {
                    switch (fmt)
                    {
                        case TF_PVRTC_4RGBA:
                            ram /= 2;
                            break;
                        case TF_ETC1:
                            ram /= 2;
                            break;
                        default:
                            break;
                    }
                }
                else
                    ram *= getBytesPerPixel(fmt);

                mem += ram;
            }
        }

        char txt[255];
        safe_sprintf(txt, "created textures: %d, vram: %d kb", textures.size(), mem / 1024);

        text->setText(txt);
        if (numX > n)
            numX = n;

        content->setSize(
            (itemSize.x + 5.0f) * numX,
            (itemSize.y + 5.0f) * (n + numX - 1.0f) / numX + offsetY);

        setWidth(content->getWidth());
        slide->setWidth(content->getWidth());

        //slide->setSize()
        slide->setContent(content);
    }