public override void OnAwake()
    {
        CreateBackground();

        //make the start button and add it to the stage
        CinchSprite startButton = CinchSprite.NewFromImage("StartButton");

        this.AddChild(startButton);
        startButton.Width  = 3f;
        startButton.ScaleY = startButton.ScaleX;

        //give it a jaunty little tilt
        startButton.Rotation = 10f;

        //do an animation effect and start the game when startButton is pressed
        startButton.AddEventListener <MouseEvent>(MouseEvent.MOUSE_DOWN, (mouseEvent) => {
            new Tween(startButton, "ScaleX",
                      1.5f, .5f, Easing.Bounce.EaseOut, 0f);
        });

        //add an instructions text field
        SimpleTextField instructions = SimpleTextField.NewFromString("Press Start to begin!", "FjallaOne-Regular", .4f, TextAnchor.MiddleCenter);

        this.AddChildAt(instructions, 1);

        startButton.X  = ViewportWidth / 2;
        startButton.Y  = ViewportHeight / 2;
        instructions.X = startButton.X;
        instructions.Y = startButton.Y - 1.4f;
    }
Exemple #2
0
    public override void OnAwake()
    {
        CreateBackground();

        var upperLeft = SimpleTextField.NewFromString("Upper-Left", "Cinch2D/FjallaOne-Regular", .5f, TextAnchor.UpperLeft);

        upperLeft.TextColor = Color.green;
        AddChild(upperLeft);

        var lowerLeft = SimpleTextField.NewFromString("Lower-Left", "Cinch2D/FjallaOne-Regular", .5f, TextAnchor.LowerLeft);

        lowerLeft.TextColor = Color.red;
        AddChild(lowerLeft);

        var upperRight = SimpleTextField.NewFromString("Upper-Right", "Cinch2D/FjallaOne-Regular", .5f, TextAnchor.UpperRight);

        upperRight.TextColor = Color.magenta;
        AddChild(upperRight);

        var lowerRight = SimpleTextField.NewFromString("Lower-Right", "Cinch2D/FjallaOne-Regular", .5f, TextAnchor.LowerRight);

        lowerRight.TextColor = Color.cyan;
        AddChild(lowerRight);

        //this will overlap all the others, not a bug.
        var centeredText = SimpleTextField.NewFromString("Centered", "Cinch2D/FjallaOne-Regular", .5f, TextAnchor.MiddleCenter);

        AddChild(centeredText);
    }
Exemple #3
0
    public override void OnAwake()
    {
        InitFromImage("Table", 100f);

        _tf = SimpleTextField.NewFromString("Green", "Cinch2D/FjallaOne-Regular", 1f, TextAnchor.MiddleCenter);
        AddChild(_tf);
    }
    public override void OnAwake()
    {
        _background = CinchSprite.NewFromSpriteSheet("Cinch2D/ButtonParts", 0, 257, 512, 256, 256);
        AddChild(_background);

        _foreground = CinchSprite.NewFromSpriteSheet("Cinch2D/ButtonParts", 0, 0, 512, 256, 256);
        AddChild(_foreground);

        _text = SimpleTextField.NewFromString("", "Cinch2D/FjallaOne-Regular", .2f);
        AddChild(_text);

        this.AddEventListener <MouseEvent>(MouseEvent.MOUSE_DOWN, OnMouseDown);
    }
    public override void OnAwake()
    {
        base.OnAwake();
        CreateBackground();

        //create a watermelon to listen to.
        var watermelon = CinchSprite.NewFromImage("Cinch2D/Watermelon", 256);

        AddChild(watermelon);
        watermelon.Name = "Watermelon";

        //let's add a label to the melon
        var textField = SimpleTextField.NewFromString("Watermelon!", "Cinch2D/FjallaOne-Regular", .5f);

        watermelon.AddChild(textField);
        textField.Name = "TextField";

        //now add a listener.  Cinch2D implements MOUSE_DOWN, MOUSE_UP, RELEASE_OUTSIDE, MOUSE_OVER, MOUSE_OUT, and MOUSE_MOVE
        watermelon.AddEventListener <MouseEvent>(MouseEvent.MOUSE_DOWN, onWatermelonPress);
    }
Exemple #6
0
    public override void OnAwake()
    {
        var panel = CinchSprite.NewFromImage("Cinch2D/DialogBackground", 256f);

        //leave a 20% border around the edge of the panel, that won't scale
        panel.SetScale9Grid(new Rect(.2f, .2f, .6f, .6f));
        AddChild(panel);

        panel.AddEventListener <MouseEvent>(MouseEvent.MOUSE_DOWN, (e) => {
            panel.ScaleX = .1f;
            panel.ScaleY = 2f;
            new Tween(panel, "ScaleX", 1f, 2f, Easing.Bounce.EaseOut);
            new Tween(panel, "ScaleY", 1f, 2f, Easing.Bounce.EaseOut);
        });

        var instructions = SimpleTextField.NewFromString("Click panel", "Cinch2D/FjallaOne-Regular", .5f);

        AddChild(instructions);
        instructions.Y = -1.5f;
    }
Exemple #7
0
    public override void OnAwake()
    {
        var btn = Library.New <TextButton>("TextButtonInstance");

        AddChild(btn);
        btn.Text = "Cinch Button";

        //toss up a little info text to avoid confusing the user
        var info = SimpleTextField.NewFromString("Teapot is normal Unity 3D on a second camera.", "Cinch2D/FjallaOne-Regular", .25f, TextAnchor.UpperCenter);

        AddChild(info);
        info.Y = -.75f;

        var silliness = SimpleTextField.NewFromString("CHOO CHOO IT\'S THE TEAPOT TRAIN.", "Cinch2D/FjallaOne-Regular", .5f, TextAnchor.UpperCenter);

        AddChild(silliness);
        silliness.Y = 1.5f;

        //if you need to hide all the Cinch stuff entirely, you can use Stage.Disable() and Stage.Enable();
    }