Exemplo n.º 1
0
    public static UIScrollableVerticalLayout createScrollableLayout(UIToolkit toolkit, Vector2 size)
    {
        UIScrollableVerticalLayout layout = new UIScrollableVerticalLayout(0);

        layout.alignMode = UIAbstractContainer.UIContainerAlignMode.Left;
        layout.positionFromBottom(0);           // Position it at the bottom of the screen to keep it out of the view.
        layout.edgeInsets = new UIEdgeInsets(0, 0, 0, 10);
        layout.setSize(size.x, size.y);

        // Create the scrollbar
        UIVerticalPanel scrollbar  = UIVerticalPanel.create(toolkit, "scrollbar_top.png", "scrollbar_mid.png", "scrollbar_bottom.png");
        int             spacerSize = 16;

        hd(ref spacerSize);
        UISpacer spacer = new UISpacer(spacerSize, spacerSize);

        scrollbar.addChild(spacer);

        layout.addScrollBar(scrollbar, spacer);
        return(layout);
    }
    void Start()
    {
        var scrollable = new UIScrollableVerticalLayout( 10 );
        scrollable.position = new Vector3( 0, -50, 0 );
        var width = UI.instance.isHD ? 300 : 150;
        scrollable.setSize( width, Screen.height / 1.4f );

        for( var i = 0; i < 20; i++ )
        {
            UITouchableSprite touchable;
            if( i % 3 == 0 )
            {
                touchable = UIToggleButton.create( "cbUnchecked.png", "cbChecked.png", "cbDown.png", 0, 0 );
            }
            else if( i % 2 == 0 )
            {
                touchable = UIButton.create( "playUp.png", "playDown.png", 0, 0 );
            }
            else
            {
                touchable = UIButton.create( "optionsUp.png", "optionsDown.png", 0, 0 );
            }

            // only add a touchUpInside handler for buttons
            if( touchable is UIButton )
            {
                var button = touchable as UIButton;

                // store i locally so we can put it in the closure scope of the touch handler
                var j = i;
                button.onTouchUpInside += ( sender ) => Debug.Log( "touched button: " + j );
            }

            scrollable.addChild( touchable );
        }

        // click to scroll to a specific offset
        var scores = UIButton.create( "scoresUp.png", "scoresDown.png", 0, 0 );
        scores.positionFromTopRight( 0, 0 );
        scores.highlightedTouchOffsets = new UIEdgeOffsets( 30 );
        scores.onTouchUpInside += ( sender ) =>
        {
            scrollable.scrollTo( -10, true );
        };

        scores = UIButton.create( "scoresUp.png", "scoresDown.png", 0, 0 );
        scores.positionFromBottomRight( 0, 0 );
        scores.highlightedTouchOffsets = new UIEdgeOffsets( 30 );
        scores.onTouchUpInside += ( sender ) =>
        {
            scrollable.scrollTo( -600, true );
        };

        scores = UIButton.create( "scoresUp.png", "scoresDown.png", 0, 0 );
        scores.centerize();
        scores.positionFromTopRight( 0.5f, 0 );
        scores.highlightedTouchOffsets = new UIEdgeOffsets( 30 );
        scores.onTouchUpInside += ( sender ) =>
        {
            var target = scrollable.position;
            var moveBy = _movedContainer ? -100 : 100;
            if( !UI.instance.isHD )
                moveBy /= 2;
            target.x += moveBy * 2;
            target.y += moveBy;
            scrollable.positionTo( 0.4f, target, Easing.Quintic.easeIn );
            _movedContainer = !_movedContainer;
        };
    }
	void Start()
	{
		var scrollable = new UIScrollableVerticalLayout( 10 );
		scrollable.position = new Vector3( 0, -50, 0 );
		var width = UI.instance.isHD ? 300 : 150;
		scrollable.setSize( width, Screen.height / 1.4f );
		
		for( var i = 0; i < 20; i++ )
		{
			UITouchableSprite touchable;
			if( i % 3 == 0 )
			{
				touchable = UIToggleButton.create( "cbUnchecked.png", "cbChecked.png", "cbDown.png", 0, 0 );
			}
			else if( i % 2 == 0 )
			{
				touchable = UIButton.create( "playUp.png", "playDown.png", 0, 0 );
			}
			else
			{
				touchable = UIButton.create( "optionsUp.png", "optionsDown.png", 0, 0 );
			}
			if (i == 1) {
				var ch = UIToggleButton.create("cbUnchecked.png", "cbChecked.png", "cbDown.png", 0, 0);
				ch.parentUIObject = touchable;
				ch.pixelsFromRight(0);
				ch.client.name = "TEST THINGY";
				ch.scale = new Vector3(0.5f, 0.5f, 1);
			}
			if (i == 4) {
				var text = new UIText(TextManager, "prototype", "prototype.png");

				var helloText = text.addTextInstance("Child Text", 0, 0,0.5f,-1,Color.cyan,UITextAlignMode.Center,UITextVerticalAlignMode.Middle);
				helloText.parentUIObject = touchable;
				helloText.positionCenter();

				var ch = UIToggleButton.create("cbUnchecked.png", "cbChecked.png", "cbDown.png", 0, 0);
				ch.parentUIObject = helloText;
				ch.pixelsFromRight(-16);
				ch.client.name = "subsub";
				ch.scale = new Vector3(0.25f, 0.25f, -2);
			}

			
			// only add a touchUpInside handler for buttons
			if( touchable is UIButton )
			{
				var button = touchable as UIButton;
				
				// store i locally so we can put it in the closure scope of the touch handler
				var j = i;
				button.onTouchUpInside += ( sender ) => Debug.Log( "touched button: " + j );
			}

			
			scrollable.addChild( touchable );
		}
		
		
		// click to scroll to a specific offset
		var scores = UIButton.create( "scoresUp.png", "scoresDown.png", 0, 0 );
		scores.positionFromTopRight( 0, 0 );
		scores.highlightedTouchOffsets = new UIEdgeOffsets( 30 );
		scores.onTouchUpInside += ( sender ) =>
		{
			scrollable.scrollTo( -10, true );
		};
		
		
		scores = UIButton.create( "scoresUp.png", "scoresDown.png", 0, 0 );
		scores.positionFromBottomRight( 0, 0 );
		scores.highlightedTouchOffsets = new UIEdgeOffsets( 30 );
		scores.onTouchUpInside += ( sender ) =>
		{
			scrollable.scrollTo( -600, true );
		};
		
		
		scores = UIButton.create( "scoresUp.png", "scoresDown.png", 0, 0 );
		scores.centerize();
		scores.positionFromTopRight( 0.5f, 0 );
		scores.highlightedTouchOffsets = new UIEdgeOffsets( 30 );
		scores.onTouchUpInside += ( sender ) =>
		{
			var target = scrollable.position;
			var moveBy = _movedContainer ? -100 : 100;
			if( !UI.instance.isHD )
				moveBy /= 2;
			target.x += moveBy * 2;
			target.y += moveBy;
			scrollable.positionTo( 0.4f, target, Easing.Quintic.easeIn );
			_movedContainer = !_movedContainer;
		};
	}
Exemplo n.º 4
0
    //game store
    void Start()
    {
        AudioScript.status = true;
        var scaleFactor = ScaleFactor.GetScaleFactor();
        var backButton  = UIButton.create(backManager, "back_normal2.png", "back_active2.png", 0, 0);

        backButton.highlightedTouchOffsets = new UIEdgeOffsets(30);
        backButton.touchDownSound          = audioplay.getSoundClip();
        backButton.onTouchUpInside        += sender => Application.LoadLevel("AGAIN");
        backButton.positionFromCenter(0.43f, 0.05f);
        backButton.setSize(backButton.width / scaleFactor * 1f, backButton.height / scaleFactor * 1f);

        var scrollable = new UIScrollableVerticalLayout(10);

        scrollable.alignMode      = UIAbstractContainer.UIContainerAlignMode.Center;
        scrollable.parentUIObject = backButton;
        scrollable.positionFromCenter(-12.5f, -2.2f);
        scrollable.setSize(Screen.width / 1.1f, Screen.height / 1.7f);


        for (var i = 0; i < 15; i++)
        {
            UIButton touchable;
            if (i == 4)              // text sprite
            {
                touchable = UIButton.create(storeManager, "4.png", "4.png", 0, 0);
                touchable.setSize(touchable.width / scaleFactor - 50f, touchable.height / scaleFactor - 20f);
                touchable.userData         = "Click";
                touchable.onTouchUpInside += (sender) => Application.LoadLevel("shortcuts");
                touchable.onTouchUp       += OnButtonUp;
                touchable.onTouchDown     += OnButtonDown;
                touchable.onTouchUpInside += OnButtonSelect;
                touchable.parentUIObject   = scrollable;
            }
            else if (i % 3 == 0)
            {
                touchable = UIButton.create("3.png", "3.png", 0, 0);
                touchable.setSize(touchable.width / scaleFactor - 50f, touchable.height / scaleFactor - 20f);
                touchable.onTouchUpInside += (sender) => Application.LoadLevel("shortcuts");
                touchable.onTouchUp       += OnButtonUp;
                touchable.onTouchDown     += OnButtonDown;
                touchable.onTouchUpInside += OnButtonSelect;
                touchable.parentUIObject   = scrollable;
            }
            else if (i % 2 == 0)
            {
                touchable = UIButton.create("2.png", "2.png", 0, 0);
                touchable.setSize(touchable.width / scaleFactor - 50f, touchable.height / scaleFactor - 20f);
                touchable.onTouchUpInside += (sender) => Application.LoadLevel("shortcuts");
                touchable.onTouchUp       += OnButtonUp;
                touchable.onTouchDown     += OnButtonDown;
                touchable.onTouchUpInside += OnButtonSelect;
                touchable.parentUIObject   = scrollable;
            }
            else
            {
                touchable = UIButton.create("1.png", "1.png", 0, 0);
                touchable.setSize(touchable.width / scaleFactor - 50f, touchable.height / scaleFactor - 20f);
                touchable.onTouchUpInside += (sender) => Application.LoadLevel("shortcuts");
                touchable.onTouchUp       += OnButtonUp;
                touchable.onTouchDown     += OnButtonDown;
                touchable.onTouchUpInside += OnButtonSelect;
                touchable.parentUIObject   = scrollable;
            }
            scrollable.addChild(touchable);
        }
    }
    void Start()
    {
        var scrollable = new UIScrollableVerticalLayout(10);

        scrollable.alignMode = UIAbstractContainer.UIContainerAlignMode.Center;
        scrollable.position  = new Vector3(0, -50, 0);
        var width = UI.isHD ? 300 : 150;

        scrollable.setSize(width, Screen.height / 1.4f);

        for (var i = 0; i < 20; i++)
        {
            UITouchableSprite touchable;
            if (i == 4)              // text sprite
            {
                touchable = UIButton.create("emptyUp.png", "emptyDown.png", 0, 0);
            }
            else if (i % 3 == 0)
            {
                touchable = UIToggleButton.create("cbUnchecked.png", "cbChecked.png", "cbDown.png", 0, 0);
            }
            else if (i % 2 == 0)
            {
                touchable = UIButton.create("playUp.png", "playDown.png", 0, 0);
            }
            else
            {
                touchable = UIButton.create("optionsUp.png", "optionsDown.png", 0, 0);
            }


            // extra flair added by putting some child objects in some of the buttons created above
            if (i == 1)
            {
                // add a toggle button to the first element in the list
                var ch = UIToggleButton.create("cbUnchecked.png", "cbChecked.png", "cbDown.png", 0, 0);
                ch.parentUIObject = touchable;
                ch.pixelsFromRight(0);
                ch.client.name = "TEST THINGY";
                ch.scale       = new Vector3(0.5f, 0.5f, 1);
            }
            else if (i == 4)
            {
                // add some text to the 4th element in the list
                var text = new UIText(textManager, "prototype", "prototype.png");

                var helloText = text.addTextInstance("Child Text", 0, 0, 0.5f, -1, Color.black, UITextAlignMode.Center, UITextVerticalAlignMode.Middle);
                helloText.parentUIObject = touchable;
                helloText.positionCenter();

                // add a scaled down toggle button as well but this will be parented to the text
                var ch = UIToggleButton.create("cbUnchecked.png", "cbChecked.png", "cbDown.png", 0, 0);
                ch.parentUIObject = helloText;
                ch.pixelsFromRight(-16);
                ch.client.name = "subsub";
                ch.scale       = new Vector3(0.25f, 0.25f, 0);
            }


            // only add a touchUpInside handler for buttons
            if (touchable is UIButton)
            {
                var button = touchable as UIButton;

                // store i locally so we can put it in the closure scope of the touch handler
                var j = i;
                button.onTouchUpInside += (sender) => Debug.Log("touched button: " + j);
            }

            scrollable.addChild(touchable);
        }


        // click to scroll to a specific offset
        var scores = UIButton.create("scoresUp.png", "scoresDown.png", 0, 0);

        scores.positionFromTopRight(0, 0);
        scores.highlightedTouchOffsets = new UIEdgeOffsets(30);
        scores.onTouchUpInside        += (sender) =>
        {
            scrollable.scrollTo(-10, true);
        };


        scores = UIButton.create("scoresUp.png", "scoresDown.png", 0, 0);
        scores.positionFromBottomRight(0, 0);
        scores.highlightedTouchOffsets = new UIEdgeOffsets(30);
        scores.onTouchUpInside        += (sender) =>
        {
            scrollable.scrollTo(-600, true);
        };


        scores = UIButton.create("scoresUp.png", "scoresDown.png", 0, 0);
        scores.centerize();
        scores.positionFromTopRight(0.5f, 0);
        scores.highlightedTouchOffsets = new UIEdgeOffsets(30);
        scores.onTouchUpInside        += (sender) =>
        {
            var target = scrollable.position;
            var moveBy = _movedContainer ? -100 : 100;
            if (!UI.isHD)
            {
                moveBy /= 2;
            }
            target.x += moveBy * 2;
            target.y += moveBy;
            scrollable.positionTo(0.4f, target, Easing.Quintic.easeIn);
            _movedContainer = !_movedContainer;
        };
    }
	void Start()
	{
		var scrollable = new UIScrollableVerticalLayout( 10 );
		scrollable.alignMode = UIAbstractContainer.UIContainerAlignMode.Center;
		scrollable.position = new Vector3( 0, -50, 0 );
		var width = UI.scaleFactor * 150;
		scrollable.setSize( width, Screen.height / 1.4f );
		
		for( var i = 0; i < 20; i++ )
		{
			UITouchableSprite touchable;
			if( i == 4 ) // text sprite
			{
				touchable = UIButton.create( "emptyUp.png", "emptyDown.png", 0, 0 );
			}
			else if( i % 3 == 0 )
			{
				touchable = UIToggleButton.create( "cbUnchecked.png", "cbChecked.png", "cbDown.png", 0, 0 );
			}
			else if( i % 2 == 0 )
			{
				touchable = UIButton.create( "playUp.png", "playDown.png", 0, 0 );
			}
			else
			{
				touchable = UIButton.create( "optionsUp.png", "optionsDown.png", 0, 0 );
			}
			
			
			// extra flair added by putting some child objects in some of the buttons created above
			if( i == 1 )
			{
				// add a toggle button to the first element in the list
				var ch = UIToggleButton.create( "cbUnchecked.png", "cbChecked.png", "cbDown.png", 0, 0 );
				ch.parentUIObject = touchable;
				ch.pixelsFromRight( 0 );
				ch.client.name = "TEST THINGY";
				ch.scale = new Vector3( 0.5f, 0.5f, 1 );
			}
			else if( i == 4 )
			{
				// add some text to the 4th element in the list
				var text = new UIText( textManager, "prototype", "prototype.png" );

				var helloText = text.addTextInstance( "Child Text", 0, 0, 0.5f, -1, Color.black, UITextAlignMode.Center, UITextVerticalAlignMode.Middle );
				helloText.parentUIObject = touchable;
				helloText.positionCenter();
				
				// add a scaled down toggle button as well but this will be parented to the text
				var ch = UIToggleButton.create( "cbUnchecked.png", "cbChecked.png", "cbDown.png", 0, 0 );
				ch.parentUIObject = helloText;
				ch.pixelsFromRight( -16 );
				ch.client.name = "subsub";
				ch.scale = new Vector3( 0.25f, 0.25f, 0 );
			}

			
			// only add a touchUpInside handler for buttons
			if( touchable is UIButton )
			{
				var button = touchable as UIButton;
				
				// store i locally so we can put it in the closure scope of the touch handler
				var j = i;
				button.onTouchUpInside += ( sender ) => Debug.Log( "touched button: " + j );
			}

			scrollable.addChild( touchable );
		}
		
		
		// click to scroll to a specific offset
		var scores = UIButton.create( "scoresUp.png", "scoresDown.png", 0, 0 );
		scores.positionFromTopRight( 0, 0 );
		scores.highlightedTouchOffsets = new UIEdgeOffsets( 30 );
		scores.onTouchUpInside += ( sender ) =>
		{
			scrollable.scrollTo( -10, true );
		};
		
		
		scores = UIButton.create( "scoresUp.png", "scoresDown.png", 0, 0 );
		scores.positionFromBottomRight( 0, 0 );
		scores.highlightedTouchOffsets = new UIEdgeOffsets( 30 );
		scores.onTouchUpInside += ( sender ) =>
		{
			scrollable.scrollTo( -600, true );
		};
		
		
		scores = UIButton.create( "scoresUp.png", "scoresDown.png", 0, 0 );
		scores.centerize();
		scores.positionFromTopRight( 0.5f, 0 );
		scores.highlightedTouchOffsets = new UIEdgeOffsets( 30 );
		scores.onTouchUpInside += ( sender ) =>
		{
			var target = scrollable.position;
			var moveBy = _movedContainer ? -50 : 50;
			moveBy *= UI.scaleFactor;
			target.x += moveBy * 2;
			target.y += moveBy;
			scrollable.positionTo( 0.4f, target, Easing.Quintic.easeIn );
			_movedContainer = !_movedContainer;
		};
	}
	void Start()
	{
		var scrollable = new UIScrollableVerticalLayout( 10 );
		scrollable.position = new Vector3( 0, -50, 0 );
		var width = UI.instance.isHD ? 300 : 150;
		scrollable.setSize( width, Screen.height / 1.4f );
		
		for( var i = 0; i < 20; i++ )
		{
			UITouchableSprite touchable;
			if( i % 3 == 0 )
			{
				touchable = UIToggleButton.create( "cbUnchecked.png", "cbChecked.png", "cbDown.png", 0, 0 );
			}
			else if( i % 2 == 0 )
			{
				touchable = UIButton.create( "playUp.png", "playDown.png", 0, 0 );
			}
			else
			{
				touchable = UIButton.create( "optionsUp.png", "optionsDown.png", 0, 0 );
			}
			
			// only add a touchUpInside handler for buttons
			if( touchable is UIButton )
			{
				var button = touchable as UIButton;
				
				// store i locally so we can put it in the closure scope of the touch handler
				var j = i;
				button.onTouchUpInside += ( sender ) => Debug.Log( "touched button: " + j );
			}

			
			scrollable.addChild( touchable );
		}
		
		
		// click to scroll to a specific offset
		var scores = UIButton.create( "scoresUp.png", "scoresDown.png", 0, 0 );
		scores.positionFromTopRight( 0, 0 );
		scores.highlightedTouchOffsets = new UIEdgeOffsets( 30 );
		scores.onTouchUpInside += ( sender ) =>
		{
			scrollable.scrollTo( -10, true );
		};
		
		
		scores = UIButton.create( "scoresUp.png", "scoresDown.png", 0, 0 );
		scores.positionFromBottomRight( 0, 0 );
		scores.highlightedTouchOffsets = new UIEdgeOffsets( 30 );
		scores.onTouchUpInside += ( sender ) =>
		{
			scrollable.scrollTo( -600, true );
		};
		
		
		scores = UIButton.create( "scoresUp.png", "scoresDown.png", 0, 0 );
		scores.centerize();
		scores.positionFromTopRight( 0.5f, 0 );
		scores.highlightedTouchOffsets = new UIEdgeOffsets( 30 );
		scores.onTouchUpInside += ( sender ) =>
		{
			var target = scrollable.position;
			var moveBy = _movedContainer ? -100 : 100;
			if( !UI.instance.isHD )
				moveBy /= 2;
			target.x += moveBy * 2;
			target.y += moveBy;
			scrollable.positionTo( 0.4f, target, Easing.Quintic.easeIn );
			_movedContainer = !_movedContainer;
		};
	}
Exemplo n.º 8
0
    public static UIScrollableVerticalLayout createScrollableLayout( UIToolkit toolkit, Vector2 size )
    {
        UIScrollableVerticalLayout layout = new UIScrollableVerticalLayout(0);
        layout.alignMode = UIAbstractContainer.UIContainerAlignMode.Left;
        layout.positionFromBottom( 0 ); // Position it at the bottom of the screen to keep it out of the view.
        layout.edgeInsets = new UIEdgeInsets( 0, 0, 0, 10 );
        layout.setSize( size.x, size.y );

        // Create the scrollbar
        UIVerticalPanel scrollbar = UIVerticalPanel.create( toolkit, "scrollbar_top.png", "scrollbar_mid.png", "scrollbar_bottom.png" );
        int spacerSize = 16;
        hd( ref spacerSize );
        UISpacer spacer = new UISpacer( spacerSize, spacerSize );
        scrollbar.addChild( spacer );

        layout.addScrollBar( scrollbar, spacer );
        return layout;
    }