public GameObject(Sprite sprite, ObjectState[] states, Vector2 vel, Vector2 accel) { this.sprite = sprite; activationEffected = true; transistion = 0; this.states = states; velocity = vel; acceleration = accel; }
public GameObject(Sprite sprite, ObjectState[] states) { this.sprite = sprite; activationEffected = true; transistion = 0; this.states = states; velocity = Vector2.Zero; acceleration = Vector2.Zero; }
public GameObject(Sprite sprite, ObjectState state, Vector2 vel, Vector2 accel) { this.sprite = sprite; activationEffected = false; transistion = 0; states = new ObjectState[3]; states[1] = state; velocity = vel; acceleration = accel; }
public GameObject(Sprite sprite, ObjectState state) { this.sprite = sprite; activationEffected = false; transistion = 0; states = new ObjectState[2]; states[1] = state; velocity = Vector2.Zero; acceleration = Vector2.Zero; }
public static ObjectState Lerp(ObjectState state1, ObjectState state2, float amount) { return new ObjectState( new Rectangle( (int)(state1.Rectangle.X + amount * (state2.Rectangle.X - state1.Rectangle.X)), (int)(state1.Rectangle.Y + amount * (state2.Rectangle.Y - state1.Rectangle.Y)), (int)(state1.Rectangle.Width + amount * (state2.Rectangle.Width - state1.Rectangle.Width)), (int)(state1.Rectangle.Height + amount * (state2.Rectangle.Height - state1.Rectangle.Height))), new Color(), 0.0f); }
public void draw(SpriteBatch sb) { if (activationEffected) { ObjectState transistionState = new ObjectState(); transistionState.Rectangle = new Rectangle( (int)(states[0].Rectangle.X + transistion * (states[1].Rectangle.X - states[0].Rectangle.X)), (int)(states[0].Rectangle.Y + transistion * (states[1].Rectangle.Y - states[0].Rectangle.Y)), (int)(states[0].Rectangle.Width + transistion * (states[1].Rectangle.Width - states[0].Rectangle.Width)), (int)(states[0].Rectangle.Height + transistion * (states[1].Rectangle.Height - states[0].Rectangle.Height))); transistionState.Color = Color.Lerp(states[0].Color, states[1].Color, transistion); transistionState.Rotation = states[0].Rotation + transistion * (states[1].Rotation - states[0].Rotation); sprite.draw(sb, transistionState.Rectangle, transistionState.Color); } else { sprite.draw(sb, states[1].Rectangle, states[1].Color); } }