Sign in to follow this  
eguneys

How to size TilingSprite and run on single direction

Recommended Posts

I have a tiling image that is 300x200 I want this image to sit on the bottom of game canvas and tile only horizontally. The example given sets the size in constructor with renderer.width/height that doesn't work if this size is smaller.

Share this post


Link to post
Share on other sites

Are you saying TilingSprite will only work for the whole stage that is entire application. Can I make it work inside a display container? I want to make the tiling image bigger.

 

For example:

 

// What is this width/height corresponds to, why is it set to renderer.width, can I set it to the texture size.
let tsprite = new TilingSprite(texture, width, height);

// I want to make the sprite bigger. Setting the width/height doesn't work. Why `tileScale` why not just `scale`?
tsprite.tileScale.x = 2;
tsprite.tileScale.y = 2;

// Now I don't know the width/height of this sprite I have to position it to the bottom. 
// Do I just have to eyeball the position and set it to some ratio of the displayHeight,
// so it becomes responsive?

// tsprite.position.y = displayHeight - tsprite.height
tsprite.position.y = displayHeight * 0.7;

Here's the demo https://eguneys.github.io/jsgames/work.html

 

And here's the repository: https://github.com/eguneys/orb

Edited by eguneys

Share this post


Link to post
Share on other sites

Tilingsprite is a sprite. No requirements for its size. Just make it "0.3*screen.height" , and position at the bottom , either like you did it, either by specifying anchor.y=1 and setting position to "screen.height"

I have a feeling that you didnt try to experiment with it enough.

Edited by ivan.popelyshev

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.