How do I fill a layout with sprites?

  • I have a 32x32 sprite and I want to fill all the layout with that sprite but using events. All sprites aligned to a 32x32 grid.

  • + On Start Layout

    + For "loopx" from 0 to layoutwidth/32

    + For "loopy" from 0 to layoutheight/32

    • Create sprite at loopindex("loopx")*32,loopindex("loopy")*32

    Assuming your origin is top left of sprite. If you want it center, you'll need to add sprite.width/2 and sprite.height/2 to offset the respective x and y values

  • Highly recommend using Tiled Backgrounds for this instead of a sprite. Depending exactly how many of these sprite's you intend on spawning that is.

    But assuming that you intend on filling your entire layout, then I'm afraid that using sprite's is the wrong way to go about it.

    I have a game of where overtime the actual layout teraforms itself depending on the season in the game. I was spawning 100s of sprite's but after hitting 500 I got worried. 100% CPU usage, stuttering FPS but only 13MB RAM usage ?? ... So I came here and I was told and taught how to achieve the exact same thing but this time using a Tiled Background instead of a sprite so I did just that.

    Last night I had 1000s and thousands of Tiled Backgrounds and my FPS stayed at 60, my CPU 3-5% but my RAM was still 13.

    Use Tiled Background for this.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • agent11 is correct.

    In the event you need non-identical tiling or collisions, you should utilize a tilemap instead.

  • Thanks to both of you!

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