I am trying to make a game which has a jumbled up algebra equation. I have assigned an outlet to each component of the equation. For example, if the equation was:
x2 + y = 2(a+b)
Then x2 (which is x squared), +, y, = and 2(a+b) would all be its own outlet. But the equation is going to be jumbled up and I want the user to move the label outlets to the correct order. I have enabled touchesMoved, but my problem lies in checking if the equation is in the correct order. I would wrap the code into an IBAction button action, but how do I analyze the text? Would I check for the offset between each label? Is there an easy way/API to do this? Thanks!
Assuming your labels are called
xLabel,plusLabel,yLabel,equalsLabel, andabLabel, you could do something like this:This is kind of clumsy, but it works. An even better way to do it would be to put this in a function with each parameter being a label to check. For example:
This is assuming the function you write returns a bool.
Hope this helped!