Problem with TiledBackground’s “Set image X offset” action every tick

0 favourites
  • 7 posts
From the Asset Store
10 Beautiful Pokemon-like Building Pixel Art Sprite Sets
  • Hello,

    I’m trying to achieve an auto-scrolling background. To do it, I’m using the following action:

    [System] Every tick: [TiledBackground] Set image X offset to TiledBackground.ImageOffsetX - Speed * dt

    It works but, as time goes by since the start of layout, it begins to stutter. It begins to be noticed after about 45 seconds, and after 75 seconds it becomes very apparent.

    Any ideas about why it happens? Maybe it isn’t the correct way to implement an auto-scrolling background. Any suggestions?

    Thank you in advance for your help! :)

    Link to a minimal Construct 3 project presenting the issue: 1drv.ms/u/s!ArZid5DzDvUXk51aS1m9NLwsiFnSRw

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Parallax1Background.ImageOffsetX - Speed * dt

    Is different than:

    Parallax1Background.ImageOffsetX - (Speed * dt)

  • Parallax1Background.ImageOffsetX - Speed * dt

    Is different than:

    Parallax1Background.ImageOffsetX - (Speed * dt)

    Really? I thought that multiplication had precedence over sum, like in all programming languages. Thank you for telling me, I didn't imagine this.

    Anyway, I've just tested the same project on Chrome for Android, and the issue doesn't present. I had this issue on Safari for iPad. Maybe I should file a bug to Construct Team.

  • Multiplication has higher precedence than subtraction, so the two equations newt posted are in fact identical.

    If you use a formula like that though the offset eventually becomes a huge negative number, like -10000. That could cause precision issues on the GPU. The best way is to add wrapping with the % operator so the number always stays within a reasonable range.

  • Multiplication has higher precedence than subtraction, so the two equations newt posted are in fact identical.

    If you use a formula like that though the offset eventually becomes a huge negative number, like -10000. That could cause precision issues on the GPU. The best way is to add wrapping with the % operator so the number always stays within a reasonable range.

    Thanks a million Ashley, wrapping with the % operator did the trick. :)

    The formula became:

    (TiledBackground.ImageOffsetX - Speed * dt) % (TiledBackground.ImageWidth)

  • I don't see as much jank my way, so potato potatoes.

    One question Ashley is there any reason not to include wrapping in the plug itself?

  • One question Ashley is there any reason not to include wrapping in the plug itself?

    Yeah, that's a good point, I'll see if I can add that in.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)