Sign in to follow this  
lilsheep

Trying to add a child to another object, but it isn't moving with the parent!

Recommended Posts

I am trying to get structure to be glued to cobblestone ground! So that their X values are dependent!


However cobblestone ground just stays in the same place(on the screen, setViewportX doesn't do anythin!)



function Background() {
var texture = PIXI.Texture.fromImage("cobblestone_ground.png");
PIXI.TilingSprite.call(this, texture, 4000, 100);
this.position.x = 0;
this.position.y = 370;
this.tilePosition.x = 50;
this.tilePosition.y = 0 ;
this.viewportX = 1000;
var structure = new PIXI.Sprite(PIXI.Texture.fromImage("spire.png"));
structure.position.y = -100;
this.addChild(structure);
};

Share this post


Link to post
Share on other sites

I don't know what "setViewportX" will do so I can't tell you, but changing "Background" position should seem to move the structure since it is a child of Background.

 

If not, show me an example that doesn't work an I can look into it.

Share this post


Link to post
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...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.