Addscene() Example?

Discussion in 'Buildbox 3.0' started by AaroArts, Nov 23, 2019.

  1. AaroArts

    AaroArts Miniboss Boxer

    Joined:
    Jun 22, 2016
    Messages:
    1,546
    Likes Received:
    826
    Hello.
    Does anyone have an example of AddScene() working in BB3?
    Thanks
     
  2. weboha

    weboha Avid Boxer

    Joined:
    Aug 8, 2018
    Messages:
    239
    Likes Received:
    178
    add this code in your chracher (game start)

    start scene always added.

    this.scene().addLevel('scene1'); //scene names
    this.scene().addLevel('scene2');
    this.scene().addLevel('finish');
    ------------------------------------------------------------------
    random scene and finish sample
    scn1=Math.round(Math.random() *9)+1; //you have 10 scenes. names are 1,2,3,..10
    scn2=Math.round(Math.random() *9)+1;
    this.scene().addLevel(String(scn1)); //random scene
    this.scene().addLevel(String(scn2));
    this.scene().addLevel('finish'); //finish is scene name
     
    Moaula and Hanomax like this.
  3. whitedogapp

    whitedogapp Avid Boxer

    Joined:
    Oct 8, 2015
    Messages:
    295
    Likes Received:
    72
    can u show it in node
     
  4. weboha

    weboha Avid Boxer

    Joined:
    Aug 8, 2018
    Messages:
    239
    Likes Received:
    178
  5. sebb121

    sebb121 Boxer

    Joined:
    Dec 10, 2017
    Messages:
    75
    Likes Received:
    56
    I second this! It would be a huge help! @weboha
     
  6. AaroArts

    AaroArts Miniboss Boxer

    Joined:
    Jun 22, 2016
    Messages:
    1,546
    Likes Received:
    826
    How do you stop it spawning scenes after Finish?
     
  7. weboha

    weboha Avid Boxer

    Joined:
    Aug 8, 2018
    Messages:
    239
    Likes Received:
    178
    finish scene is very long.
     

    Attached Files:

    AaroArts likes this.
  8. Selvamax

    Selvamax Boxer

    Joined:
    Dec 30, 2019
    Messages:
    10
    Likes Received:
    1
    or guys who couldn't make addScene() working. You have to follow this rule.
    *** You need to add final scene in the end, its damn compulsory else it won't work ***
    For example
    this.scene().addLevel('Scene1');
    this.scene().addLevel('Scene2');
    this.scene().addLevel('Finish');

    Example 2
    this.scene().addLevel('Scene3');
    this.scene().addLevel('Scene4');
    this.scene().addLevel('Finish');
     
  9. Redouane

    Redouane Boxer

    Joined:
    Nov 18, 2018
    Messages:
    12
    Likes Received:
    0
    For me it is working without the finish part. So I basically randomized everything. The only issue right now is that I want to do it in parts. So let's say that I have 4 sections of 5 scenes, every scene is 100 frames (in my game every scene is a level with a finish). First I want the first 5 scenes/levels to randomize until 2000 frames. So looped 4 times. Same with second and third section. and then i want the last section to randomize infinitly. Anyone can help?

    Thanks
     
  10. batcomic

    batcomic Boxer

    Joined:
    Oct 8, 2015
    Messages:
    1
    Likes Received:
    0
    Thanks to everyone for the sample code and help. If anyone is having a level endlessly repeating issue, this is what I used to get a consistent randomization without it getting stuck in an endless same level loop.

    function signal(name, value, sender){
    scn1=Math.round(Math.random() *8)+2; // I used *8)+2 because I want a value of 2-10 but never 1
    scn2=Math.round(Math.random() *8)+2;
    scn3=Math.round(Math.random() *8)+2;
    scn4=Math.round(Math.random() *8)+2;
    scn5=Math.round(Math.random() *8)+2;
    scn6=Math.round(Math.random() *8)+2;
    scn7=Math.round(Math.random() *8)+2;
    scn8=Math.round(Math.random() *8)+2;
    scn9=Math.round(Math.random() *8)+2;

    this.scene().addLevel(String(scn1));
    if (scn1!=scn2){this.scene().addLevel(String(scn2));}
    if (scn2!=scn3){this.scene().addLevel(String(scn3));}
    if (scn3!=scn4){this.scene().addLevel(String(scn4));}
    if (scn4!=scn5){this.scene().addLevel(String(scn5));}
    if (scn5!=scn6){this.scene().addLevel(String(scn6));}
    if (scn6!=scn7){this.scene().addLevel(String(scn7));}
    if (scn7!=scn8){this.scene().addLevel(String(scn8));}
    if (scn8!=scn9){this.scene().addLevel(String(scn9));}
    }

    It ends up looping back to my 1st scene out of 10 and loops new randomizations
    It may be a bit hacky, but hopefully someone finds it useful.
     
  11. whitedogapp

    whitedogapp Avid Boxer

    Joined:
    Oct 8, 2015
    Messages:
    295
    Likes Received:
    72
    do u have eny example of this: if i go back to load scene, bb3 is deleting previous scenes and need to load again them
     
  12. Yissou

    Yissou Boxer

    Joined:
    Dec 30, 2019
    Messages:
    1
    Likes Received:
    0
    this.scene().addLevel(String(Math.round(Math.random() *25)+17));

    hi i need to understand how this line calculate, could somebody explain it pls
     

Share This Page