Arrays VS Dictionary

Discussion and feedback on Construct 2

Post » Fri Mar 14, 2014 10:27 pm

The main thing I want to know the difference between arrays and dictionaries and that's because I have detected a problem in arrays:
First Test: Condition: When Object dragdrop drag start ==> Action: Set Array.at (0,0) to Object.X and Array.at (1,0) to Object.Y
Condition: When Object dragdrop on drop ==> Sub-Condition: (Invert) Object overlapping object2 ==> Action: Set Object position: X= Array.at (0,0) Y= Array.at (1,0). Action: Array: Clear.
Conclusion: When I tested the game, On drag start the Array Save the position, on drop instead of putting the object on it's saved position, it took it to X= 0 and Y=0 . I don't know why.

Second Test: Condition: When Object dragdrop drag start ==> Action: Add key "PX" with value Object.X Action: Add key "PY" with value Object.Y
Condition: When Object dragdrop on drop ==> Sub-Condition: (Invert) Object overlapping object2 ==> Action: Set Object position: X= Dictionary.Get("PX") Y= Dictionary.Get("PY") Action: Dictionary: Clear
Conclusion: The same test, but this time, the dictionary plugin in has saved the right positions and when dropped it returned them on the right position .
the main question: Is the error from me or the C2 and Why that happened?
ImageImageImageImageImage
B
56
S
15
G
5
Posts: 852
Reputation: 11,431

Post » Fri Mar 14, 2014 11:00 pm

Naji wrote:The main thing I want to know the difference between arrays and dictionaries and that's because I have detected a problem in arrays:
First Test: Condition: When Object dragdrop drag start ==> Action: Set Array.at (0,0) to Object.X and Array.at (1,0) to Object.Y
Condition: When Object dragdrop on drop ==> Sub-Condition: (Invert) Object overlapping object2 ==> Action: Set Object position: X= Array.at (0,0) Y= Array.at (1,0). Action: Array: Clear.
Conclusion: When I tested the game, On drag start the Array Save the position, on drop instead of putting the object on it's saved position, it took it to X= 0 and Y=0 . I don't know why.

Second Test: Condition: When Object dragdrop drag start ==> Action: Add key "PX" with value Object.X Action: Add key "PY" with value Object.Y
Condition: When Object dragdrop on drop ==> Sub-Condition: (Invert) Object overlapping object2 ==> Action: Set Object position: X= Dictionary.Get("PX") Y= Dictionary.Get("PY") Action: Dictionary: Clear
Conclusion: The same test, but this time, the dictionary plugin in has saved the right positions and when dropped it returned them on the right position .
the main question: Is the error from me or the C2 and Why that happened?


What was the size of your array? (if one of the dimension is 0, then the array won't work)
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
53
S
22
G
18
Posts: 2,122
Reputation: 17,123

Post » Fri Mar 14, 2014 11:30 pm

Is this true? I can't test this yet, but I recall a beginner's tutorial stating the array starting at 0,0.
B
27
S
9
G
2
Posts: 154
Reputation: 2,833

Post » Sat Mar 15, 2014 12:20 am

Aurora Australis wrote:Is this true? I can't test this yet, but I recall a beginner's tutorial stating the array starting at 0,0.


I am talking about the size of the array, not the coordinate
If the array is 10,1,1, then it'll go from 0 to 9, 0, 0
(and since he doesn't use the z axis, he might have set it's size to 0, which will not work at the end)
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
53
S
22
G
18
Posts: 2,122
Reputation: 17,123

Post » Sat Mar 15, 2014 12:21 am

@Aurora Australis
It starts at 0,0 but the size of the array is 1 width and 1 height. Just like how a 10-width array goes from 0 to 9, a 1-width array only has the 0 position in it
B
84
S
22
G
15
Posts: 1,039
Reputation: 15,249

Post » Sat Mar 15, 2014 1:22 am

My bad, I misread Aphrodite's reply to OP.
B
27
S
9
G
2
Posts: 154
Reputation: 2,833


Return to Construct 2 General

Who is online

Users browsing this forum: tarek2 and 10 guests