PIXI elements disappear on Pause

Discussion in 'Learning Javascript' started by Seth-Rah, Nov 5, 2017.

  1. Seth-Rah

    Seth-Rah professional amateur Member

    Messages:
    22
    Likes Received:
    7
    Location:
    South Africa
    First Language:
    English
    Primarily Uses:
    RMMV
    I have been getting issues when using the pause button in my experimentation.

    It seems that every time I pause, it erases all pixi elements from the scene. is there any way to make them persist / redraw after the pause finishes?

    Open link below to see footage of it occurring.

     
    #1
  2. Jonforum

    Jonforum Veteran Veteran

    Messages:
    1,574
    Likes Received:
    1,339
    Location:
    Canada / Québec
    First Language:
    French
    Primarily Uses:
    RMMV
    yes look in the Spriteset_Map
    eatch time you change scene , you need add the pixi object to scene again. (addChild)

    it depends on how and where you stored your pixi objects.

    example here

    when Scene load , it load map again.
    PHP:
        pixiSSA._rmmvAlias.Spriteset_Map_createLowerLayer Spriteset_Map.prototype.createLowerLayer;
        
    Spriteset_Map.prototype.createLowerLayer = function() {
            
    pixiSSA._rmmvAlias.Spriteset_Map_createLowerLayer.call(this);
            
    // this.createParallax(); from Spriteset_Map_createLowerLayer
            
    this.bindToMapOBJ pixiSSA._animationControler._pictures.bindToMapOBJ// have list of all BindToMapData bindToMapData
            
    this.addPixianiLayerZ(); // assign correct z index layers
        
    };
    And i add again the child of my pixi object to the map.
    with my function this.addPixianiLayerZ();

    PHP:
        Spriteset_Map.prototype.addPixianiLayerZ = function() { // procced to add other layers with Z to _tilemap and TOP
            
    var pixiLayers pixiSSA._animationControler._pictures;
            for(var 
    pixiLayers.asignedToRMMV.length;i--;){
                
    this._tilemap.addChildpixiLayers[pixiLayers.asignedToRMMV[i]]);
            };
            var 
    pixiLayers pixiSSA._animationControler._pictures;
            for(var 
    pixiLayers.layersAsignTo_topLayers.length;i--;){
                
    this._baseSprite.addChild(pixiLayers[pixiLayers.layersAsignTo_topLayers[i]]);
            };
        };
    in my case, when my map change , my pixi object not destroy because a store in a variable.
    When map load , i just need to add this variable as child to the map.
    it is an example among many, but I let you study this, these the best way to learn.

    ps: pause, combat, or menu = change map scene.
     
    #2
    Seth-Rah likes this.
  3. Seth-Rah

    Seth-Rah professional amateur Member

    Messages:
    22
    Likes Received:
    7
    Location:
    South Africa
    First Language:
    English
    Primarily Uses:
    RMMV
    So I have tried to implement this

    I have some questions, I see you calling a lot of pixiSSA however I don't have access to it or any of the appended features.
    Is this a plugin you are using or is this some of your own code?

    ==EDIT==

    Friend gave me some insight to your code and helped me a lot with understanding it better. I think I get it now, but I will only really be able to try it out in about a week from now as I will be busy with studies. Will be sure to update the post if progress is made.
     
    Last edited: Nov 14, 2017
    #3
  4. Seth-Rah

    Seth-Rah professional amateur Member

    Messages:
    22
    Likes Received:
    7
    Location:
    South Africa
    First Language:
    English
    Primarily Uses:
    RMMV
    Ok, thanks for all the assistance, I understand now what you were trying to do and it seems to have worked like a charm :)
    Still really new to programming so I was a bit in the dark on what you were trying to do, but I realized a bit late that you were probably storing your elements you want to recreate in their own places.

    PHP:
    MyGameStuff.prototype.sprites = [goRightgoLefttesttext2]

    Spriteset_Map.prototype.createLowerLayer_old Spriteset_Map.prototype.createLowerLayer;
    Spriteset_Map.prototype.createLowerLayer = function() {
        
    //use strict because the "let" call does not work without it.
        
    "use strict";
        
    //call the old method
        
    Spriteset_Map.prototype.createLowerLayer_old.call(this);
        
    //add all objects to map again
        
    for(let i 0MyGameStuff.prototype.sprites.length;i++){
          
    this._tilemap.addChild(MyGameStuff.prototype.sprites[i]);
          
    console.log("WE MADE IT TO THE END OF THE FUNCTION BOYS")
        }
    };
    I am curious about one thing though, is there a reason you declared pixiLayers twice with the same content?
     
    #4
    Jonforum likes this.
  5. Jonforum

    Jonforum Veteran Veteran

    Messages:
    1,574
    Likes Received:
    1,339
    Location:
    Canada / Québec
    First Language:
    French
    Primarily Uses:
    RMMV
    yes there is 10 or more than 100 way to do and code the same result.
    Each one codes according to these knowledge.
    I do not recommend storing objects in a prototype.
    Except if these really nessary.
    This has a very negative impact on performance.

    you can try to embed and get result with
    PHP:
    var t0 performance.now();
    doSomething();
    var 
    t1 performance.now();
    for a website, or an application, this can be ok.
    But for a game, it is preferable to always opt for optimizing code.


    And 2 time yes.
    because
    this._tilemap.addChild( pixiLayers[pixiLayers.asignedToRMMV]);
    its for the tileMap in rmmv layer (z-index)
    and after i add final layer Top to the _baseSprite
    this._baseSprite.addChild(pixiLayers[pixiLayers.layersAsignTo_topLayers]);

    _baseSprite it over all rmmv element, so am shure it maximum top rendering
    _tilemap it where your event, parralaxe, event middle, botom, tiles... are rendering
     
    Last edited: Nov 15, 2017
    #5
    Seth-Rah likes this.
  6. Seth-Rah

    Seth-Rah professional amateur Member

    Messages:
    22
    Likes Received:
    7
    Location:
    South Africa
    First Language:
    English
    Primarily Uses:
    RMMV
    Currently I am storing the objects globally because I will be using it on each map, and storing the array that holds my map elements as a prototype.
    I still don't really understand how prototypes work, but I will remove them from the prototype for now then.

    At this time I know nothing on performance impact, the closest I got to seeing anything impacting my performance was when I was having an object get recreated infinitely because I never erased an event.
     
    #6
  7. Jonforum

    Jonforum Veteran Veteran

    Messages:
    1,574
    Likes Received:
    1,339
    Location:
    Canada / Québec
    First Language:
    French
    Primarily Uses:
    RMMV
    i edit upper.
    and you can maybe get a look at the my full script here.
    I add comments everywhere.
    This could help you to have some idea about my code in general.
    Download the version 1.0 (unCompress dev)
    the plugin are not final,but he meets my needs now
    https://forums.rpgmakerweb.com/inde...ets-animations-core-v1-0-texturepacker.83083/

    look at the line 1940 also 731 for layer
     
    #7
    Seth-Rah likes this.

Share This Page