Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using LemonUI.Elements;
- using System.Windows.Forms;
- using System;
- using System.Drawing;
- using GTA;
- using GTA.Math;
- namespace LemonUI.Menu1
- {
- public class YourScript : Script
- {
- ScaledRectangle rectangle;
- const int slidingDuration = 3000;
- bool isSlidingRight = true;
- int slidingStartTick;
- int startingPosition;
- public YourScript()
- {
- Tick += OnTick;
- KeyDown += OnKeyDown;
- rectangle = new ScaledRectangle(new PointF(10, 10), new SizeF(100, 200));
- startingPosition = (int)rectangle.Position.X;
- }
- private float lerp(float a, float b, float t)
- {
- return a + (b - a) * t;
- }
- private void OnTick(object sender, EventArgs e)
- {
- float progress = (Game.GameTime - slidingStartTick) / slidingDuration;
- float xPosition = lerp(startingPosition, isSlidingRight ? 10 : -200, progress);
- rectangle.Position = new PointF(xPosition, 10);
- if (progress >= 1.0f)
- {
- //isAnimating = false;
- }
- }
- private void OnKeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Y)
- {
- slidingStartTick = Game.GameTime;
- startingPosition = (int)rectangle.Position.X;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement