- Home /
Am i using good the array ?
Hello how are you? I'm having a problem with my game, it's a kind of book. Each leaf is an object, each blade is you will keep in an array. At the start of the first sheet is active, but when broken page, disable and enable the next. The problem is that I can not decipher what this fix malfunctioning. Hope you can help.
// Update is called once per frame
void Update ()
{
this.realizarMovimiento(this.chequearTeclado());
}
public string chequearTeclado()
{
if(Input.GetKey(KeyCode.RightArrow))
{
this.queBotonToca = "DERECHA";
return "Derecha";
}
else if(Input.GetKey(KeyCode.LeftArrow))
{
this.queBotonToca = "IZQUIERDA";
return "Izquierda";
}
else
{
this.queBotonToca = "NADA";
return "Nada";
}
}
public void realizarMovimiento(string botonQueTocan)
{
if(botonQueTocan == "Derecha")
{
this.realizarRotacionDIADcon(this.dameLaPaginaActiva());
}
else if(botonQueTocan == "Izquierda")
{
this.realizarRotacionDDAIcon(this.dameLaPaginaActiva());
}
}
public void realizarRotacionDDAIcon(paginaYlado paginaActiva)
{
this.rotarDDAIa(paginaActiva);
if(paginaActiva.tieneAnterior == false)
{
//es la primera pagina
this.desplazarHaciaArribaSiguientesDe(paginaActiva);
}
else
{
//no es la primera pagina
this.desplazarHaciaAbajoAnterioresDe(paginaActiva);
this.desplazarHaciaArribaSiguientesDe(paginaActiva);
}
this.cambiarActivoAlSiguienteDe(paginaActiva);
}
public void realizarRotacionDIADcon(paginaYlado paginaActiva)
{
this.rotarDIADa(paginaActiva);
if(paginaActiva.tieneAnterior == false)
{
//es la primera pagina
this.desplazarHaciaAbajoSiguientesDe(paginaActiva);
}
else
{
//no es la primera
this.desplazarHaciaAbajoSiguientesDe(paginaActiva);
this.desplazarHaciaArribaAnterioresDe(paginaActiva);
}
this.cambiarActivoAlAnteriorDe(paginaActiva);
}
public paginaYlado dameLaPaginaActiva()
{
int i;
for( i=0; i<4; i++)
{
if(this.coleccionPaginas[i].estaActiva == true)
{
return this.coleccionPaginas[i];
}
}
this.check1 = "Nunca deberia entrar aca";
return this.coleccionPaginas[i];
}
public void rotarDDAIa(paginaYlado paginaActiva)
{
iTween.RotateBy(paginaActiva.pagina, iTween.Hash("y", .50, "time", 4, "delay", .2));
}
public void rotarDIADa(paginaYlado paginaActiva)
{
iTween.RotateBy(paginaActiva.pagina, iTween.Hash("y", -.50, "time", 4, "delay", .2));
}
I can't help you because I can't read your code, because it's in a different language. $$anonymous$$ost people who could help you won't understand it either. Please translate it, so we can help you too :)
A description of what you mean by "malfunctioning" might help get this question answered.
I can read your code but I urge you to learn about
List
It is much easier and better to use than arrays. Never use arrays, just use List. Search on here for 100s of examples.
Lists are dope if you need a dynamically sized action but I don't use them like a global replacement for arrays.
Your answer
Follow this Question
Related Questions
How to generate unique random number 1 Answer
How could I create a book? 6 Answers
How could I use quads to make a book? 2 Answers
How could I write a script to flip pages of a book? 1 Answer