Пример #1
0
        void OnTouchesBegan(List <CCTouch> touches, CCEvent touchEvent)
        {
            if (touches.Count > 0)
            {
                _line.DrawLine(touches[0].StartLocation, touches[0].Location, LINE_WIDTH, CCColor4B.Yellow, CCLineCap.Round);

                _lastLineStartPoint = new CCPoint(touches[0].Location);

                _ball.AddChild(_glow);
                _ball.ReorderChild(_glow, 1);
            }
        }
Пример #2
0
        protected override void AddedToScene()
        {
            base.AddedToScene();

            // Use the bounds to layout the positioning of our drawable assets
            _bounds = VisibleBoundsWorldspace;

            //var background = new CCSprite("background");
            //AddChild(background);

            _targetZone          = new CCDrawNode();
            _targetZone.Position = new CCPoint(_bounds.MaxX - 100, _bounds.MaxY - 100);
            _targetZone.DrawRect(new CCPoint(0, 0), 50, CCColor4B.Transparent);
            AddChild(_targetZone);

            var coinSprite = new CCSprite("coin");

            _targetZone.AddChild(coinSprite);

            _line = new CCDrawNode();
            AddChild(_line);

            _ball          = new CCDrawNode();
            _ball.Position = new CCPoint(100, 100);
            _ball.DrawCircle(new CCPoint(0, 0), 50, CCColor4B.Transparent);
            AddChild(_ball);
            ReorderChild(_ball, 2);

            var ballSprite = new CCSprite("ball");

            _ball.AddChild(ballSprite);
            //ballSprite.Scale = 0.15f;
            _ball.ReorderChild(ballSprite, 2);

            _glow             = new CCParticleSun(new CCPoint(0, 0), CCEmitterMode.Radius);
            _glow.StartColor  = new CCColor4F(CCColor3B.Orange);
            _glow.EndColor    = new CCColor4F(CCColor3B.Yellow);
            _glow.StartRadius = _ball.ContentSize.Width * 0.4f;
            _glow.EndRadius   = _ball.ContentSize.Width * 0.5f;

            Schedule(RunGameLogic);

            // Register for touch events
            var touchListener = new CCEventListenerTouchAllAtOnce();

            touchListener.OnTouchesBegan = OnTouchesBegan;
            touchListener.OnTouchesEnded = OnTouchesEnded;
            touchListener.OnTouchesMoved = HandleTouchesMoved;
            AddEventListener(touchListener, _ball);
        }