I want to create an object within another, but I can not use adds in sprite - HaxeFlixel

2

I want to create a box with a coin, which appears when I destroy it. The problem arises when I break the box, the currency appears but it is invisible because I can not do add in the states . How can I create the coin in another way so that it appears only when I destroy the box?

This is the code with which I tried to solve it:

class Obstaculo extends FlxSprite{ // Base para una clase por lo que no comentare mas hasta que tenga s
    private var destructible:Int = FlxG.random.int(0, 1);
    private var dropeable:DropFalling; // esto es para asignarle un drop
    private var destructible:Int = FlxG.random.int(0, 1);
    private var danio:Int = 0;
    private var golpeado:Bool = false;
    // private var direccionDelGolpe:Bool = false; // indica la direccion del golpe para determinar vel
    private var contador:Int = 0; // ahora lo uso para saber cuanto tiempo se mueve la caja indestructi
    public function Golpeada(personaje:Jugador){
        golpeado = false;
        if (destructible == 1 && golpeado == false){
            danio += 1; //por cada golpe lastima la caja 6 veces. 3 golpes para matarla.
            contador = Reg.effectTimer - 5;
            trace ("crash");
            if (danio == 3){
                dropeable = new DropFalling(x+14, y+29);
                dropeable.SetBroken(true);
                add(dropeable); // ...?
                Reg.puntaje += 10;
                // ...
}}}}
    
asked by Rodrigo Diaz 02.06.2017 в 21:25
source

0 answers