How do I spawn sprites across another sprite?

0 favourites
  • 7 posts
From the Asset Store
A set of 10 pixel art animated magic effects with icons. 2 Fire, 2 Earth, 2 Wind, 2 Water, Portal, Explosion.
  • Hello there,

    I'm having some trouble with the math behind on how I can spawn sprites that would belong to a parent sprite having the best performances. (not using any behavior).

    For each parent sprite (platform), it should spawn multiple sprites (like the grass), which would follow the width and the of the parent sprite.

    If you see my project, you can see I'm "almost" there, but I'm missing something. The children should spam within the width, and the space between each child should be slightly random.

    Example: https://drive.google.com/file/d/1d2qrvecjUsEq99_xzHUd2f-PGhyfvyEN/view?usp=share_link

    Thanks!

    Tagged:

  • Something like this?

    Example:

    https://www.dropbox.com/s/b2dkvbrnbr5vcb5/Grass%20Spawner1.c3p?dl=0

    having the best performances

    For performance, I will definitely use Tiled_Background, Preferably (2 or 3) variations and choose one random. This is if you need some randomness if not then you can use just one.

    I will try to make an example if I have time.

  • I like the TiledBG method, and it also supports tile randomization now, so you can make your grass look random.

  • I like the TiledBG method, and it also supports tile randomization now, so you can make your grass look random.

    Yep, I like the TiledBG too, also you wouldn't have to worry about any performance issues.

    Indeed the new Randomization + Mesh deformation to skew the Grass to give that grass-moving effect can give great results.

  • Thank you tarek2 for the reply and the project shared.

    This is what I was able to do starting with your generator:

    C3 File: https://drive.google.com/file/d/13v5Ftz4MPLFlTnup2WTs2H0TsgiWawQV/view?usp=sharing

    I feel like there might be a better way to achieve the same result. I'm still playing around with some property (to make the touch effect more realistic), but I guess this will be a kill performance for big levels.

    I was thinking if there might be some effect that can be applied to a single bg where the mesh get distorted on a specific area (when the player touch it).

    Feel free to play around with the file. I have checked around the forum but I'm not able to find a nice grass effect that doesn't kill the performance.

    Thanks

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Jesus (18K Grass objects + Effects + Sine Behaivor) thats a lot))

    I assume that you saw my last example with Tiled Backgrounds but you still want to do it with single objects right?

    If you want to go that road then the first thing you need to do is to keep the Grass object count under control. So we can do this by setting a max Width size for your Spawner so they dont get too long and then we can calculate which one is near the viewports (Left or Right) and then (Spawn or Destroy) the grass.

    If the spawner is too long then you will be spawning more than you need as some of them will spawn offscreen, so by keeping the width sort you can control the spawn by just spawning the necessary that will be on the screen.

    I modified your project:

    There are two options:

    1-(Spawn & Destroy) as you need but I dont know how big your levels are. so you could have issues with "Garbage collection" and run in some stutters but as it is now I haven't noticed any, it runs quite smooth in my laptop.

    https://www.dropbox.com/s/ex6nvd9vp00wwnh/grass_test5.c3p?dl=0

    2-Options2 is by recycling the Grass so you dont have to keep (Destroying & Spawning)

    So here will only spawn a grass object when there isn't any grass available to use, which is good for "Garbage collection".

    Test them both and see which one works better for you.

    https://www.dropbox.com/s/iga84y9wm6zsdez/grass_test6.c3p?dl=0

    On my laptop runs quite well:

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