gRoberts

TileSprite without repetition?

Recommended Posts

Hey all,

Working on a game that animates a number of different layers to produce an parallax effect however I'm stuck when trying to repeat a single instance of a tile across the world and once out of view, it comes back in, i.e. marquee effect.

The only ways I can think of doing this is:

  1. Create an asset with a lot of white space, however this could result in the tile taking longer on smaller devices and repeating on larger devices.
  2. Use a standard tile and change the X/Y values and use math to reset once out of view.

Is there any way we can tell the TileSprite to effectively not repeat, but still move the image along the path as usual?

Thanks

Share this post


Link to post
Share on other sites

FYI, I just ended up doing:

app.game.prototype.update = function() {
    sprite.x -= .3;
    if (sprite.x <= -sprite.width) {
        sprite.x = this.world.width;
    }
}

Which as soon as it was out of view, it reset the x position back to the other side and continued moving.

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

  • Recently Browsing   0 members

    No registered users viewing this page.