UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Project 11 (Pachinko game) why aren't slotBase images appearing?

Forums > 100 Days of Swift

Hi, I'm stuck with Project 11. I can't get the slotBaseGood and slotBaseBad images to appear. I've checked the spelling of the image names. The images are definitely in the Content folder in XCode. I can click on them in the Content folder and see a green bar for slotBaseGood and a red bar for slotBaseBad.

I think its a problem with the images. If I add the following code to func makeSlot just before the "addChild(slotBase)" statement slotBase = SKSpriteNode(imageNamed: "bouncer") then I get four extra bouncer images where the slots should be. So the code runs and adds bouncer images OK. But when I remove this line, so the code goes back to trying to add slotBaseGood or slotBaseBad images, they don't appear. Any offers on what's going wrong please? Thanks

Ian

3      

UPDATE I've just read further on in the chapter where there is a screenshot of the slots with glows. Comparing the book image to my simulator image (iPad Pro 11 inch selected), the bouncer images look cut-off at the bottom. So the slots are probably there, just off the edge of the screen. I changed the simulated device to iPad Pro 9.7 inch and then everything worked.

But why does the device size matter? In the intro to the chapter, it says: "Tip: the 9.7 inch iPad is 1024 points wide and 768 high but the 10.5-inch and 12.9-inch are both larger. SpriteKit takes care of this, we asked for a 1024 x 768 canvas and it will give us one regardless of what device our game runs on". So if the 11 inch iPad Pro simulator has a larger screen, why are the slot images being pushed off the bottom of the screen and not displaying?

3      

TAKE YOUR SKILLS TO THE NEXT LEVEL If you like Hacking with Swift, you'll love Hacking with Swift+ – it's my premium service where you can learn advanced Swift and SwiftUI, functional programming, algorithms, and more. Plus it comes with stacks of benefits, including monthly live streams, downloadable projects, a 20% discount on all books, and free gifts!

Find out more

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.