• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Juego de plataformas AS3. Coleccionables, Arrays y grabado de datos.

Community Beginner ,
Sep 12, 2017 Sep 12, 2017

Copy link to clipboard

Copied

Buenas, estoy haciendo un prototipo para recoger monedas, desaparezcan y que sólo se grabe si toco con el personaje el MovieClip de grabar. Quiero decir, que si toco ese mc, al cerrar el swf y volverlo a abrir, la moneda no debería volver a aparecer.

Llevo muchos días buscando archivos viejos de As2 para convertirlos a As3, pero ha llegado el momento de pedir ayuda. Necesito si alguien me da una estructura y yo seguirla. Hasta ahora lo que tengo es esto:

EN la Clase principal:

Código ActionScript :

                //ARRAYS       var moneda:Array = new Array();       var miArray1:Array = [1,1,1];       var monedasArray1:Array = [];       var posicionMonedasx:Array = [131.25,232.3,309.25];       var posicionMonedasy:Array = [138.9,138.9,138.9];                 //VARIABLES       var tamañoMonedasArray1;       var a;



En la función constructora:

Código ActionScript :

                if (miSO.data.miArray1Grabado != null)          {             miArray1 = miSO.data.miArray1Grabado;          }              var i = 0;          while (i < miArray1.length)          {             moneda = new Moneda();             moneda.x = posicionMonedasx;             moneda.y = posicionMonedasy;             var monedaPusheada = addChild(moneda);             monedasArray1.push(monedaPusheada);             ++i;          } 



Y dentro de la función con listener ENTER_FRAME:

Código ActionScript :

                 tamañoMonedasArray1 = monedasArray1.length;          a = 0;          while (a < tamañoMonedasArray1)          {             var monedaDentroArray = monedasArray1;             if (monedasArray1 != null)             {                 if (miArray1 == 0)                {                   monedaDentroArray.gotoAndStop(2);                         ... = 0;                   monedasArray1 = null;                   monedaDentroArray.gotoAndStop(2);                 }             }        ...



El problema que tengo con este código que he hecho es que después de coger una moneda y tocar elGrabador para grabarla, si cierro el programa y vuelvo a tocar cualquiera de las 2 monedas restantes, cierro sin volver a tocar elGrabador y vuelvo a abrir el swf, esas monedas no grabadas ya no aparecen. Espero que no sea un lío, gracias.

TOPICS
ActionScript

Views

500

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Sep 13, 2017 Sep 13, 2017

you're welcome.

Votes

Translate

Translate
Community Expert ,
Sep 12, 2017 Sep 12, 2017

Copy link to clipboard

Copied

your code's not legible.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 12, 2017 Sep 12, 2017

Copy link to clipboard

Copied

Buenas, estoy haciendo un prototipo para recoger monedas, desaparezcan y que sólo se grabe si toco con el personaje el MovieClip de grabar. Quiero decir, que si toco ese mc, al cerrar el swf y volverlo a abrir, la moneda no debería volver a aparecer.

Llevo muchos días buscando archivos viejos de As2 para convertirlos a As3, pero ha llegado el momento de pedir ayuda. Necesito si alguien me da una estructura y yo seguirla. Hasta ahora lo que tengo es esto:

EN la Clase principal:

                //ARRAYS

var moneda:Array = new Array();

var miArray1:Array = [1,1,1];

var monedasArray1:Array = [];

var posicionMonedasx:Array = [131.25,232.3,309.25];

var posicionMonedasy:Array = [138.9,138.9,138.9];

              //VARIABLES

var tamañoMonedasArray1;

var a;

En la función constructora:

if (miSO.data.miArray1Grabado != null)

{

miArray1 = miSO.data.miArray1Grabado;

}

var i = 0;

while (i < miArray1.length)

{

moneda = new Moneda();

moneda.x = posicionMonedasx;

moneda.y = posicionMonedasy;

var monedaPusheada = addChild(moneda);

monedasArray1.push(monedaPusheada);

++i;

}

Y dentro de la función con listener ENTER_FRAME:

tamañoMonedasArray1 = monedasArray1.length;

a = 0;

while (a < tamañoMonedasArray1)

{

var monedaDentroArray = monedasArray1;

if (monedasArray1 != null)

{

if (miArray1 == 0)

{

monedaDentroArray.gotoAndStop(2);

                                        //(No me deja hacer un removeChild, no se por qué).

}

if (protagonista.hitTestObject(monedaDentroArray))

{

miArray1 = 0;

monedasArray1 = null;

monedaDentroArray.gotoAndStop(2);

}

}

++a;

}

if (protagonista.hitTestObject(elGrabador))

{

miSO.data.miArray1Grabado = miArray1;

miSO.flush();

}

El problema que tengo con este código que he hecho es que después de coger una moneda y tocar elGrabador para grabarla, si cierro el programa y vuelvo a tocar cualquiera de las 2 monedas restantes, cierro sin volver a tocar elGrabador y vuelvo a abrir el swf, esas monedas no grabadas ya no aparecen. Espero que no sea un lío, gracias.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 12, 2017 Sep 12, 2017

Copy link to clipboard

Copied

the first error i see is miSO is not defined.  eg, somewhere you should have something like:

var miSO:SharedObject=SharedObject.getLocal('whatever','/');

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 12, 2017 Sep 12, 2017

Copy link to clipboard

Copied

Of course, I defined that, but I did not want to write it here...

I just solved it...!!  I just had to copy that:

if (miSO.data.miArray1Grabado != null)

{

miArray1 = miSO.data.miArray1Grabado;

}

inside the while loop, at the end of it. Thank you!!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 13, 2017 Sep 13, 2017

Copy link to clipboard

Copied

LATEST

you're welcome.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 12, 2017 Sep 12, 2017

Copy link to clipboard

Copied

At the end of last hitTestObject (elGrabador), not the while loop. Thank you for your time.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 12, 2017 Sep 12, 2017

Copy link to clipboard

Copied

Aquí está:

[removed by moderator]

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines