Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Sprite position relative to parent (container), behavior strangeness


Cyberguille
 Share

Recommended Posts

I have  a container with a group of  with one child sprite objects. So my target is to have this sprites in two rows.
 
Fragment of my code:

 

                       
 var container = new PIXI.Container();                        stage.addChild(container);                        for (var j = 0; j < 2; j++) {                            for (var i = 0; i < options.length/2; i++) {                                console.log("j: "+ j);                                console.log("i: "+ i);                                var sprite= options[j*4+i];                                console.log("140 * j="+ 140 * j);                                console.log("140 * i="+140 * i);                                sprite.position.set(140 * j,140 * i);                                console.log("x: "+ sprite.x);                                console.log("y: "+ sprite.x);                                container.addChild(sprite);                            };                        };                        container.x=200;                                              container.y=300; 

but this is what I get:

xnjppjR.png?1

 

and  when I debug with google chrome I see this:

F33Wil2.png

 

 

So the values of x and y are not taking the values that I think should have, as you can see above in my code
sprite.position.set(140 * j,140 * i);
then is impossible that 140*i=280 and y=0

 

 

this is the fragment to create  each sprite:

function numberContainer(a,texture){    var slice = new PIXI.Sprite(texture);    slice.anchor.set(0.5,0.5);    slice.heigth = slice.width =a;    slice.buttonMode = true;    slice.interactive = true;     slice.on('mousedown',function(){       //do something    });    return slice;}

any idea please, thanks in advance

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...