Hello everyone,
Well, after months of developing my game, hundreds of hours of playtesting, coding, bugtesting, fixing, and then porting to Android I thought I'd still have some hurdles, but not the kinds I'm having. Welcome to coding, I suppose.
I'm trying to develop for the Ouya, and am having a strange issue. My game goes Splash Screen - Main Menu - (if select new game) - Are you sure screen - (If Yes) Intro. Now, when going from Are You Sure to Intro a command is inserted to delete PlayerPrefs and install new ones. (script below) In Windows, everything works fine. On the Ouya, however, when the player selects new the music for the intro begins, but the scene never changes, and after the intro would have ended (estimated guess based on the music's playthrough) the entire thing crashes. Now, am prepared to deal with it crashing when the gamescene starts, but the intro scene makes no sense, as it's just slides and music. I don't know if it's the Playerprefs commands that have something to do with it, or the limits of the Ouya itself. Any help is greatly appreciated. Thanks, and God bless.
**Are you sure script (Yes / No - Load to intro or back to main menu)**
var ammountInInventoryArray : int[]; // Holds how many items you have.
var itemNameArray : String[]; // The name of the array set in the hierarchy.
var onScreenText : GameObject[]; // Holds your gui text.
var numberOfItems : int = 6; // Total number of items in the game. Start counting this at zero. For example if you have 10 items then this number needs to be 9
// var selectedTextColor : Color; // Was suppose to let you selcet your text color. Couldn't get it to work :(
// private var
private var numberOfItemsDisplayed : int = 0; // These all keep your script running fine. I wouldn't mess with these unless you fully understand the script
private var itemPosition : int = 0;
private var colorCheck : int = 0;
private var currentPosition : GameObject;
private var upCheck : boolean = true; // Checks to see if your still holding up
private var downCheck : boolean = true; //Checks to see if your still holding down
// global variables
static var displayChanged : boolean = true; // Set this to true everytime there is an inventory change. It will auto set back to false once inventory is updated
static var selectingInventory : boolean = true; // Set this to true when your accessing your inventory in game. Set it to false when you don't want to access your inventory.
var PlayersPosition : GameObject;
var inventory2Script : Inventory2;
var ArrayA = new int[68];
function Start()
{
}
function Update()
{
if(selectingInventory == true)
{
SelectItemFromInventory(); // During the game if you want to access your inventory make sure selectingInventory is true.
}
if(displayChanged == true)
{
// Every time you add or take an item from inventory you should set displayChanged to true.
//This will keep the number of items you have up to curret without calling it every frame all game long.
DisplayItems();
}
}
function SelectItemFromInventory()
{
if(itemPosition < 0)
{
itemPosition = numberOfItems;
while(onScreenText[itemPosition].active == false)
{
itemPosition--;
}
}
if(itemPosition > numberOfItems)
{
itemPosition = 0; // Makes you go back to top if you hit the bottom of the list
print("this happened");
while(onScreenText[itemPosition].active == false)
{
itemPosition++;
if(itemPosition > numberOfItems)
{
break;
}
}
}
if(Input.GetAxis("Vertical") < -.5)
{
if(downCheck == true)
{
// moves you down an item
itemPosition++;
colorCheck = 0;
ResetTextColor(); // Sets text back to white
downCheck = false;
}
while(onScreenText[itemPosition].active == false)
{
itemPosition++; // this makes sure you don't stop on an empty item
if(itemPosition > numberOfItems)
{
break;
}
}
}
else
{
downCheck = true;
}
if(Input.GetAxis("Vertical") >.5)
{
if(upCheck == true)
{
// Moves you up the list
itemPosition--;
colorCheck = 0;
ResetTextColor();
upCheck = false;
}
if(onScreenText[itemPosition].active == false)
{
itemPosition--;
while(onScreenText[itemPosition].active == false)
{
itemPosition--;
if(itemPosition < 0)
{
break;
}
}
}
if(itemPosition < 0)
{
itemPosition = numberOfItems; // makes you go to the bottom if you hit the top of the list
}
}
else
{
upCheck = true;
}
currentPosition = onScreenText[itemPosition];
currentPosition.guiText.material.color = Color.magenta;// Changes the color so you know what item your on
//2840, 1362, 1320
if(Input.GetButtonUp("Action"))
{
if(itemPosition == 0){
PlayerPrefs.DeleteAll();
PlayerPrefsX.SetIntArray("Ammount in inventory", ArrayA);
PlayerPrefsX.SetVector3("PlayersPosition", PlayersPosition.transform.position);
PlayerPrefs.SetInt("CurXp", 0);
PlayerPrefs.SetInt("MaxXp", 100);
PlayerPrefs.SetInt("MaxHealth", 35);
PlayerPrefs.SetInt("CurHealth", 35);
PlayerPrefs.SetInt("Level", 1);
yield WaitForSeconds(3.0);
Application.LoadLevel(8);
}
if(itemPosition == 1){
Application.LoadLevel(11);
}
}
}
function DisplayItems()
{
if(numberOfItemsDisplayed <= numberOfItems)
{
if(ammountInInventoryArray[numberOfItemsDisplayed] <= 0)
{
onScreenText[numberOfItemsDisplayed].active = false; // turns items off if there isn't any in the inventory
}
else
{
onScreenText[numberOfItemsDisplayed].active = true; // turns items back on if they are in the inventory
onScreenText[numberOfItemsDisplayed].guiText.text = itemNameArray[numberOfItemsDisplayed]; // Displays the name and current amount in stock
}
numberOfItemsDisplayed++;
}
else
{
// Turns off this function so that it doesn't always play. Make displayChanged true when you need it back on.
displayChanged = false;
numberOfItemsDisplayed = 0;
}
}
function ResetTextColor()
{
while(colorCheck <= numberOfItems)
{
onScreenText[colorCheck].guiText.material.color = Color.white;
colorCheck++;
}
}
**Intro Slide Changer, just in case it might be that**
var BG1 : GameObject;
var BG2 : GameObject;
var BG3 : GameObject;
var BG4 : GameObject;
var BG5 : GameObject;
var BG6 : GameObject;
var BG7 : GameObject;
var BG8 : GameObject;
var BG9 : GameObject;
var BG10 : GameObject;
var BG11 : GameObject;
var BG12 : GameObject;
var BG13 : GameObject;
var BG14 : GameObject;
var BG15 : GameObject;
var BG16 : GameObject;
var Cam1 : Camera;
function Start () {
yield WaitForSeconds(8.0);
Cam1.SendMessage("fadeOut");
yield WaitForSeconds(3.0);
BG1.active = false;
BG2.active = true;
Cam1.SendMessage("fadeIn");
yield WaitForSeconds(12.0);
Cam1.SendMessage("fadeOut");
yield WaitForSeconds(3.0);
BG2.active = false;
BG3.active = true;
Cam1.SendMessage("fadeIn");
yield WaitForSeconds(12.0);
Cam1.SendMessage("fadeOut");
yield WaitForSeconds(3.0);
BG3.active = false;
BG4.active = true;
Cam1.SendMessage("fadeIn");
yield WaitForSeconds(12.0);
Cam1.SendMessage("fadeOut");
yield WaitForSeconds(3.0);
BG4.active = false;
BG5.active = true;
Cam1.SendMessage("fadeIn");
yield WaitForSeconds(12.0);
Cam1.SendMessage("fadeOut");
yield WaitForSeconds(3.0);
BG5.active = false;
BG6.active = true;
Cam1.SendMessage("fadeIn");
yield WaitForSeconds(12.0);
Cam1.SendMessage("fadeOut");
yield WaitForSeconds(3.0);
BG6.active = false;
BG7.active = true;
Cam1.SendMessage("fadeIn");
yield WaitForSeconds(12.0);
Cam1.SendMessage("fadeOut");
yield WaitForSeconds(3.0);
BG7.active = false;
BG8.active = true;
Cam1.SendMessage("fadeIn");
yield WaitForSeconds(12.0);
Cam1.SendMessage("fadeOut");
yield WaitForSeconds(3.0);
BG8.active = false;
BG9.active = true;
Cam1.SendMessage("fadeIn");
yield WaitForSeconds(12.0);
Cam1.SendMessage("fadeOut");
yield WaitForSeconds(3.0);
BG9.active = false;
BG10.active = true;
Cam1.SendMessage("fadeIn");
yield WaitForSeconds(12.0);
Cam1.SendMessage("fadeOut");
yield WaitForSeconds(3.0);
BG10.active = false;
BG11.active = true;
Cam1.SendMessage("fadeIn");
yield WaitForSeconds(12.0);
Cam1.SendMessage("fadeOut");
yield WaitForSeconds(3.0);
BG11.active = false;
BG12.active = true;
Cam1.SendMessage("fadeIn");
yield WaitForSeconds(12.0);
Cam1.SendMessage("fadeOut");
yield WaitForSeconds(3.0);
BG12.active = false;
BG13.active = true;
Cam1.SendMessage("fadeIn");
yield WaitForSeconds(20.0);
Cam1.SendMessage("fadeOut");
yield WaitForSeconds(3.0);
BG13.active = false;
BG14.active = true;
Cam1.SendMessage("fadeIn");
yield WaitForSeconds(12.0);
Cam1.SendMessage("fadeOut");
yield WaitForSeconds(3.0);
BG14.active = false;
BG15.active = true;
Cam1.SendMessage("fadeIn");
yield WaitForSeconds(12.0);
Cam1.SendMessage("fadeOut");
yield WaitForSeconds(3.0);
BG15.active = false;
BG16.active = true;
Cam1.SendMessage("fadeIn");
yield WaitForSeconds(12.0);
Cam1.SendMessage("fadeOut");
yield WaitForSeconds(3.0);
Application.LoadLevel(6);
}
function Update () {
if(Input.GetButtonUp("Action"))
Application.LoadLevel(6);
{
}
}
↧