How do I create a queue of customers

Get help using Construct 2

Post » Thu Sep 01, 2016 2:35 pm

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):
Image

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!
B
7
S
1
Posts: 12
Reputation: 645

Post » Thu Sep 01, 2016 6:19 pm

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.
Mistakes were made.
B
54
S
28
G
115
Posts: 1,705
Reputation: 65,083

Post » Thu Sep 01, 2016 7:04 pm

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?
B
7
S
1
Posts: 12
Reputation: 645

Post » Thu Sep 01, 2016 8:37 pm

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.
Mistakes were made.
B
54
S
28
G
115
Posts: 1,705
Reputation: 65,083

Post » Fri Sep 02, 2016 1:36 am

Updated capx, with comments, same link.

https://www.dropbox.com/s/mz3e0ys26mfo5 ... .capx?dl=0
Mistakes were made.
B
54
S
28
G
115
Posts: 1,705
Reputation: 65,083

Post » Fri Sep 02, 2016 2:28 pm

Awesome, thanks a lot!
B
7
S
1
Posts: 12
Reputation: 645


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 6 guests