예제 #1
0
        public override bool Init()
        {
            if (base.Init())
            {
                CCSize screenSize = CCDirector.SharedDirector.WinSize;

                var layer = new CCNode();
                layer.Position = screenSize.Center;
                AddChild(layer, 1);

                float layer_width = 0;

                // Add the black background for the text
                CCScale9Sprite background = new CCScale9SpriteFile("extensions/buttonBackground.png");
                background.ContentSize = new CCSize(100, 50);
                background.Position    = new CCPoint(layer_width + background.ContentSize.Width / 2.0f, 0);
                layer.AddChild(background);

                DisplayValueLabel = new CCLabelTTF("0", "Arial", 26);

                _displayValueLabel.Position = background.Position;
                layer.AddChild(_displayValueLabel);

                layer_width += background.ContentSize.Width;

                CCControlStepper stepper = MakeControlStepper();
                stepper.Position = new CCPoint(layer_width + 10 + stepper.ContentSize.Width / 2, 0);
                stepper.AddTargetWithActionForControlEvents(this, ValueChanged,
                                                            CCControlEvent.ValueChanged);
                layer.AddChild(stepper);

                layer_width += stepper.ContentSize.Width;

                // Set the layer size
                layer.ContentSize = new CCSize(layer_width, 0);
                layer.AnchorPoint = new CCPoint(0.5f, 0.5f);

                // Update the value label
                ValueChanged(stepper, CCControlEvent.ValueChanged);
                return(true);
            }
            return(false);
        }
        public override void OnEnter()
        {
            base.OnEnter();

            CCSize screenSize = Layer.VisibleBoundsWorldspace.Size;

            var layer = new CCNode();

            layer.Position = screenSize.Center;
            AddChild(layer, 1);

            float layer_width = 0;

            // Add the black background for the text
            CCScale9Sprite background = new CCScale9SpriteFile("extensions/buttonBackground.png");

            background.ContentSize = new CCSize(100, 50);
            background.Position    = new CCPoint(layer_width + background.ContentSize.Width / 2.0f, 0);
            layer.AddChild(background);

            DisplayValueLabel = new CCLabel("0", "Arial", 26, CCLabelFormat.SpriteFont);

            DisplayValueLabel.Position = background.Position;
            layer.AddChild(DisplayValueLabel);

            layer_width += background.ContentSize.Width;

            CCControlStepper stepper = MakeControlStepper();

            stepper.Position      = new CCPoint(layer_width + 10 + stepper.ContentSize.Width / 2, 0);
            stepper.ValueChanged += Stepper_ValueChanged;
            layer.AddChild(stepper);

            layer_width += stepper.ContentSize.Width;

            // Set the layer size
            layer.ContentSize = new CCSize(layer_width, 0);
            layer.AnchorPoint = CCPoint.AnchorMiddle;

            // Update the value label
            ValueChanged(stepper, CCControlEvent.ValueChanged);
        }
예제 #3
0
        public CCControlStepperTest()
        {
            CCSize screenSize = Layer.VisibleBoundsWorldspace.Size;

            var layer = new CCNode();

            layer.Position = screenSize.Center;
            AddChild(layer, 1);

            float layer_width = 0;

            // Add the black background for the text
            CCScale9Sprite background = new CCScale9SpriteFile("extensions/buttonBackground.png");

            background.ContentSize = new CCSize(100, 50);
            background.Position    = new CCPoint(layer_width + background.ContentSize.Width / 2.0f, 0);
            layer.AddChild(background);

            DisplayValueLabel = new CCLabelTtf("0", "Arial", 26);

            _displayValueLabel.Position = background.Position;
            layer.AddChild(_displayValueLabel);

            layer_width += background.ContentSize.Width;

            CCControlStepper stepper = MakeControlStepper();

            stepper.Position = new CCPoint(layer_width + 10 + stepper.ContentSize.Width / 2, 0);
            stepper.AddTargetWithActionForControlEvents(this, ValueChanged,
                                                        CCControlEvent.ValueChanged);
            layer.AddChild(stepper);

            layer_width += stepper.ContentSize.Width;

            // Set the layer size
            layer.ContentSize = new CCSize(layer_width, 0);
            layer.AnchorPoint = new CCPoint(0.5f, 0.5f);

            // Update the value label
            ValueChanged(stepper, CCControlEvent.ValueChanged);
        }