Apple Game Frameworks and Technologies: fadeIn to alpha 1.0 when alpha was already 1.0 (p 143)

On page 143 is this code:
// Add the 'chomp' text at the player's position
let chomp = SKLabelNode(fontNamed: "Nosifer")
chomp.name = "chomp"
chomp.fontSize = 22.0
chomp.text = "gloop"
chomp.horizontalAlignmentMode = .center
chomp.verticalAlignmentMode = .bottom
chomp.position = CGPoint(x: player.position.x, y: player.frame.maxY + 25)
chomp.zRotation = CGFloat.random(in: -0.15...0.15)
addChild(chomp)
// Add actions to fade in, rise up, and fade out
let fadeIn = SKAction.fadeAlpha(to: 1.0, duration: 0.05)
let fadeOut = SKAction.fadeAlpha(to: 0.0, duration: 0.45)
let moveUp = SKAction.moveBy(x: 0.0, y: 45, duration: 0.45)
let groupAction = SKAction.group([fadeOut, moveUp])
let removeFromParent = SKAction.removeFromParent()
let chompAction = SKAction.sequence([fadeIn, groupAction, removeFromParent])
chomp.run(chompAction)
The fadeIn
action fades alpha to 1.0 over 0.05 seconds. It is the first action in the sequence. But the label node hasn’t had its alpha tweaked and the default is already 1.0. So the fadeIn
action, as it is currently written, is just adding a small delay but no fade.
Question:
Was it intended for this to actually fade? If so then we should add chomp.alpha = 0
to the upper code block. If not then perhaps the fadeAlpha
action should just be a wait
action?
Admittedly nobody will ever notice the difference either way due to the very short duration of 0.05 seconds. But I feel like the code doesn’t match the intent right now. I’m just not sure what the intent was.
Popular Prag Prog topics

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

The answer to 3rd Problem of Chapter 5 (Making Choices) of “Practical Programming, Third Edition” seems incorrect in the given answer ke...
New

Hi @Margaret ,
On page VII the book tells us the example and snippets will be all using Elixir version 1.11
But on page 3 almost the en...
New

Hi Travis! Thank you for the cool book! :slight_smile:
I made a list of issues and thought I could post them chapter by chapter. I’m rev...
New

I’m under the impression that when the reader gets to page 136 (“View Data with the Database Inspector”), the code SHOULD be able to buil...
New

Hi,
I completed chapter 6 but am getting the following error when running:
thread 'main' panicked at 'Failed to load texture: IoError(O...
New

When running the program in chapter 8, “Implementing Combat”, the printout Health before attack was never printed so I assumed something ...
New

@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

Getting an error when installing the dependencies at the start of this chapter:
could not compile dependency :exla, "mix compile" failed...
New

I just bought this book to learn about Android development, and I’m already running into a major issue in Ch. 1, p. 20: “Update activity...
New
Other popular topics

We have a thread about the keyboards we have, but what about nice keyboards we come across that we want? If you have seen any that look n...
New

Here’s our thread for the Keyboardio Atreus. It is a mechanical keyboard based on and a slight update of the original Atreus (Keyboardio ...
New

Learn different ways of writing concurrent code in Elixir and increase your application's performance, without sacrificing scalability or...
New

A Hero’s Journey with Chris Pine
Chris Pine, author of Learn to Program, Third Edition, discusses his journey to becoming a Pragm...
New

Hi folks,
I don’t know if I saw this here but, here’s a new programming language, called Roc
Reminds me a bit of Elm and thus Haskell. ...
New

If you get Can't find emacs in your PATH when trying to install Doom Emacs on your Mac you… just… need to install Emacs first! :lol:
bre...
New

Author Spotlight: Dmitry Zinoviev (@aqsaqal)
Today we’re putting our spotlight on Dmitry Zinoviev, author of Data Science Essentials ...
New

I am trying to crate a game for the Nintendo switch, I wanted to use Java as I am comfortable with that programming language. Can you use...
New

Author Spotlight: Karl Stolley (@karlstolley)
Logic! Rhetoric! Prag! Wow, what a combination. In this spotlight, we sit down with Kar...
New

Author Spotlight: Tammy Coron (@Paradox927)
Gaming, and writing games in particular, is about passion, vision, experience, and immers...
New
Latest in PragProg
Latest (all)
Categories:
Popular Portals
- /elixir
- /opensuse
- /rust
- /kotlin
- /ruby
- /erlang
- /python
- /clojure
- /react
- /quarkus
- /go
- /vapor
- /v
- /react-native
- /wasm
- /security
- /django
- /nodejs
- /centos
- /haskell
- /rails
- /fable
- /gleam
- /swift
- /js
- /deno
- /assemblyscript
- /tailwind
- /laravel
- /symfony
- /phoenix
- /crystal
- /typescript
- /debian
- /adonisjs
- /julia
- /arch-linux
- /svelte
- /spring
- /flutter
- /c-plus-plus
- /preact
- /actix
- /java
- /angular
- /ocaml
- /zig
- /kubuntu
- /scala
- /zotonic
- /vim
- /rocky
- /lisp
- /html
- /keyboards
- /nim
- /vuejs
- /emacs
- /elm
- /nerves