Exemple #1
0
        public void Draw(GameTime gameTime, Rectangle rectangle, float Rotation, Color color)
        {
            if (loaded)
            {
                if (!Animated)
                {
                    X.spriteBatch.Draw(texture, rectangle, Color.White);
                }
                else
                {
                    if (timer.PassedTime > AnimationTime && IsRunning)
                    {
                        timer.Reset();
                        timer.Start();

                        if (CurrentCell < TotalCells - 1)
                        {
                            CurrentCell++;
                        }
                        else
                        {
                            CurrentCell = 0;
                        }
                    }

                    X.spriteBatch.Draw(texture, rectangle, new Rectangle(
                                           cells[CurrentCell].Column * cells[CurrentCell].CellWidth,
                                           cells[CurrentCell].Row * cells[CurrentCell].CellWidth,
                                           cells[CurrentCell].CellWidth,
                                           cells[CurrentCell].CellHeight
                                           ), color, Rotation, new Vector2(texture.Width / 2, texture.Height / 2), SpriteEffects.None, 0);
                }
            }
        }
Exemple #2
0
        public override void Update(ref GameTime gameTime)
        {
            if (loaded)
            {
                //System.Diagnostics.Debug.Write(Timer.PassedTime.ToString());
                //did enough time pass for another frame?
                //this limited the speed of the animation so if we are drawing the game faster then
                // the desired framerate we skip and wait a bit
                //Also if the game is drawing slower then the framerate of the animation we should
                //skip some frames of animation to keepup!
                if (Timer.PassedTime >= FrameTime && !IsStopped)
                {
                    int framedelta = (int)(Timer.PassedTime / FrameTime);
                    if (framedelta > 1)
                    {//we are running to slow frameskip by the number of frame we are behind!
                        CurrentFrame += framedelta;
                        if (CurrentFrame >= FrameCount) CurrentFrame = 0;
                    }
                    else
                    {
                        if (CurrentFrame < FrameCount - 1)
                            CurrentFrame++;
                        else
                            CurrentFrame = 0;
                    }

                    Timer.Reset();
                    Timer.Start();
                }
            }
        }//end update method
Exemple #3
0
        public override void Update(ref GameTime gameTime)
        {
            LastState    = CurrentState;
            CurrentState = Mouse.GetState();

            CurrentPosition = new Vector2(CurrentState.X, CurrentState.Y);

            if (Reset)
            {
                Delta = InitialPosition - CurrentPosition;
            }
            else
            {
                Delta = CurrentPosition - new Vector2(LastState.X, LastState.Y);
            }

            if (Reset)
            {
                Mouse.SetPosition((int)InitialPosition.X, (int)InitialPosition.Y);
            }

            ScrollPosition = CurrentState.ScrollWheelValue;
            ScrollDelta    = ScrollPosition - LastState.ScrollWheelValue;

            if (CurrentState == LastState)
            {
                idleTime.Start();
            }
            else
            {
                idleTime.Reset();
            }
        }
Exemple #4
0
        public XTimer CreateTimer(float second, Action <object> callback, object param)
        {
            XTimer timer = new XTimer();

            m_dicTimer.Add(timer, timer);
            timer.Reset(m_runSecond, second, callback, param);
            return(timer);
        }
Exemple #5
0
        public override void Update(ref GameTime gameTime)
        {
            UpdateStates();

            if (CurrentState == LastState)
            {
                idleTime.Start();
            }
            else
            {
                idleTime.Reset();
            }
        }
Exemple #6
0
        public override void Update(ref GameTime gameTime)
        {
            GetState();

            if (CurrentState == LastState)
            {
                idleTime.Start();
            }
            else
            {
                idleTime.Reset();
            }

            if (vibrationTimer.PassedTime > length)
            {
                vibrationTimer.Reset();
                left   = 0;
                right  = 0;
                length = 0;
                GamePad.SetVibration(index, 0, 0);
            }
        }