public CCControlSwitch(CCSprite maskSprite, CCSprite onSprite, CCSprite offSprite, CCSprite thumbSprite, CCLabel onLabel,
                               CCLabel offLabel)
        {
            Debug.Assert(maskSprite != null, "Mask must not be nil.");
            Debug.Assert(onSprite != null, "onSprite must not be nil.");
            Debug.Assert(offSprite != null, "offSprite must not be nil.");
            Debug.Assert(thumbSprite != null, "thumbSprite must not be nil.");

            on = true;

            switchSprite          = new CCControlSwitchSprite(maskSprite, onSprite, offSprite, thumbSprite, onLabel, offLabel);
            switchSprite.Position = new CCPoint(switchSprite.ContentSize.Width / 2, switchSprite.ContentSize.Height / 2);
            AddChild(switchSprite);

            IgnoreAnchorPointForPosition = false;
            AnchorPoint = new CCPoint(0.5f, 0.5f);
            ContentSize = switchSprite.ContentSize;

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

            touchListener.IsSwallowTouches = true;

            touchListener.OnTouchBegan     = OnTouchBegan;
            touchListener.OnTouchMoved     = OnTouchMoved;
            touchListener.OnTouchEnded     = OnTouchEnded;
            touchListener.OnTouchCancelled = OnTouchCancelled;

            AddEventListener(touchListener);
        }
Пример #2
0
        public bool initWithEntryID(int entryId)
        {
			// Register Touch Event
			touchListener = new CCEventListenerTouchOneByOne();
			touchListener.IsSwallowTouches = true;

			touchListener.OnTouchBegan = onTouchBegan;
			touchListener.OnTouchMoved = onTouchMoved;
			touchListener.OnTouchEnded = onTouchEnded;

            AddEventListener(touchListener, -10);

			var keyboardListener = new CCEventListenerKeyboard ();
			keyboardListener.OnKeyPressed = onKeyPressed;
			keyboardListener.OnKeyReleased = onKeyReleased;

            AddEventListener(keyboardListener);



            m_entry = TestEntries.TestList[entryId];
            m_test = m_entry.CreateFcn();

            return true;
        }
Пример #3
0
        public CCControlPotentiometer(string backgroundFile, string progressFile, string thumbFile)
        {
            var trackSprite   = new CCSprite(backgroundFile);
            var thumbSprite   = new CCSprite(thumbFile);
            var progressTimer = new CCProgressTimer(new CCSprite(progressFile));

            minimumValue = 0.0f;
            maximumValue = 1.0f;
            value        = minimumValue;

            ProgressTimer        = progressTimer;
            ThumbSprite          = thumbSprite;
            thumbSprite.Position = progressTimer.Position;

            AddChild(thumbSprite, 2);
            AddChild(progressTimer, 1);
            AddChild(trackSprite);

            ContentSize = trackSprite.ContentSize;

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

            touchListener.IsSwallowTouches = true;

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

            AddEventListener(touchListener);
        }
Пример #4
0
 public ButtonEventDispatcher()
 {
     Listener = new CCEventListenerTouchOneByOne()
     {
         OnTouchBegan = OnTouchBegan,
         OnTouchEnded = OnTouchEnded,
     };
 }
Пример #5
0
 public virtual void Init(float width, float height)
 {
     EventListener = new CCEventListenerTouchOneByOne()
     {
         OnTouchBegan = OnTouchBegan,
         OnTouchEnded = OnTouchEnded,
     };
     ContentSize = new CCSize(width, height);
 }
        internal CCEventListenerTouchOneByOne(CCEventListenerTouchOneByOne eventListener)
            : this()
        {
            OnTouchBegan     = eventListener.OnTouchBegan;
            OnTouchMoved     = eventListener.OnTouchMoved;
            OnTouchEnded     = eventListener.OnTouchEnded;
            OnTouchCancelled = eventListener.OnTouchCancelled;

            ClaimedTouches.AddRange(eventListener.ClaimedTouches);
            IsSwallowTouches = eventListener.IsSwallowTouches;
        }
Пример #7
0
        public KeyboardNotificationLayer()
        {
            // Register Touch Event
            var touchListener = new CCEventListenerTouchOneByOne();
            touchListener.IsSwallowTouches = true;

            touchListener.OnTouchBegan = OnTouchBegan;
            touchListener.OnTouchEnded = OnTouchEnded;

            AddEventListener(touchListener);
        }
		internal CCEventListenerTouchOneByOne(CCEventListenerTouchOneByOne eventListener) 
			: this()
		{
			OnTouchBegan = eventListener.OnTouchBegan;
			OnTouchMoved = eventListener.OnTouchMoved;
			OnTouchEnded = eventListener.OnTouchEnded;
			OnTouchCancelled = eventListener.OnTouchCancelled;

            ClaimedTouches.AddRange(eventListener.ClaimedTouches);
			IsSwallowTouches = eventListener.IsSwallowTouches;

		}
Пример #9
0
            void AttachListener()
            {
                // Register Touch Event
                var listener = new CCEventListenerTouchOneByOne();
                listener.IsSwallowTouches = true;

                listener.OnTouchBegan = OnTouchBegan;
                listener.OnTouchEnded = OnTouchEnded;
                listener.OnTouchCancelled = OnTouchCancelled;

                AddEventListener(listener, this);
            }
Пример #10
0
        public KeyboardNotificationLayer()
        {
            // Register Touch Event
            var touchListener = new CCEventListenerTouchOneByOne();

            touchListener.IsSwallowTouches = true;

            touchListener.OnTouchBegan = onTouchBegan;
            touchListener.OnTouchEnded = onTouchEnded;

            AddEventListener(touchListener);
        }
Пример #11
0
        public override void OnEnter()
        {
            base.OnEnter();

			// Register Touch Event
			var listener = new CCEventListenerTouchOneByOne();
			listener.IsSwallowTouches = true;

			listener.OnTouchBegan = onTouchBegan;
			listener.OnTouchMoved = onTouchMoved;
			listener.OnTouchEnded = onTouchEnded;

			AddEventListener(listener);
        }
Пример #12
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;
        }
Пример #13
0
        protected override void AddedToScene()
        {
            base.AddedToScene();

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

            touchListener.OnTouchBegan = OnTouchBegan;
            touchListener.OnTouchEnded = OnTouchEnded;

            AddEventListener(touchListener);


        }
Пример #14
0
        public bool initWithEntryID(int entryId)
        {
            m_entryID = entryId;

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

			touchListener.OnTouchBegan = onTouchBegan;
			touchListener.OnTouchMoved = onTouchMoved;

			AddEventListener(touchListener);

            return true;
        }
Пример #15
0
        public CCControlStepper(CCSprite minusSprite, CCSprite plusSprite)
        {
            Debug.Assert(minusSprite != null, "Minus sprite must be not nil");
            Debug.Assert(plusSprite != null, "Plus sprite must be not nil");

            IsContinuous = true;
            IgnoreAnchorPointForPosition = false;
            autorepeat   = true;
            minimumValue = 0;
            maximumValue = 100;
            value        = 0;
            stepValue    = 1;
            wraps        = false;

            MinusSprite          = minusSprite;
            MinusSprite.Position = new CCPoint(minusSprite.ContentSize.Width / 2, minusSprite.ContentSize.Height / 2);
            AddChild(MinusSprite);

            MinusLabel          = new CCLabelTtf("-", ControlStepperLabelFont, 38);
            MinusLabel.Color    = ControlStepperLabelColorDisabled;
            MinusLabel.Position = new CCPoint(MinusSprite.ContentSize.Width / 2, MinusSprite.ContentSize.Height / 2);
            MinusSprite.AddChild(MinusLabel);

            PlusSprite          = plusSprite;
            PlusSprite.Position = new CCPoint(minusSprite.ContentSize.Width + plusSprite.ContentSize.Width / 2, minusSprite.ContentSize.Height / 2);
            AddChild(PlusSprite);

            PlusLabel          = new CCLabelTtf("+", ControlStepperLabelFont, 38);
            PlusLabel.Color    = ControlStepperLabelColorEnabled;
            PlusLabel.Position = PlusSprite.ContentSize.Center;
            PlusSprite.AddChild(PlusLabel);

            // Defines the content size
            CCRect maxRect = CCControlUtils.CCRectUnion(MinusSprite.BoundingBox, PlusSprite.BoundingBox);

            ContentSize = new CCSize(MinusSprite.ContentSize.Width + PlusSprite.ContentSize.Height, maxRect.Size.Height);

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

            touchListener.IsSwallowTouches = true;

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

            AddEventListener(touchListener);
        }
        public CCControlSlider(CCSprite backgroundSprite, CCSprite progressSprite, CCSprite thumbSprite)
        {
            Debug.Assert(backgroundSprite != null, "Background sprite can not be null");
            Debug.Assert(progressSprite != null, "Progress sprite can not be null");
            Debug.Assert(thumbSprite != null, "Thumb sprite can not be null");

            BackgroundSprite             = backgroundSprite;
            ProgressSprite               = progressSprite;
            ThumbSprite                  = thumbSprite;
            minimumValue                 = 0.0f;
            maximumValue                 = 1.0f;
            Value                        = minimumValue;
            IgnoreAnchorPointForPosition = false;

            // Defines the content size
            CCRect maxRect = CCControlUtils.CCRectUnion(backgroundSprite.BoundingBox, thumbSprite.BoundingBox);

            ContentSize = new CCSize(maxRect.Size.Width, maxRect.Size.Height);

            // Add the slider background
            BackgroundSprite.AnchorPoint = CCPoint.AnchorMiddle;
            BackgroundSprite.Position    = ContentSize.Center;
            AddChild(BackgroundSprite);

            // Add the progress bar
            ProgressSprite.AnchorPoint = CCPoint.AnchorMiddleLeft;
            ProgressSprite.PositionX   = 0;
            ProgressSprite.PositionY   = BackgroundSprite.PositionY;
            AddChild(ProgressSprite);

            // Add the slider thumb
            ThumbSprite.Position    = new CCPoint(0, ContentSize.Height / 2);
            ThumbSprite.AnchorPoint = CCPoint.AnchorMiddle;
            ThumbSprite.PositionX   = 0;
            ThumbSprite.PositionY   = BackgroundSprite.PositionY;
            AddChild(ThumbSprite);

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

            touchListener.IsSwallowTouches = true;

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

            AddEventListener(touchListener);
        }
Пример #17
0
        public MenuLayer1()
        {

			// Register Touch Event
			touchListener = new CCEventListenerTouchOneByOne();
			touchListener.IsSwallowTouches = true;

			touchListener.OnTouchBegan = onTouchBegan;
			touchListener.OnTouchMoved = onTouchMoved;
			touchListener.OnTouchEnded = onTouchEnded;
			touchListener.OnTouchCancelled = onTouchCancelled;

			AddEventListener(touchListener, 1);


        }
        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 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");

            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 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;
        }
Пример #22
0
        public bool initWithEntryID(int entryId)
        {
            CCSize s = CCDirector.SharedDirector.WinSize;

            m_entryID = entryId;

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

			touchListener.OnTouchBegan = onTouchBegan;
			touchListener.OnTouchMoved = onTouchMoved;

			EventDispatcher.AddEventListener(touchListener, this);

            Box2DView view = Box2DView.viewWithEntryID(entryId);
            AddChild(view, 0, kTagBox2DNode);
            view.Scale = 10;
            view.AnchorPoint = new CCPoint(0, 0);
            view.Position = new CCPoint(s.Width / 2, s.Height / 4);
            //#if (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE)
            //    CCLabelBMFont* label = new CCLabelBMFont(view.title().c_str(),  "fonts/arial16.fnt");
            //#else    
            CCLabelTtf label = new CCLabelTtf(view.title(), "arial", 28);
            //#endif
            AddChild(label, 1);
            label.Position = new CCPoint(s.Width / 2, s.Height - 50);

            CCMenuItemImage item1 = new CCMenuItemImage("Images/b1", "Images/b2", backCallback);
            CCMenuItemImage item2 = new CCMenuItemImage("Images/r1", "Images/r2", restartCallback);
            CCMenuItemImage item3 = new CCMenuItemImage("Images/f1", "Images/f2", nextCallback);

            CCMenu menu = new CCMenu(item1, item2, item3);

            menu.Position = CCPoint.Zero;
            item1.Position = new CCPoint(s.Width / 2 - 100, 30);
            item2.Position = new CCPoint(s.Width / 2, 30);
            item3.Position = new CCPoint(s.Width / 2 + 100, 30);

            AddChild(menu, 1);

            return true;
        }
        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);
        }
Пример #24
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);
        }
Пример #25
0
        public CocoPiece(Piece piece, CCSpriteFrame cCSpriteFrame)
            : base(cCSpriteFrame)
        {
            this.ScaleX = 118 / cCSpriteFrame.Texture.ContentSizeInPixels.Width + 0.1f;
            this.ScaleY = 118 / cCSpriteFrame.Texture.ContentSizeInPixels.Width + 0.1f;
            this.piece = piece;
            this.piece.PieceTaken += OnPieceTaken;
            this.piece.PositionUpdated += (s, p) =>
            {
                this.Position = p.GetPoint(this.piece.Board.Size);
            };

            AnchorPoint = CCPoint.AnchorMiddle;
            Position = this.GetPosition();
            touchListener = new CCEventListenerTouchOneByOne();

            touchListener.OnTouchMoved = Touch;
            touchListener.OnTouchBegan = ToucheBegan;
            touchListener.OnTouchEnded = TouchEnded;
            touchListener.OnTouchCancelled = TouchCanceled;
            AddEventListener(touchListener, this);
        }
Пример #26
0
        public bool initWithEntryID(int entryId)
        {

			//TouchEnabled = true;

            Schedule(tick);

            m_entry = TestEntries.TestList[entryId];
            m_test = m_entry.CreateFcn();
            m_test.Initialize();

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

			touchListener.OnTouchBegan = onTouchBegan;
			touchListener.OnTouchMoved = onTouchMoved;
			touchListener.OnTouchEnded = onTouchEnded;

			EventDispatcher.AddEventListener(touchListener, this);


            return true;
        }
Пример #27
0
        protected override void AddedToScene()
        {
            base.AddedToScene();

            if (Scene != null)
            {
                var touchListener = new CCEventListenerTouchOneByOne();
                touchListener.IsSwallowTouches = true;

                touchListener.OnTouchBegan     = TouchBegan;
                touchListener.OnTouchMoved     = TouchMoved;
                touchListener.OnTouchEnded     = TouchEnded;
                touchListener.OnTouchCancelled = TouchCancelled;

                AddEventListener(touchListener);

                switch (alignmentState.Alignment)
                {
                case Alignment.Vertical:
                    AlignItemsVertically(alignmentState.Padding);
                    break;

                case Alignment.Horizontal:
                    AlignItemsHorizontally(alignmentState.Padding);
                    break;

                case Alignment.Column:
                    AlignItemsInColumns(alignmentState.NumberOfItemsPer);
                    break;

                case Alignment.Row:
                    AlignItemsInRows(alignmentState.NumberOfItemsPer);
                    break;
                }
            }
        }
Пример #28
0
        public override void OnEnter()
        {
            base.OnEnter(); 
            CCRect visibleBounds = Layer.VisibleBoundsWorldspace;

            // Laying out content based on window size
            closeMenu.Position = CCPoint.Zero;
            closeMenuItem.Position = new CCPoint(visibleBounds.Size.Width - 40, visibleBounds.Size.Height - 40);

#if !PSM && !WINDOWS_PHONE

            versionLabel.HorizontalAlignment = CCTextAlignment.Left;
            versionLabel.Position = new CCPoint (10.0f, visibleBounds.Size.Height - 40);
#endif
            testListMenu.ContentSize = new CCSize(visibleBounds.Size.Width, ((int)TestCases.TESTS_COUNT + 1) * LINE_SPACE);

            int i = 0;
            foreach (CCMenuItem testItem in testListMenuItems) 
            {
                testItem.Position = new CCPoint(visibleBounds.Size.Width /2.0f, (visibleBounds.Size.Height - (i + 1) * LINE_SPACE));

                i++;
            }
                
            #if XBOX || OUYA
            // Center the menu on the first item so that it is 
            // in the center of the screen
            homePosition = new CCPoint(0f, visibleBounds.Size.Height / 2f + LINE_SPACE / 2f);
            lastPosition = new CCPoint(0f, homePosition.Y - (testListMenuItems.Count - 1) * LINE_SPACE);
            #else
			homePosition = curPos;
            #endif

            testListMenu.Position = homePosition;

            // Add listeners
            #if !XBOX && !OUYA
            var touchListener = new CCEventListenerTouchOneByOne ();
            touchListener.IsSwallowTouches = true;
            touchListener.OnTouchBegan = OnTouchBegan;
            touchListener.OnTouchMoved = OnTouchMoved;

            AddEventListener(touchListener);

            var mouseListener = new CCEventListenerMouse ();
            mouseListener.OnMouseScroll = OnMouseScroll;
            AddEventListener(mouseListener);

            #endif

            #if WINDOWS || WINDOWSGL || MACOS
            EnableGamePad();
            #endif

            // set the first one to have the selection highlight
            currentItemIndex = 0;
            //SelectMenuItem();
        }
Пример #29
0
        public override void OnEnter()
        {
            base.OnEnter();
            Schedule(Step);

#if WINDOWS || MACOS
            //AccelerometerEnabled = false;
            //TouchEnabled = true;
            //TouchMode = CCTouchMode.OneByOne;
            touchListener = new CCEventListenerTouchOneByOne();
            touchListener.OnTouchBegan = OnTouchBegan;
            touchListener.OnTouchMoved = OnTouchMoved;
            touchListener.OnTouchEnded = OnTouchEnded;


#else	
            AccelerometerEnabled = true;
            SingleTouchEnabled = false;
#endif
            //IsAccelerometerEnabled = true;

            // CCDirector.SharedDirector.Accelerometer.SetDelegate(new AccelerometerDelegate(DidAccelerate);
            StartGame();




        }
Пример #30
0
        private void InitCCControlButton(CCNode node, CCNode backgroundSprite)
        {
            Debug.Assert(node != null, "Label must not be nil.");
            var label     = node as ICCTextContainer;
            var rgbaLabel = node;

            Debug.Assert(backgroundSprite != null, "Background sprite must not be nil.");
            Debug.Assert(label != null || rgbaLabel != null || backgroundSprite != null);

            parentInited = true;

            // Initialize the button state tables
            titleDispatchTable            = new Dictionary <CCControlState, string>();
            titleColorDispatchTable       = new Dictionary <CCControlState, CCColor3B>();
            titleLabelDispatchTable       = new Dictionary <CCControlState, CCNode>();
            backgroundSpriteDispatchTable = new Dictionary <CCControlState, CCNode>();

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

            touchListener.IsSwallowTouches = true;

            touchListener.OnTouchBegan     = onTouchBegan;
            touchListener.OnTouchMoved     = onTouchMoved;
            touchListener.OnTouchEnded     = onTouchEnded;
            touchListener.OnTouchCancelled = onTouchCancelled;

            AddEventListener(touchListener);

            isPushed        = false;
            zoomOnTouchDown = true;

            currentTitle = null;

            // Adjust the background image by default
            IsAdjustBackgroundImage = true;
            PreferredSize           = CCSize.Zero;
            // Zooming button by default
            zoomOnTouchDown = true;

            // Set the default anchor point
            IgnoreAnchorPointForPosition = false;
            AnchorPoint = new CCPoint(0.5f, 0.5f);

            // Set the nodes
            TitleLabel       = node;
            BackgroundSprite = backgroundSprite;

            // Set the default color and opacity
            Color   = new CCColor3B(255, 255, 255);
            Opacity = 255;
            IsColorModifiedByOpacity = true;

            // Initialize the dispatch table

            string tempString = label.Text;

            //tempString->autorelease();
            SetTitleForState(tempString, CCControlState.Normal);
            SetTitleColorForState(rgbaLabel.Color, CCControlState.Normal);
            SetTitleLabelForState(node, CCControlState.Normal);
            SetBackgroundSpriteForState(backgroundSprite, CCControlState.Normal);

            LabelAnchorPoint = new CCPoint(0.5f, 0.5f);

            NeedsLayout();
        }
Пример #31
0
        public TMXHexTest() : base("TileMaps/hexa-test1")
        {
            CCLayerColor color = new CCLayerColor(new CCColor4B(64, 64, 64, 255));
            AddChild(color, -1);

            drawNode = new CCDrawNode();
            tileLayersContainer.AddChild(drawNode);

            var touchListener = new CCEventListenerTouchOneByOne();
            touchListener.OnTouchBegan = OnTouchBegan;

            AddEventListener(touchListener);
        }
Пример #32
0
        public TMXStaggeredMapTest() : base("TileMaps/staggered_test")
        {
            drawNode = new CCDrawNode();
            tileLayersContainer.AddChild(drawNode);

            var touchListener = new CCEventListenerTouchOneByOne();
            touchListener.OnTouchBegan = OnTouchBegan;

            AddEventListener(touchListener);
        }
Пример #33
0
		public override void OnEnter()
		{
            base.OnEnter(); 

            int i;

            for (i = 0; i < SPRITE_COUNT; i++)
            {
                CCSprite sprite;

                if(i==4)
                {
                    sprite = new CCSprite("Images/CyanSquare.png") { Tag = TAG_SPRITE + i};
                    blueSprite = sprite;
                    //blueSprite.Scene = Scene;
                    blueSprite.GlobalZOrder = -1;

                }
                else
                {
                    sprite = new CCSprite("Images/YellowSquare.png") { Tag = TAG_SPRITE + i};
                }

                // For right now since we do not draw by GlobalZOrder we will move a value to the
                // Local z-order so we can fake this.  It is a Hack for now for the foreground
                // to background movement.
                AddChild(sprite, 2);

            }

            CCRect visibleRect = Layer.VisibleBoundsWorldspace;

			var listener = new CCEventListenerTouchOneByOne();
			listener.IsSwallowTouches = true;

			listener.OnTouchBegan = (touch, touchEvent) =>
				{
					var target = (CCSprite)touchEvent.CurrentTarget;

					var locationInNode = target.Layer.ScreenToWorldspace(touch.LocationOnScreen);
					var s = target.ContentSize;
                    var rect = target.BoundingBoxTransformedToWorld;
		
					if (rect.ContainsPoint(locationInNode))
					{
						CCLog.Log("sprite began... x = {0}, y = {1}", locationInNode.X, locationInNode.Y);
						target.Opacity = 180;
						return true;
					}
					return false;

				};

			listener.OnTouchMoved = (touch, touchEvent) =>
			{
				var target = (CCSprite)touchEvent.CurrentTarget;
				target.Position = target.Position + touch.Delta;
			};

			listener.OnTouchEnded = (touch, touchEvent) => 
				{
					var target = (CCSprite)touchEvent.CurrentTarget;
					CCLog.Log ("sprite OnTouchEnded...");
					target.Opacity = 255;
				};

			i = 0;
			foreach (var child in Children)
			{
				if (child.Tag >= TAG_SPRITE && child.Tag <= TAG_SPRITE_END)
				{
                    child.Position = new CCPoint(visibleRect.Origin.X + visibleRect.Size.Width / (SPRITE_COUNT - 1) * i, visibleRect.Center.Y);
					i++;
					child.AddEventListener(listener.Copy());
				}
			}

			Schedule();

		}
        public CCControlSwitch(CCSprite maskSprite, CCSprite onSprite, CCSprite offSprite, CCSprite thumbSprite, CCLabel onLabel,
            CCLabel offLabel)
        {
            Debug.Assert(maskSprite != null, "Mask must not be nil.");
            Debug.Assert(onSprite != null, "onSprite must not be nil.");
            Debug.Assert(offSprite != null, "offSprite must not be nil.");
            Debug.Assert(thumbSprite != null, "thumbSprite must not be nil.");

            on = true;

            switchSprite = new CCControlSwitchSprite(maskSprite, onSprite, offSprite, thumbSprite, onLabel, offLabel);
            switchSprite.Position = new CCPoint(switchSprite.ContentSize.Width / 2, switchSprite.ContentSize.Height / 2);
            AddChild(switchSprite);

            IgnoreAnchorPointForPosition = false;
            AnchorPoint = new CCPoint(0.5f, 0.5f);
            ContentSize = switchSprite.ContentSize;

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

			touchListener.OnTouchBegan = OnTouchBegan;
			touchListener.OnTouchMoved = OnTouchMoved;
			touchListener.OnTouchEnded = OnTouchEnded;
			touchListener.OnTouchCancelled = OnTouchCancelled;

            AddEventListener(touchListener);
        }
Пример #35
0
		public override void OnEnter ()
		{
            CCRect visibleBounds = Layer.VisibleBoundsWorldspace;

			base.OnEnter ();

			var item1 = new  CCMenuItemFont("Click Me 1", (sender) =>
				{
					var listener = new CCEventListenerTouchOneByOne();
					listener.OnTouchBegan = (touch, touchEvent) => 
					{
						Debug.Assert(false, "Should not come here!");
						return true;
					};

                    AddEventListener(listener, -1);
                    RemoveEventListener(listener);
			});

            item1.Position = visibleBounds.Center + new CCPoint(0, 80);

			var addNextButton = new Action( () =>
			{
				var next = new CCMenuItemFont("Please Click Me To Reset!", (sender) => 
				{
						RestartCallback(null);
				});
                next.Position = visibleBounds.Center + new CCPoint(0, -40);

				var menuNext = new CCMenu(next);
                menuNext.Position = visibleBounds.Origin;
				menuNext.AnchorPoint = CCPoint.Zero;
				AddChild(menuNext);
				});

			var item2 = new CCMenuItemFont ("Click Me 2", (sender) => 
			{
				var listener = new CCEventListenerTouchOneByOne ();
				listener.OnTouchBegan = (touch, touchEvent) => {
					Debug.Assert (false, "Should not come here!");
					return true;
				};

                    AddEventListener(listener, -1);
                    RemoveEventListeners(CCEventListenerType.TOUCH_ONE_BY_ONE);

					addNextButton ();
			});

            item2.Position = visibleBounds.Center + new CCPoint(0, 40);

			var item3 = new CCMenuItemFont("Click Me 3", (sender) => 
				{
					var listener = new CCEventListenerTouchOneByOne ();
					listener.OnTouchBegan = (touch, touchEvent) => {
						Debug.Assert (false, "Should not come here!");
						return true;
					};

                    AddEventListener(listener, -1);
                    RemoveEventListeners(CCEventListenerType.TOUCH_ONE_BY_ONE);

					addNextButton();
			});

            item3.Position = visibleBounds.Center;

			var menu = new CCMenu(item1, item2, item3);
            menu.Position = visibleBounds.Origin;
			menu.AnchorPoint = CCPoint.Zero;

			AddChild(menu);

		}
Пример #36
0
		public override void OnEnter ()
		{

			spriteSaved = false;

			base.OnEnter ();

			var origin = Layer.VisibleBoundsWorldspace.Origin;
			var size = Layer.VisibleBoundsWorldspace.Size;

			//MenuItemFont::setFontSize(20);

			var sprite = new CCSprite("Images/CyanSquare.png");
			sprite.Position = origin + size.Center;
			AddChild(sprite, 10);

			// Make sprite1 touchable
			var listener1 = new CCEventListenerTouchOneByOne ();
			listener1.IsSwallowTouches = true;

			listener1.OnTouchBegan = (touch, touchEvent) => 
			{
				var target = (CCSprite) touchEvent.CurrentTarget;

				var locationInNode = target.Layer.ScreenToWorldspace(touch.LocationOnScreen);
				var s = target.ContentSize;
				var rect = new CCRect(0, 0, s.Width, s.Height);

				if (rect.ContainsPoint(locationInNode))
				{
					CCLog.Log("sprite began... x = {0}, y = {1}", locationInNode.X, locationInNode.Y);
					target.Opacity = 180;
					return true;
				}
				return false;
			};

			listener1.OnTouchMoved = (touch, touchEvent) =>
			{
				var target = (CCSprite) touchEvent.CurrentTarget;
				target.Position += touch.Delta;
			};

			listener1.OnTouchEnded = (touch, touchEvent) =>
			{
				var target = (CCSprite) touchEvent.CurrentTarget;
				CCLog.Log("sprite onTouchesEnded.. ");
				target.Opacity = 255;
			};

            sprite.AddEventListener(listener1);

			RunActions(new CCDelayTime(5.0f),
				new CCCallFunc(() => 
				{
					spriteSaved = true;
					sprite.RemoveFromParent();
				}),
				new CCDelayTime(5.0f),
				new CCCallFunc(() =>
				{
					spriteSaved = false;
					AddChild(sprite);
				})
			);


		}
Пример #37
0
		public override void OnEnter ()
		{
			base.OnEnter ();
			var listener = new CCEventListenerTouchOneByOne();
			listener.IsSwallowTouches = true;

			listener.OnTouchBegan = (CCTouch touch, CCEvent rouchEvent) => 
			{

                var locationInNode = Layer.ScreenToWorldspace(touch.LocationOnScreen);
				var s = ContentSize;
				var rect = new CCRect(0, 0, s.Width, s.Height);

				if (rect.ContainsPoint(locationInNode))
				{
					Color = CCColor3B.Red;
					return true;
				}
				return false;
			};

			listener.OnTouchEnded = (CCTouch touch, CCEvent rouchEvent) =>
			{
				Color = CCColor3B.White;

				if (IsRemoveListenerOnTouchEnded)
				{
                    RemoveEventListener(Listener);
				}
			};

            if (FixedPriority != 0)
            {
                AddEventListener(listener, FixedPriority);
            }
            else
            {
                AddEventListener(listener);
            }

			Listener = listener;
		}
Пример #38
0
		public override void OnEnter ()
		{
			base.OnEnter ();

            CCRect visibleBounds = Layer.VisibleBoundsWorldspace;
			var origin = Layer.VisibleBoundsWorldspace.Origin;
			var size = Layer.VisibleBoundsWorldspace.Size;

			var sprite1 = new CCSprite("Images/CyanSquare.png");
			sprite1.Position = origin + new CCPoint (size.Width / 2, size.Height / 2) + new CCPoint (-80, 80);
			AddChild(sprite1, 10);

			var sprite2 = new CCSprite("Images/MagentaSquare.png");
			sprite2.Position = origin + new CCPoint (size.Width / 2, size.Height / 2);
			AddChild(sprite2, 20);

			var sprite3 = new CCSprite("Images/YellowSquare.png");
			sprite3.Position = CCPoint.Zero;
			sprite2.AddChild(sprite3, 1);

			// Make sprite1 touchable
			var listener1 = new CCEventListenerTouchOneByOne ();
			listener1.IsSwallowTouches = true;

			listener1.OnTouchBegan = (touch, touchEvent) => 
			{
				var target = (CCSprite)touchEvent.CurrentTarget;

				var locationInNode = target.Layer.ScreenToWorldspace(touch.LocationOnScreen);
				var s = target.ContentSize;
                CCRect rect = target.BoundingBoxTransformedToWorld;

				if (rect.ContainsPoint(locationInNode))
				{
					CCLog.Log("sprite began... x = {0}, y = {1}", locationInNode.X, locationInNode.Y);
					target.Opacity = 180;
					return true;
				}
				return false;
			};

			listener1.OnTouchMoved = (touch, touchEvent) => 
			{
				var target = (CCSprite)touchEvent.CurrentTarget;
                CCPoint pt = touch.PreviousLocationOnScreen + touch.Delta;
                target.Position = target.WorldToParentspace(Layer.ScreenToWorldspace(pt));
			};

			listener1.OnTouchEnded = (touch, touchEvent) => 
			{
				var target = (CCSprite)touchEvent.CurrentTarget;
				CCLog.Log("sprite onTouchesEnded..");
				target.Opacity = 255;
				if (target == sprite2)
				{
					sprite1.LocalZOrder = 100;
				}
				else if(target == sprite1)
				{
					sprite1.LocalZOrder = 0;
				}
			};


            sprite1.AddEventListener(listener1);
            sprite2.AddEventListener(listener1.Copy());
            sprite3.AddEventListener(listener1.Copy());


			var removeAllTouchItem = new CCMenuItemFont("Remove All Touch Listeners", (sender) => {
				var senderItem = (CCMenuItemFont)sender;
				senderItem.LabelTTF.Text = "Only Next item could be clicked";

                RemoveEventListeners(CCEventListenerType.TOUCH_ONE_BY_ONE);

				var nextItem = new CCMenuItemFont("Next", (senderNext) => NextCallback(senderNext));
			

				CCMenuItemFont.FontSize = 16;
                nextItem.Position =  new CCPoint(visibleBounds.Origin.X + visibleBounds.Size.Width -100, 100);

				var menu2 = new CCMenu(nextItem);
				menu2.Position = CCPoint.Zero;
				menu2.AnchorPoint = CCPoint.AnchorLowerLeft;
				this.AddChild(menu2);
			});

			CCMenuItemFont.FontSize = 16;
            removeAllTouchItem.Position = new CCPoint(visibleBounds.Origin.X + visibleBounds.Size.Width -100, 80);

			var menu = new CCMenu(removeAllTouchItem);
			menu.Position = CCPoint.Zero;
			menu.AnchorPoint = CCPoint.AnchorLowerLeft;
			AddChild(menu);


		}
Пример #39
0
		public StopPropagationTest() : base()
		{
			var touchOneByOneListener = new CCEventListenerTouchOneByOne();
			touchOneByOneListener.IsSwallowTouches = true;

			touchOneByOneListener.OnTouchBegan = (touch, touchEvent) =>
			{
				// Skip if don't touch top half screen.
				if (!IsPointInTopHalfAreaOfScreen(touch.LocationOnScreen))
					return false;

				var target = (CCSprite)touchEvent.CurrentTarget;
				Debug.Assert (target.Tag == TAG_BLUE_SPRITE, "Yellow blocks shouldn't response event.");

				if (IsPointInNode(touch.LocationOnScreen, target))
				{
					target.Opacity = 180;
					return true;
				}

				// Stop propagation, so yellow blocks will not be able to receive event.
				touchEvent.StopPropogation();
				return false;
			};

			touchOneByOneListener.OnTouchEnded = (touch, touchEvent) => 
			{
				var target = (CCSprite)touchEvent.CurrentTarget;
				target.Opacity = 255;
			};

			var touchAllAtOnceListener = new CCEventListenerTouchAllAtOnce();
			touchAllAtOnceListener.OnTouchesBegan = (touches, touchEvent) => 
			{
				// Skip if don't touch top half screen.
				if (IsPointInTopHalfAreaOfScreen(touches[0].LocationOnScreen))
					return;

				var target = (CCSprite)touchEvent.CurrentTarget;
				Debug.Assert(target.Tag == TAG_BLUE_SPRITE2, "Yellow blocks shouldn't response event.");

				if (IsPointInNode(touches[0].LocationOnScreen, target))
				{
					target.Opacity = 180;
				}
				// Stop propagation, so yellow blocks will not be able to receive event.
				touchEvent.StopPropogation();
			};

			touchAllAtOnceListener.OnTouchesEnded = (touches, touchEvent) => 
			{
				// Skip if don't touch top half screen.
				if (IsPointInTopHalfAreaOfScreen(touches[0].LocationOnScreen))
					return;

				var target = (CCSprite)touchEvent.CurrentTarget;
				Debug.Assert(target.Tag == TAG_BLUE_SPRITE2, "Yellow blocks shouldn't response event.");

				if (IsPointInNode(touches[0].LocationOnScreen, target))
				{
					target.Opacity = 255;;
				}
				// Stop propagation, so yellow blocks will not be able to receive event.
				touchEvent.StopPropogation();
			};

			var keyboardEventListener = new CCEventListenerKeyboard();

			keyboardEventListener.OnKeyPressed = (keyboardEvent) => 
			{
				var target = (CCSprite)keyboardEvent.CurrentTarget;
				Debug.Assert(target.Tag == TAG_BLUE_SPRITE || target.Tag == TAG_BLUE_SPRITE2, "Yellow blocks shouldn't response event.");
				// Stop propagation, so yellow blocks will not be able to receive event.
				keyboardEvent.StopPropogation();
			};


			const int SPRITE_COUNT = 8;

			for (int i = 0; i < SPRITE_COUNT; i++)
			{
				CCSprite sprite;
				CCSprite sprite2;

				if(i==4)
				{
					sprite = new CCSprite("Images/CyanSquare.png");
					sprite.Tag = TAG_BLUE_SPRITE;
					AddChild(sprite, 100);

					sprite2 = new CCSprite("Images/CyanSquare.png");
					sprite2.Tag = TAG_BLUE_SPRITE2;
					AddChild(sprite2, 100);
				}
				else
				{
					sprite = new CCSprite("Images/YellowSquare.png");
					AddChild(sprite, 0);
					sprite2 = new CCSprite("Images/YellowSquare.png");
					AddChild(sprite2, 0);
				}

				sprite.AddEventListener(touchOneByOneListener.Copy());
				sprite.AddEventListener(keyboardEventListener.Copy());

				sprite2.AddEventListener(touchAllAtOnceListener.Copy());
				sprite2.AddEventListener(keyboardEventListener.Copy());


				var visibleBounds = Layer.VisibleBoundsWorldspace;
                sprite.Position = new CCPoint( visibleBounds.Origin.X + visibleBounds.Size.Width / (SPRITE_COUNT - 1) * i, visibleBounds.Center.Y + sprite2.ContentSize.Height/2 +10);
                sprite2.Position = new CCPoint( visibleBounds.Origin.X + visibleBounds.Size.Width / (SPRITE_COUNT - 1) * i, visibleBounds.Center.Y - sprite2.ContentSize.Height/2-10);
			}

		}
		public CCControlSlider(CCSprite backgroundSprite, CCSprite progressSprite, CCSprite thumbSprite)
		{
            Debug.Assert(backgroundSprite != null, "Background sprite can not be null");
            Debug.Assert(progressSprite != null, "Progress sprite can not be null");
            Debug.Assert(thumbSprite != null, "Thumb sprite can not be null");

            BackgroundSprite = backgroundSprite;
            ProgressSprite = progressSprite;
            ThumbSprite = thumbSprite;
			minimumValue = 0.0f;
			maximumValue = 1.0f;
			Value = minimumValue;
			IgnoreAnchorPointForPosition = false;

            // Defines the content size
            CCRect maxRect = CCControlUtils.CCRectUnion(backgroundSprite.BoundingBox, thumbSprite.BoundingBox);
            ContentSize = new CCSize(maxRect.Size.Width, maxRect.Size.Height);

            // Add the slider background
            BackgroundSprite.AnchorPoint = CCPoint.AnchorMiddle;
            BackgroundSprite.Position = ContentSize.Center;
            AddChild(BackgroundSprite);

            // Add the progress bar
            ProgressSprite.AnchorPoint = CCPoint.AnchorMiddleLeft;
            ProgressSprite.PositionX = 0;
            ProgressSprite.PositionY = BackgroundSprite.PositionY;
            AddChild(ProgressSprite);

            // Add the slider thumb  
            ThumbSprite.Position = new CCPoint(0, ContentSize.Height / 2);
            ThumbSprite.AnchorPoint = CCPoint.AnchorMiddle;
            ThumbSprite.PositionX = 0;
            ThumbSprite.PositionY = BackgroundSprite.PositionY;
            AddChild(ThumbSprite);

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

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

            AddEventListener(touchListener);
        }
Пример #41
0
        public IsoNodePosition() : base("TileMaps/iso-test-zorder")
        {

            drawNode = new CCDrawNode();
            tileLayersContainer.AddChild(drawNode);

            var touchListener = new CCEventListenerTouchOneByOne();
            touchListener.OnTouchBegan = OnTouchBegan;

            AddEventListener(touchListener);

        }
        public CCControlPotentiometer(string backgroundFile, string progressFile, string thumbFile)
        {
			var trackSprite = new CCSprite(backgroundFile);
            var thumbSprite = new CCSprite(thumbFile);
            var progressTimer = new CCProgressTimer(new CCSprite(progressFile));

			minimumValue = 0.0f;
			maximumValue = 1.0f;
			value = minimumValue;

			ProgressTimer = progressTimer;
			ThumbSprite = thumbSprite;
			thumbSprite.Position = progressTimer.Position;

			AddChild(thumbSprite, 2);
			AddChild(progressTimer, 1);
			AddChild(trackSprite);

			ContentSize = trackSprite.ContentSize;

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

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

            AddEventListener(touchListener);
        }