- Home /
Displaying a PNG on lap finish (racing game)
Hi folks,
We've nearly finished our rracing game for a final year University project and we're a bit stuck.
We're programming in javaScript and I need to know how to do the following:
We have a lap timer, and the player has to complete two laps. We're going to award a gold medal for <6min laps, silver for 6-6;30 laps and bronze for >6:30 laps. These images will just pop up on the screen and give the user an option to quit to the main menu or restart the level.
I have creted the medals as PNGs in photoshop and imported them into the project.
Any help would be appreciated.
Thanks
Answer by Ejlersen · May 16, 2011 at 08:04 PM
Here is one way of doing it...
Example:
public Texture bronzeTexture; public Texture silverTexture; public Texture goldTexture;
public bool isRaceComplete = false; public Medal medal = Medal.None;
// Or whatever... If you have several resultions, then its may be better to do it with Screen.width, Screen.height... public Rect rect = new Rect(0.0f, 0.0f, 32.0f, 32.0f);
function OnGUI() { if (isRaceComplete) { if (medal == Medal.Bronze) GUI.DrawTexture(rect, bronzeTexture); else if (medal == Medal.Silver) GUI.DrawTexture(rect, silverTexture); else if (medal == Medal.gold) GUI.DrawTexture(rect, goldTexture);
// Add other options...
}
}
public enum Medal { None, Bronze, Silver, Gold };
Your answer
Follow this Question
Related Questions
Stack Overflow Exception & Importing Images So They Can Be Scripted 0 Answers
Image in GUI warped 1 Answer
GUI Texture in toolbar (C#) 1 Answer
Exporting to Iphone, bad changes... 1 Answer
Importing Image for GUI 1 Answer