I thought a Flashcard app would be a fairly simple way to learn Construct 2, but I'm sort of struggling at the moment. I spend about half my time "coding" and the other half reading forum posts and looking at tutorials, but despite my research some things are just not clicking yet...
1. If I create a function to manipulate an array, what is the execution flow? For example, let's say I have a 10 line program. Line 5 is a function call. The function is manipulating an array using "for each". Does the "for each" loop finish WITHIN the function before returning to the main program? Or does it process the loop once, increment the LoopIndex, return to the main program until it hits the Function again, at which point it process the loop, increments the LoopIndex again, etc.
2. I try to put all my code in Groups. When one Group is finished I deactivate it and activate the next group. But what happens when I sort an array? Can I perform the sort and then immediately de-activate the group? How do I know when an array has finished sorting? Are these events asynchronous like Local Storage?
3. Is there a way to tell how long other array and dictionary manipulation takes? I wound up writing some code like this to ensure stuff has time to finish:
- initialize counter = 0
- if counter = 0 reverse array
- if counter = 15 sort array
- if counter = 30 update array
- if counter = 40 deactivate group
- counter = counter + 1
Is that necessary? Is there a better way to do it?
Here's what I'm trying to do with my Flashcard App. If anyone has suggestions please let me know!
score, french phrase, english phrase, id
I use AJAX to load data.json into my array. Then I use Local Storage to create my Dictionary object. After that I reverse the y axis of my array so the "id" is in the first column. Then I can sort the array by id. This makes it easy to update the array using the values in the dictionary object. (Everyone using the app needs to have their own "score" for each word.)
After every card I basically do the opposite of the above to save back to Local Storage.
It's mostly working but I'm getting weird values in weird places and none of it makes any sense. Perhaps I'm trying to sort an array before it has finished reversing, for example. Not sure.