Jump to content

table with different graphics ?


espace
 Share

Recommended Posts

hi,

is it possible to store graphics in a table to have different name of my graphics (player and opponent) ?

the main reason is to have only one object to add in my container and be able to recognize each element of background.

I try with this but it's not the good format it seems....

thanks for your advice. 

 

var w = 320
var h = 480
var w2 = w/2
var h2 = h/2

var red=0xFF0000
var blue=0x009AFF

var background={}
background.opponent=new PIXI.Graphics()
background.opponent.beginFill(red);
background.opponent.drawRect(0,0,w2,h);

background.player=new PIXI.Graphics()
background.player.beginFill(black);
background.player.drawRect(w2,0,w2,h);

 

Link to comment
Share on other sites

var background= new PIXI.Container();

background.opponent=new PIXI.Graphics()
background.opponent.beginFill(red);
background.opponent.drawRect(0,0,w2,h);
background.addChild(background.opponent);

background.player=new PIXI.Graphics()
background.player.beginFill(black);
background.player.drawRect(w2,0,w2,h);
background.addChild(background.player);

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...