Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat
texture repeat and scroll - Gideros Forum

texture repeat and scroll

I want to make a bitmap scroll indefinitely through the screen. I saw there is a Texture.REPEAT property in the Texture.new method. But I don't know how to use it.
I tried to offset the anchor point of a bitmap, then the anchor position but to no avail.
Also, how do I extend my bitmap if I want to use a smaller texture that should repeat itself?


  • piepie Member
    edited February 2019
    @meobeou I think that Texture.REPEAT is used to fill a Mesh, Shape or a Pixel object (which you can extend at your pleasure) with a repeated texture.
    To achieve the infinite scrolling I would go for 2 objects one aside of the other that scroll from the beginning to the end of the screen, then switch position
  • Use a texture that's size is a power of 2. Set the repeat option. Map it to a pixel type sprite, size it whatever you want. Change the position of the texture area within the pixel (your instinct may have been to change the pixel position and to have multiple pixels - like @pie - this is a different way of looking at things).
    -- the setup
    scroll:setDimensions(100,100) -- you could set this at the beginning, this is just to show you that you can change this dynamically
    -- in the frame event
    x+=1  -- this is just an example
    y+=1  -- ditto!

    Likes: pie

    +1 -1 (+1 / -0 ) Share on Facebook
  • I forgot to say, if you want the whole screen to be covered, just setDimension to the visible screen width and height.

    You can then also...
    stage:setClearColorBuffer(false) -- possibly speed up rendering time
    As you will be covering the entire background, so no need to have it cleared on each frame.
  • SinisterSoftSinisterSoft Maintainer
    edited February 2019
    Also, if you want to make a game that scrolls infinitely then there are at least two nice ways to do it:

    Use tilemaps and use the scroll commands to feed in one of the edges or again use tilemaps and use the commands to say it basically loops back to the beginning when out of space. You will have to use mod (%) on your x,y positions so they loop too.
  • hgy29hgy29 Maintainer

    Use a texture that's size is a power of 2.

    It is no longer strictly necessary in recent Gideros, if your texture isn't power-of-two sized you can ask gideros to leave it as-is by adding extend=false in texture options table.

    +1 -1 (+3 / -0 ) Share on Facebook
  • @hgy29 thatt's very handy to know, I'll try to remember! Pretty much all asset packs you buy on the internet have parallax scrolling backgrounds that are stupid sizes like 1821and so on :D
Sign In or Register to comment.