Common use of Dictionary, Array

Just started using Construct 2? Post your questions here

Post » Fri Nov 28, 2014 9:46 am

hello, I was wondering if you could give me your experience when you have used Dictionary instead of an Array and vice versa.

I have read the manual of both objects and right now I think:
- a dictionary is like a 2d array, but with less options to manipulate the data
- both objects can store numbers as well as strings.
- I could store an inventory in both a Dictionary and 2d Array (if I'm right) and change the values (at any time).

I am looking forward to your experience when one object was more useful than the other or some advice when not to use Dictionary or Array.
B
28
S
6
G
7
Posts: 681
Reputation: 5,682

Post » Fri Nov 28, 2014 4:53 pm

Array saves as "location" and Dictionary as named keys.

Most of the time I would use Array for inventory and tiled maps. It is easy to compare positions by slot ID and check if they are occupied or not.

Dictionary is also very useful for all kind of things. For example you could use it as container for instance to have some extra variables if you need to make them at runtime.

There is a lot that both can do. Just sometimes one or another could be more suitable for the task.
B
34
S
9
G
3
Posts: 517
Reputation: 5,246


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 0 guests