samedi 2 juillet 2016

How can i calculate the reflection of a coordinate in Swift 2


Alike the common math axis where the origin (0,0) is in the center of the axis, the origin in Swift (Using Sprite Kit) is in bottom-left if i'm not mistaken. So, I need to calculate the complete opposite x,y on a sprite that i touched on, but i can't find a way yet, i'm not very good at math. In a normal axis, it would be as easy as giving the coordinate A (-7,8), the number I would be looking for is (7,-8). But how can I get the same with a non-zero axis? Where there all positive values. To demonstrate a little bit better, I just made this picture: The outer frame boundaries would be my phone screen, that would be my real origin 0,0 right? Now, imagine that I just tapped on the coordinate (13,13) of that box. The height and width of the box is 12px by 12px. The origin of the box at that point is (10,10). The point I would like to get is the (19,19). How can I achieve this? Thanks.

Aucun commentaire:

Enregistrer un commentaire