arrays - Adding background at certain part -


i'm updating text adventure engine , want add background each part of story. problem @ moment making backgrounds appear respective part.

public var parts:object =  {      "0":         {             "text":"you're name david, agoraphobic 24 year old. it's 12:32 am, woken abruptly glass smashing inside house.",             "choices":                 {                     "response1":                         {                             "text":"investigate",                             "nextpart":"1"                         },                     "response2":                         {                             "text":"ignore it. need beauty sleep.",                             "nextpart":"2"                         }                  },         }, 

what add can make background appear @ each part.

here's backgrounds have (defined after parts)

[embed(source = "../backgrounds/old-bedroom.png")] public var background1:class public var background1png:bitmapdata  public var bg1:bitmap = new background1 public var br:sprite = new sprite();  [embed(source = "../backgrounds/img010.jpg")] public var background2:class public var background2png:bitmapdata  public var bg2:bitmap = new background2 public var lr:sprite = new sprite(); 

since embedding background images , "parts" data structure, can refer background classes in parts object:

"0": {     "text": "...",     "choices": { ... },     "background": background1 } 

then in code update game "part", display background referenced part:

var background:bitmap; function updatebackground(part:object):void {     if (background) {         // remove old background         removechild(background);     }     // add new background     background = new part.background();     addchild(background); } 

Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -