How do I create a queue of customers

0 favourites
  • 6 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • Hello.

    Does anyone here have a good idea of how to create a queue of customers or people in general? As in creating X amount of sprites (the customers) and placing them in a queue with a little room between each one? And then being able to remove each customer from the front of the queue again as they get served.

    A bit like in this screenshot from Sim Tower (on the ground floor):

    At first I had some idea of placing a lot of invisible sprites and use them as "queue places", but that would quickly get messy and inefficient. So if anyone has a good idea, let me know:) Thanks in advance!

  • You could keep track of each sprite in an array, which gives you lots of options for queueing by using the push and delete actions, or you can use a variable to keep track of the queue size and use that as a multiplier for x position when spawning.

    The invisible sprite idea is also acceptable, but is limited to a fixed amount of positions. If you're worried about too many objects being clunky to work with, you can use one stretched out line with multiple image points instead.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi oosyrag, thanks for you response. I'm a bit of a n00b and don't have much experience with arrays, if you have time could you walk me through how to use an array in this manner? I guess the game would have to know how long the queue is and where to spawn each customer, and which sprite represents a customer, right?

  • It may be better to just stick with a simple variable, if you don't need to store much information about each entity in the queue. Here is an example - https://www.dropbox.com/s/mz3e0ys26mfo5 ... .capx?dl=0

    For multiple queues, it will be a smart idea to use an invisible helper sprite to mark the start of each queue. This helper sprite can also be used to help position new customers and keep track of queue size. You will also be able to associate each customer with a particular queue by saving the UID of the helper sprite.

    I'll get back to this and update with a better example when I have time.

  • Updated capx, with comments, same link.

    https://www.dropbox.com/s/mz3e0ys26mfo5 ... .capx?dl=0

  • Awesome, thanks a lot!

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