mikecargal

mikecargal

Apple Game Frameworks and Technologies: Chapter 5 question

Title: Name of book: Apple Game Frameworks and Technologies (Chapter 5 “die” animation)

Not an errata that I can tell so far…

I’m at the point in Chapter 5 of changing to the “die” animation on gameOver().

For some reason, the display does not change to the “die” png.

I’ve placed print() debugging statements in the player::die() method

    func die() {
        print("Player::die()")
        guard let dieTextures = dieTextures else {
            preconditionFailure("Could not find die textures!")
        }
        print("removeAction(forKey: \"walk\"")
        removeAction(forKey: "walk")
        
        print("dieTextures=>>\(dieTextures)<<")
        print("startAnimation(name:\"die\"")
        
        startAnimation(textures: dieTextures, speed: 0.25,
                       name: "die",
                       count: 0, resize: true, restore: true)
    }

and I get the following in the debug console:

player hit collectible
player hit collectible
collectible hit foreground
Player::die()
removeAction(forKey: "walk"
dieTextures=>>[<SKTexture> 'blob-die_0' (186 x 196)]<<
startAnimation(name:"die"

So, I know:

  • the die() method is being called.
  • the dieTextures has a single entry named “blob-die_0” (dimensions 186x196 on iPhone 8 simulator (and I see the 3x dimensions if I run on another simulator), so it really seems like it’s finding the png assets. (I followed the link in the assets, and it opened a directory that has the “sad blob” images.)

But this is what the screen looks like (you can even see the rectangle missing from removing the physics attributes from the drop

I’ve thought about comparing to the “end” project but there’s a lot of stuff left in the chapter before I get to the “end” state (so not applicable to current state). (I did start from my own previous project state (not the “start” project file. I may re-work my way through chapter 5 to this point on that project . But, I generally find that I learn a lot be trying to debug whatever I did wrong. In this case I’ve read, re-read, re-compared the steps in chapter 5 until I’m cross-eyed. (The changes for the labels, and everything up to this are all “working”)

So, as a question… does anyone have a suggestion as to where I should look. (I’m in that debugging state, where there’s so little involved in the changes, that I can’t see what I may have missed). Hoping someone has been here and can point me in the right direction.

Oh yeah… feel free to tell me “you’re on your own. Your mess, you clean it up” :slight_smile:

Marked As Solved

mikecargal

mikecargal

Mystery solved…

It was “Code Completion” in the SpriteKitHelper::startAnimation(...) { ... SKAction.animate(...) ...} with a withNormalTextures: instead of with:

(How the detective missed that so many times, remains a mystery. He’s on desk duty pending an investigation into his competency.)

Also Liked

mikecargal

mikecargal

I am enjoying the book. I wasn’t really expecting anyone to find my typo for me. (In hindsight, probably biggest “surprise” was that the mistake was something I got wrong so far back and didn’t bit me until this part.

And, based on your endorsement, the detective is back “on the beat”

mikecargal

mikecargal

Here’s a probably hint if anyone is interesting in tossing me a hint.

I went ahead with the code to override the update(_ currentTime: TimeInterval) method, and I do indeed see the level going wild, but I’m not bombarded with gloop drops. (I’m pretty sure that points to what I missed before, but I need to call it a day)

If I find it tomorrow, I’ll update.

Paradox927

Paradox927

Author and Editor at PragProg

Hey, Mike.

Sorry for the delay in getting back to you. Usually, I’m a lot faster at responding to these posts, but this week has proven to be quite the challenge. It seems time was not on my side. :roll_eyes:

On the plus side, it looks like you got everything working—and, for what it’s worth, I think you should keep that detective on the payroll. Everyone deserves a second chance. :blush: :grimacing:

Have a great weekend. Hope you’re enjoying the book.

Popular Pragmatic Bookshelf topics Top

jimmykiang
This test is broken right out of the box… — FAIL: TestAgent (7.82s) agent_test.go:77: Error Trace: agent_test.go:77 agent_test.go:...
New
mikecargal
Title: Hands-On Rust (Chap 8 (Adding a Heads Up Display) It looks like ​.with_simple_console_no_bg​(SCREEN_WIDTH*2, SCREEN_HEIGHT*2...
New
lirux
Hi Jamis, I think there’s an issue with a test on chapter 6. I own the ebook, version P1.0 Feb. 2019. This test doesn’t pass for me: ...
New
joepstender
The generated iex result below should list products instead of product for the metadata. (page 67) iex&gt; product = %Product{} %Pento....
New
jeremyhuiskamp
Title: Web Development with Clojure, Third Edition, vB17.0 (p9) The create table guestbook syntax suggested doesn’t seem to be accepted ...
New
swlaschin
The book has the same “Problem space/Solution space” diagram on page 18 as is on page 17. The correct Problem/Solution space diagrams ar...
New
Charles
In general, the book isn’t yet updated for Phoenix version 1.6. On page 18 of the book, the authors indicate that an auto generated of ro...
New
andreheijstek
After running /bin/setup, the first error was: The foreman' command exists in these Ruby versions: That was easy to fix: gem install fore...
New
Keton
When running the program in chapter 8, “Implementing Combat”, the printout Health before attack was never printed so I assumed something ...
New
mcpierce
@mfazio23 I’ve applied the changes from Chapter 5 of the book and everything builds correctly and runs. But, when I try to start a game,...
New

Other popular topics Top

wolf4earth
@AstonJ prompted me to open this topic after I mentioned in the lockdown thread how I started to do a lot more for my fitness. https://f...
New
AstonJ
poll poll Be sure to check out @Dusty’s article posted here: An Introduction to Alternative Keyboard Layouts It’s one of the best write-...
New
Exadra37
I am asking for any distro that only has the bare-bones to be able to get a shell in the server and then just install the packages as we ...
New
mafinar
This is going to be a long an frequently posted thread. While talking to a friend of mine who has taken data structure and algorithm cou...
New
New
PragmaticBookshelf
Author Spotlight Rebecca Skinner @RebeccaSkinner Welcome to our latest author spotlight, where we sit down with Rebecca Skinner, auth...
New
PragmaticBookshelf
Author Spotlight: VM Brasseur @vmbrasseur We have a treat for you today! We turn the spotlight onto Open Source as we sit down with V...
New
PragmaticBookshelf
Author Spotlight: Karl Stolley @karlstolley Logic! Rhetoric! Prag! Wow, what a combination. In this spotlight, we sit down with Karl ...
New
AstonJ
If you’re getting errors like this: psql: error: connection to server on socket “/tmp/.s.PGSQL.5432” failed: No such file or directory ...
New
AstonJ
This is a very quick guide, you just need to: Download LM Studio: https://lmstudio.ai/ Click on search Type DeepSeek, then select the o...
New