Today, i’m gonna show you how to make a writing game. the logic is pretty similiar to connecting nodes game, actually. We won’t use canvas plugin on this case, because writing game is different with drawing game or coloring game.
Getting Started
1. First, you need a large sprite which contains all of the words you want to write. I’ll use an arabic word(s) --> i don’t know what it means, actually --. This will become the blue print, so our player will know what to write.
2. Add three sprite objects.
Node with 4 instance variables :
- isConnected (boolean) = false
- isIgnored (boolean) = false
- id (number)
- toID (number)
Line also with 4 instance variables :
- isDone (boolean) = false
-isNew (boolean) = true
- destinationID (number)
- fromStep (number)
StartingPoint with 1 instance variable :
-id (number)
Node will be used to connect the lines, just like connecting nodes game.
StartingPoint will be used to tell our player which node he/she should select at the first time.
3. Add four global variables :
LAST_ID (number) initial value 0
CURRENT_STEP (number) initial value 1
toID (number) initial value 2
TOTAL_STEPS (number) initial value 3
4. Place the nodes all over our blueprint. Especially on curvy places.
5. There are three steps to complete this level, so there will be three different node as a starting point for each step. Which are pointed by these arrows.
6. Assign id and toID from the first starting point in step 1. Increment the value for next node. In every last node of each step, set toID to -1.
7. Place a StartingPoint object above every first node for each step, and set it’s id.
WRITE IT DOWN!
8. On start of layout, set invisible every StartingPoint with id != 1, this will help our player to locate which part he/she should write first.
9. Make sure our player select the correct node. We’ll use global variable toID to check it. If correct, spawn a line. Set isIgnored to true, to make sure this node won’t be connected to itself. Also set this line’s correct destination to Node.toID, and isNew to true.
10. If a new line is near a node, check if that node is equal to it’s destination. If Yes, connect them. Set fromStep to CURRENT_STEP.
11. Add a sub event into step 9. Check if the current step if completed. If no, increment toID, and spawn another line to connect to the next node.
12. Else, proceed to the next step. Change blueprint anmiation to CURRENT_STEP-1. Record the last correct node to LAST_ID.
ERROR HANDLING
13. Add else into step 9. If a line is near a node, but it’s not the correct destination, ignore it.
14. If a step is not complete, reset.
15. DONE! you can play and download the capx
here
That's all. Thanks for reading, and sorry for my bad english.
If you like this tutorial, please like my
fanspage!