How do I distribute sprites

0 favourites
  • 6 posts
From the Asset Store
Elliptic
$2.49 USD
Distribute points along elliptic steps for cool explosions and similar effects.
  • Hi

    I'm using the script below to distribute sprites with random frames. The problem is that the frame "0" always repeats a few times. Any help? Thanks

    Function > On "distrSprites"
    

    System > For each local

    System > Pick local where local.occupied = 0

    System > Pick random local instance >> local > Spawn Sprite on layer 0

    >> Sprite > Set animation frame to Array (randomFrame)

    >> Array > Delete index randomFrame from X axis

    >> local > Set occupied to 1[/code:cxsiyz75]

  • It seems to me the picking is at fault. What does your Array look like?

    Is

    >> System > Pick local where local.occupied = 0
    System > Pick random local instance >>[/code:mc8e2nmk]
    
    in the same block or sub block? If it's in a sub event, try putting them together.
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi TwinTails

    Both lines are in the same block/sub-event.

    My array have the same number of sprite frames (16 values = 0 to 15)

  • TwinTails RenatoB : when you use "for each", you already pick each instance one by one, in a row. You don't have to filter more.

    for each (local)

    >> if local.occupied = 0

    >>>> spawn a random sprite

    >>>> set local.occupied = 1

    I know isn't your current problem, but it's important to point out. Then, the logic of the code you provided looks correct otherwise. We need to know more about your code to solve this bug !

    Cheers,

    Nathan

  • Valerien: Thanks for the tip. I think that I need to maintain the "pick random local" line because the sprite is the same and the system choose a different frame using the array.

  • RenatoB : if you have for example 16 instances of the object "local", the for each loop will go through each "local" instance one by one. If you sub-pick an instance, it will keep the one that's already filtered within the loop.

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