I feel that the best way to grasp a new programming language is to make simple games.
So for my first game setup, there will only be 4 buttons (Up, Down, Left, and Right). The buttons will change the position of a single image view object. So for example, if I wanted to press Up then the object will move up by having its X Y coordinates changed. This is where I’m stuck, how do I do this?
Here’s my psuedocode:
_imgShip.frame.position.x += 1;
That line of code is inside a button press event handler so if I press Right then the value of the current X coordinate will add 1 to itself. How do I do this exactly?
You’re pretty close. You’re probably better off moving the center though.
Update:
I should also note that you could translate the view. This is a bit different but opens the door to rotations and scales too which could be useful for games 🙂
For starting transforms use the
Makevariations. But there are also ones that build on each other so if you wanted to rotate AND translate you could do something like: