For example player click on the word, i want the color to stay on instead of going back to the original color. Don’t know if you get what i am asking. For example, initially the color is white, so when player’s mouse over the text, it will turn to blue but when the mouse exit it will turn to the original color “white”, how can i retain the color blue? Because i want to let the player know which alphabets they have clicked.
function OnMouseEnter()
{
guiText.material.color = Color.blue;
}
function OnMouseExit()
{
guiText.material.color = Color.white;
}
Another question is that for example player finish playing level1. But the player instead of proceed to the next level, they click to the main menu. So when they feel like continue the game, i want them to go to level 2 instead of the level 1 that they have already play and complete. How do i solve it?
Try this, this code have not been tested yet. I think it will work.
for question 2, I dont understand what you want to do, are you saying that when the player finish the 1st level they went back to main menu and from main menu you choose to continue played to level 2.
Thank you for the reply. For the 2nd question, i mean for example, you play a game until certain level then you have to stop to do something else. So when you are going back to the game, you are expecting to be direct to the level you stop instead of restarting from level1.
Just take the PlayerPrefsX.js from there and put it into your Standard Assets folder from your project.If you don’t have a Standard Assets folder,make one,and then you can use something like:
var player : GameObject;
function OnTriggerEnter () {
PlayerPrefsX.SetVector3("PlayerPosition", player.transform.position);
print("player position saved");
}
Make a cube,make it’s size bigger…and then check the Is Trigger button below the Box Collider.Attach this script onto your created cube.Everytime the player passes through the cube it saves the player’s position…exactly where your cube is.
If you want to load your player position just use:
Hello Thunderent, actually i am doing a puzzle game. So i do not have to store the player position or score. Perhap i might need to store those words that the player formed. To be exact, i don’t think i need to store any value. I just want to make sure that the player are in the correct level. You get what i trying to say?
Hi hizral84, it work properly. I need to do some checking on the onMouseExit(). But as i am doing puzzle games, for example player form word “A T E”, the words will disappear and being replaced by a new words AEO. how do i reset the click button. I don’t know if you understand. For example, when player click A T E, it will remain blue color right? So once the correct word formation, the A T E will be disappear and being replaced by A E O. But A E O is still remain blue whereas it should be in white.‘’’
1.If finish level 1, save state for level 1 finished.
2.At main menu make a state that tell if level 1 is finished auto load to level 2
→ i don’t really understand this. Could you explain in details with code xample? thank you
I think for this one you need to do some checklist code, so to check if the word you have cross out is in the checklist or not, per say you click “A T E”, so if there is ATE in the checklist return the color back to white. never done this before but in theory I would do it like this.
for the level state example, this is just a pseudo code. you might need to change it:
this script inside level1 to tell that level1 is completed
static var levelOneIsDone : boolean = false;
function Update()
{
levelOneIsDone = true;
if(levelOneIsDone == true)
{
//return to main menu
}
else
{
//do something else
}
}
and then this script inside main menu and check if level1 is completed.
function Update()
{
if("nameOfTheScript".levelOneIsDone == true) //to check if level1 is complete
{
//jump to level2 instead
}
else
{
//do something else
}
}