Hi everyone, in advance, sorry for the bad English. The title doesn’t really say much about my problem, it’s a little complicated to explain:
The issue is this, I have a group of GUITextures (six) that I can drag with my finger in a touch device, that works fine in the android emulator, the problem is that I want to store de name of the accion in a simple javascript Array (which has a determinated size of 4), but that only works for the accion number one (accion1). In a little more graphic explanation, the 4 empty circles represent the empty Array, it initialized with “(vacio)” in each position, when I drag the textures to the circles, the ControlAcciones.js script must send to the array the name of the object (accion1, accion2… accion6) but it ONLY WORKS WITH THE accion1 TEXTURE
I left the ControlAcciones.js script:
#pragma strict
var letrero:GUIText;
private var accion:GUITexture;
private var esferas_accion:GameObject[];
private var seleccionada=false;
private var acciones_listas=new Array();
function Start()
{
accion=gameObject.guiTexture;
letrero.text="";
//Get the action_spheres (1,2,3 and 4):
esferas_accion=GameObject.FindGameObjectsWithTag("EsferaDeAccion");
//They're disordered, I ordered here (redundant usage of methods, I know)
for(var i=0;i<esferas_accion.length;i++)
{
esferas_accion*=GameObject.Find("action_sphere_"+(i+1));*
acciones_listas*=“(vacio)”;//Initialize positions.
_ }_
_ print(accion.name);_
_}_
function Update()
_{_
_ for(var t:Touch in Input.touches)_
_ {_
_ switch(t.phase)_
_ {_
_ case TouchPhase.Began://Drop finger._
_ if(accion.HitTest(t.position))_
_ { _
_ seleccionada=true;_
_ //Zoom and center guitexture:_
_ var factor=accion.pixelInset.width/3;_
var x=accion.pixelInset.x;
_ var y=accion.pixelInset.y;*
* var an=accion.pixelInset.width;*
* var al=accion.pixelInset.height;*
* accion.pixelInset=Rect(x,y,an+factor,al+factor);
_ accion.pixelInset.x=t.position.x-accion.pixelInset.width/2;*
* accion.pixelInset.y=t.position.y-accion.pixelInset.height/2;*
* }*
* else*
* seleccionada=false;*
* break;*
* case TouchPhase.Moved://Drag finger:*
* if(seleccionada)*
* {*
* var b=false;*
* //Center:*
* accion.pixelInset.x=t.position.x-accion.pixelInset.width/2;*
* accion.pixelInset.y=t.position.y-accion.pixelInset.height/2;*
* //If accion is over an action_sphere, let says true:
for(var n=0;n<esferas_accion.length;n++)
_ if(accion.HitTest(Camera.main.WorldToScreenPoint(_
esferas_accion[n].transform.position)))
_ b=true;_
_ letrero.text=(b)?“true”:“false”;_
_ }_
_ break;_
_ case TouchPhase.Ended://Lift the finger:_
_ seleccionada=false;_
_ letrero.text=“”;_
//Verify if accion is over an action_sphere:
for(var i=0;i<esferas_accion.length;i++)
_ {_
_ //This only works with accion1 _
_ if(accion.HitTest(Camera.main.WorldToScreenPoint(_
esferas_accion.transform.position)))
_ {
letrero.text=accion.name+" is on “+(i+1)+”
“;_
acciones_listas=accion.name;
_ }
}_
//Print the array acciones_listas to the let GUIText:
for(i=0;i<acciones_listas.length;i++)
letrero.text+=acciones_listas+” ";
_ //Return accion to the original position:
var x=-1;
for(i=0;i<6;i++)
if(accion.name==“accion”+(i+1))
x=i50;
* accion.pixelInset=Rect(x,0,35,35);
break;
}
}
}*
And here’s the whole proyect:
Dropbox - Error - Simplify your life
Many thanks for your help, I have more than a week with this and I’m a little desperate :s_