Rendering multiple scenes



  • Hi, is it possible to have multiple scenes rendered at once?
    i try smth like this:

    var scene1:Scene = new Scene();
    var e1:Entity = new Entity(0, 0, Image.createRect(100, 100, 0xff0000));
    scene1.add(e1);
    
    var scene2:Scene = new Scene();
    scene2.bgAlpha = 0;
    var e2:Entity = new Entity(0, 0, Image.createRect(50, 50, 0x00ff00));
    scene2.add(e2);
    
    HXP.engine.pushScene(scene1);
    HXP.engine.pushScene(scene2);
    

    and i can only see scene2, the green square

    i've already asked this question here: http://forum.haxepunk.com/topic/21/applying-shaders-to-everything-except-ui/3
    but probably someone else will see it, if i create a new topic. sorry if it is against the rules



  • ok, if someone's interested, i'll describe what did the trick for me:
    i've pushed the second scene with some delay, like this:

            var scene1:Scene = new Scene();
            var e1:Entity = new Entity(0, 0, Image.createRect(100, 100, 0xff0000));
            scene1.add(e1);
            new haxe.Timer(1000).run = function(){
                e1.x += 1;
            }
    
            var scene2:Scene = new Scene();
            scene2.bgAlpha = 0;
            var e2:Entity = new Entity(0, 0, Image.createRect(50, 50, 0x00ff00));
            scene2.add(e2);
            new haxe.Timer(1000).run = function(){
                e2.y += 1;
            }
    
            HXP.engine.pushScene(scene1);
            haxe.Timer.delay(function(){
                HXP.engine.pushScene(scene2);
            }, 1000);
    

    it gives the first scene time to update it's add/remove list, which adds entities to the display list.
    not sure if it is the best practice though. added coordinate shift to demonstrate that both scenes are upated correctly afterwards


Log in to reply
 

Looks like your connection to NodeBB was lost, please wait while we try to reconnect.