Lesson 13 - In this lesson, I created the image assets for my app. I had to find playing card images and format them for import into my app build. I found a set of vector images on https://openclipart.org and set to editing them in Photoshop. Because the vector images were all in one file, I had to layer by cut for each image and then export them to separate files. I then had to crop them and save them as .png files.
Here is a link to a video where I show how I created the card face files.
https://viutube.viu.ca/media/MakingCardFaces/0_3bbmucgl
I also learned that there are different file sizes for each of the main iPhone types (older iPhones = regular filename, retina iPhones = filename@2x, iPhone 6~6s Plus = filename@3x). Luckily, I didn't have to format all 3 file sizes. Using an app called Prepo, I was able to add all the original files into the program and export them back to the original folder in all 3 file sizes. Prepo automatically creates a 2x and 1x file size.
Once I had all the files created, I added them to my assets in the XCode project. Because I had named all the files as I wanted them in the project, I was able to drag them all in and XCode automatically placed them where they needed to be.
Lesson 14 - In this lesson, I assigned a background and card back image to my app and created the code that would display and randomize the cards when I press the 'Play' button.
After assigning a background and card back to the app, I first assigned a fixed card to appear when I pressed the play button. After this, I learned how to randomize a number by using arc4random_uniform. This randomized the number according to a range I selected. In this case I have 52 cards so I needed to have it pick from 52 numbers. Because my designated range included '0', I had to add the modifier +1 to eliminate it.
I then had to create a string where I could have a constant 'Card' and a variable 'card number'. To do this I had to write "Card%i" which attached the randomized number to the end of the filename Card. All my image assets were made as Card1, Card2, Card3, etc. so that enabled my app to call any of the cards at random.
My app can now show a set of two random cards each time I press the 'Play' button. Getting excited now!