Exemplo n.º 1
0
        public CCControlColourPicker()
        {
            // Register Touch Event
            var touchListener = new CCEventListenerTouchOneByOne();

            touchListener.IsSwallowTouches = true;
            touchListener.OnTouchBegan     = OnTouchBegan;

            AddEventListener(touchListener);

            CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFrames("extensions/CCControlColourPickerSpriteSheet.plist");

            var spriteSheet = new CCSpriteBatchNode("extensions/CCControlColourPickerSpriteSheet.png");

            AddChild(spriteSheet);

            Hsv.H = 0;
            Hsv.S = 0;
            Hsv.V = 0;

            // Add image
            Background
                = CCControlUtils.AddSpriteToTargetWithPosAndAnchor("menuColourPanelBackground.png", spriteSheet, CCPoint.Zero, new CCPoint(0.5f, 0.5f));

            CCPoint backgroundPointZero
                = Background.Position - new CCPoint(Background.ContentSize.Width / 2, Background.ContentSize.Height / 2);

            // Setup panels
            float hueShift    = 8;
            float colourShift = 28;

            CCPoint huePickerPos = new CCPoint(backgroundPointZero.X + hueShift, backgroundPointZero.Y + hueShift);

            HuePicker = new CCControlHuePicker(spriteSheet, huePickerPos);

            CCPoint colourPickerPos = new CCPoint(backgroundPointZero.X + colourShift, backgroundPointZero.Y + colourShift);

            ColourPicker = new CCControlSaturationBrightnessPicker(spriteSheet, colourPickerPos);

            // Setup events
            HuePicker.AddTargetWithActionForControlEvents(this, HueSliderValueChanged, CCControlEvent.ValueChanged);
            ColourPicker.AddTargetWithActionForControlEvents(this, ColourSliderValueChanged, CCControlEvent.ValueChanged);

            UpdateHueAndControlPicker();
            AddChild(HuePicker);
            AddChild(ColourPicker);

            ContentSize = Background.ContentSize;
        }
        public CCControlHuePicker(CCNode target, CCPoint pos)
        {
            var touchListener = new CCEventListenerTouchOneByOne();

            touchListener.IsSwallowTouches = true;

            touchListener.OnTouchBegan = OnTouchBegan;
            touchListener.OnTouchMoved = OnTouchMoved;

            AddEventListener(touchListener);

            Background = CCControlUtils.AddSpriteToTargetWithPosAndAnchor("huePickerBackground.png", target, pos, CCPoint.Zero);
            Slider     = CCControlUtils.AddSpriteToTargetWithPosAndAnchor("colourPicker.png", target, pos, new CCPoint(0.5f, 0.5f));

            Slider.Position = new CCPoint(pos.X, pos.Y + Background.BoundingBox.Size.Height * 0.5f);
            StartPos        = pos;
        }
        public CCControlColourPicker()
        {
            // Register Touch Event
            var touchListener = new CCEventListenerTouchOneByOne();

            touchListener.IsSwallowTouches = true;
            touchListener.OnTouchBegan     = OnTouchBegan;

            AddEventListener(touchListener);

            CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFrames("extensions/CCControlColourPickerSpriteSheet.plist");

            Hsv.H = 0;
            Hsv.S = 0;
            Hsv.V = 0;

            // Add image
            Background
                = CCControlUtils.AddSpriteToTargetWithPosAndAnchor("menuColourPanelBackground.png", this, CCPoint.Zero, CCPoint.AnchorMiddle);

            CCPoint backgroundPointZero
                = Background.Position - Background.ContentSize.Center;

            // Setup panels
            float hueShift    = 8;
            float colourShift = 28;

            CCPoint huePickerPos = new CCPoint(backgroundPointZero.X + hueShift, backgroundPointZero.Y + hueShift);

            HuePicker = new CCControlHuePicker(this, huePickerPos);

            CCPoint colourPickerPos = new CCPoint(backgroundPointZero.X + colourShift, backgroundPointZero.Y + colourShift);

            ColourPicker = new CCControlSaturationBrightnessPicker(this, colourPickerPos);

            // Setup events
            HuePicker.ValueChanged    += HuePicker_ValueChanged;
            ColourPicker.ValueChanged += ColourPicker_ValueChanged;

            UpdateHueAndControlPicker();
            AddChild(HuePicker);
            AddChild(ColourPicker);

            ContentSize = Background.ContentSize;
        }
Exemplo n.º 4
0
        public CCControlSaturationBrightnessPicker(CCNode target, CCPoint pos)
        {
            Background = CCControlUtils.AddSpriteToTargetWithPosAndAnchor("colourPickerBackground.png", target, pos, CCPoint.Zero);
            Overlay    = CCControlUtils.AddSpriteToTargetWithPosAndAnchor("colourPickerOverlay.png", target, pos, CCPoint.Zero);
            Shadow     = CCControlUtils.AddSpriteToTargetWithPosAndAnchor("colourPickerShadow.png", target, pos, CCPoint.Zero);
            Slider     = CCControlUtils.AddSpriteToTargetWithPosAndAnchor("colourPicker.png", target, pos, new CCPoint(0.5f, 0.5f));

            StartPos = pos;
            boxPos   = 35;                                                      // starting position of the virtual box area for picking a colour
            boxSize  = (int)Background.ContentSize.Width / 2;                   // the size (width and height) of the virtual box for picking a colour from

            // Register Touch Event
            var touchListener = new CCEventListenerTouchOneByOne();

            touchListener.IsSwallowTouches = true;

            touchListener.OnTouchBegan = OnTouchBegan;
            touchListener.OnTouchMoved = OnTouchMoved;

            AddEventListener(touchListener);
        }