/**
         * repeat will execute the action repeat + 1 times, for a continues action use kCCRepeatForever
         * delay is the amount of time the action will wait before execution
         */
        public void schedule(TICK_IMP selector, float interval = 0, uint repeat = CCScheduler.kCCRepeatForever, float delay = 0)
        {
            NSUtils.Assert(selector != null, "Argument must be non-nil");
            NSUtils.Assert(FloatUtils.EB(interval, 0), "Arguemnt must be positive");


            _scheduler.schedule(selector, this, interval, repeat, !_isRunning, delay);
        }
        public static Rect RectIntersection(Rect a, Rect b)
        {
            float x1 = Math.Max(a.x, b.x);
            float x2 = Math.Min(a.x + a.width, b.x + b.width);
            float y1 = Math.Max(a.y, b.y);
            float y2 = Math.Min(a.y + a.height, b.y + b.height);

            if (FloatUtils.EB(x2, x1) &&
                FloatUtils.EB(y2, y1))
            {
                return(new Rect(x1, y1, x2 - x1, y2 - y1));
            }
            return(new Rect(0, 0, 0, 0));
        }
Beispiel #3
0
 /** triggers the timer */
 public void update(float dt)
 {
     if (FloatUtils.EQ(_elapsed, -1))
     {
         _elapsed        = 0;
         _nTimesExecuted = 0;
     }
     else
     {
         if (_runForever && !_useDelay)
         {
             //standard timer usage
             _elapsed += dt;
             if (FloatUtils.EB(_elapsed, _interval))
             {
                 trigger();
                 _elapsed = 0;
             }
         }
         else
         {
             //advanced usage
             _elapsed += dt;
             if (_useDelay)
             {
                 if (FloatUtils.EB(_elapsed, _delay))
                 {
                     trigger();
                     _elapsed         = _elapsed - _delay;
                     _nTimesExecuted += 1;
                     _useDelay        = false;
                 }
             }
             else
             {
                 if (FloatUtils.EB(_elapsed, _interval))
                 {
                     trigger();
                     _elapsed         = 0;
                     _nTimesExecuted += 1;
                 }
             }
             if (!_runForever && FloatUtils.Big(_nTimesExecuted, _repeat))
             {
                 cancel();
             }
         }
     }
 }
        // issue #80. Instead of hooking step:, hook update: since it can be called by any
        // container action like CCRepeat, CCSequence, CCEase, etc..
        public override void update(float dt)
        {
            if (FloatUtils.EB(dt, _nextDt))
            {
                while (FloatUtils.Big(dt, _nextDt) && _total < _times)
                {
                    _innerAction.update(1.0f);
                    _total++;

                    _innerAction.stop();
                    _innerAction.startWithTarget(_target);
                    _nextDt += _innerAction.duration / _duration;
                }

                // fix for issue #1288, incorrect end value of repeat
                if (FloatUtils.EB(dt, 1.0f) && _total < _times)
                {
                    _total++;
                }

                // don't set a instantaction back or update it, it has no use because it has no duration
                if (!_isActionInstant)
                {
                    if (_total == _times)
                    {
                        _innerAction.update(1);
                        _innerAction.stop();
                    }
                    else
                    {
                        // issue #390 prevent jerk, use right update
                        _innerAction.update(dt - (_nextDt - _innerAction.duration / _duration));
                    }
                }
            }
            else
            {
                _innerAction.update((dt * _times) % 1.0f);
            }
        }
Beispiel #5
0
 /** returns YES if the action has finished */
 public override bool isDone()
 {
     return(FloatUtils.EB(_elapsed, _duration));
 }