How to draw a line in the simplest way in swift

前端 未结 10 1993
醉梦人生
醉梦人生 2020-12-01 10:18

I am fairly new to swift and Xcode and I am trying to make a tic tac toe game. I have everything figured out except how to draw a line through the three x\'s or o\'s. I have

10条回答
  •  温柔的废话
    2020-12-01 10:57

    Are you using SpriteKit? If not, you really should do for any kind of iOS games as it makes manipulating and adding sprites (images) and other game-style objects very easy.

    Although not at all the best way in terms of coding best-practices, a very simple way to accomplish this would be to create a new view when someone wins, check which direction (out of the possible 8) the row is and then set the image of this view accordingly. The images would be semi-transparent (e.g. PNGs) squares each containing a different possible line.

    If you want to do it the proper way research how to draw paths in SpriteKit between coordinates.

    Hope this is of some help! Steve

提交回复
热议问题