- Home /
Question by
EctoWarrior · Feb 08, 2014 at 06:55 PM ·
arraypositiontextlistcoordinates
How to draw text based on text above it?
Basically I have a bunch of power ups in my game that have timers. These timers need to be drawn on the screen. Currently, I have all of the power ups drawn on the same coordinates, x:10 and y:70. But how could I change the y value if there is already text being drawn there? And, when the timer runs out and the text goes away, how could I make the text below it shift up? I've tried experimenting with arrays and lists, but I can't figure it out. here's what I have so far:
public static bool startOverdriveTimer = false;
public static bool startMultiballTimer = false;
public static bool startLargeBallTimer = false;
public static bool startDoublePointsTimer = false;
public static bool startBombPowerupTimer = false;
public static bool startBallResetTimer = false;
void OnGUI () {
GUI.Label(new Rect(10, 10, 100, 20), "Score: " + Player.score);
GUI.Label(new Rect(10, 30, 100, 20), "Lives: " + Player.lives);
GUI.Label(new Rect(10, 50, 100, 20), "Bullets: " + Player.ammo);
if (startOverdriveTimer) {
GUI.Label(new Rect(10, 70, 100, 25), "Overdrive: " + Mathf.CeilToInt(FastBallPowerup.timer));
}
if (startLargeBallTimer) {
GUI.Label(new Rect(10, 70, 100, 25), "Large Ball: " + Mathf.CeilToInt(LargeBallPowerup.timer));
}
if (startDoublePointsTimer) {
GUI.Label(new Rect(10, 70, 200, 25), "Double Points: " + Mathf.CeilToInt(DoublePointsPowerup.timer));
}
if (startBombPowerupTimer) {
GUI.Label(new Rect(10, 70, 100, 25), "Disabled: " + Mathf.CeilToInt(BombPowerup.timer));
}
if (startBallResetTimer) {
GUI.Label(new Rect(10, 70, 100, 25), "Ball Reset: " + Mathf.CeilToInt(Ball.resetVelocityTimer).ToString());
}
}
Thanks in advance.
Comment