skellt

skellt

Apple Game Frameworks and Technologies: SKEffectNode not centered (p 149, B3)

On page 149 (of Beta 3) is this code to add a glow effect to the gloop droplets:

// Add glow effect
let effectNode = SKEffectNode()
effectNode.shouldRasterize = true
addChild(effectNode) 
effectNode.addChild(SKSpriteNode(texture: texture)) 
effectNode.filter = CIFilter(name: "CIGaussianBlur", parameters: ["inputRadius":40.0])

When run this shows a circular glow effect centered at the very top of the droplet where the drop number label is. The glow proceeds down about half of the drop and doesn’t provide any glow around the fattest part of the droplet. Much of glow is radiating out around the number label.

It does not look like the photo on page 149 which shows the glow surrounding the whole drop.

The cause is that the drop is a collectible which has the anchor point set to the middle top. The effect node was not given a position and is therefore centered on the anchor point by default.

To fix it in my code I added:

        effectNode.position = CGPoint(x: 0, y: -(frame.height / 2.0))

to position to effectNode halfway down the droplet in the true center.

I tried running the sample project in the end folder and it has the same bug with the glow not being centered the same way as the photo in the book.

Marked As Solved

Paradox927

Paradox927

Author and Editor at PragProg

Hi, David.

The image on that page was done in post since it was very difficult to capture a screenshot of a falling drop with any level of success.

Regarding the effect node’s position: I prefer to have the glow closer to the top of the drop to help the number stand out, which is why I didn’t adjust its position; but, yes, moving the effect node’s position—as you did—will more closely match the image in the book.

I may end up recreating that image, if possible. And I’ve updated the text to read:

Build and run the project, and you’ll see a faint glow around the top of each drop.

You’ll see this update in the next release. Thanks for letting me know.

EDIT: Good news! I was able to adjust the image. Thank goodness for source files and layers! :smile:

Popular Pragmatic Bookshelf topics Top

telemachus
Python Testing With Pytest - Chapter 2, warnings for “unregistered custom marks” While running the smoke tests in Chapter 2, I get these...
New
Alexandr
Hi everyone! There is an error on the page 71 in the book “Programming machine learning from coding to depp learning” P. Perrotta. You c...
New
raul
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
HarryDeveloper
Hi @venkats, It has been mentioned in the description of ‘Supervisory Job’ title that 2 things as mentioned below result in the same eff...
New
alanq
This isn’t directly about the book contents so maybe not the right forum…but in some of the code apps (e.g. turbo/06) it sends a TURBO_ST...
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
New
Chrichton
Dear Sophie. I tried to do the “Authorization” exercise and have two questions: When trying to plug in an email-service, I found the ...
New
brunogirin
When I run the coverage example to report on missing lines, I get: pytest --cov=cards --report=term-missing ch7 ERROR: usage: pytest [op...
New
redconfetti
Docker-Machine became part of the Docker Toolbox, which was deprecated in 2020, long after Docker Desktop supported Docker Engine nativel...
New

Other popular topics Top

PragmaticBookshelf
A PragProg Hero’s Journey with Brian P. Hogan @bphogan Have you ever worried that your only legacy will be in the form of legacy...
New
brentjanderson
Bought the Moonlander mechanical keyboard. Cherry Brown MX switches. Arms and wrists have been hurting enough that it’s time I did someth...
New
AstonJ
There’s a whole world of custom keycaps out there that I didn’t know existed! Check out all of our Keycaps threads here: https://forum....
New
New
AstonJ
In case anyone else is wondering why Ruby 3 doesn’t show when you do asdf list-all ruby :man_facepalming: do this first: asdf plugin-upd...
New
PragmaticBookshelf
Learn different ways of writing concurrent code in Elixir and increase your application's performance, without sacrificing scalability or...
New
AstonJ
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
First poster: joeb
The File System Access API with Origin Private File System. WebKit supports new API that makes it possible for web apps to create, open,...
New
First poster: bot
The overengineered Solution to my Pigeon Problem. TL;DR: I built a wifi-equipped water gun to shoot the pigeons on my balcony, controlle...
New
DevotionGeo
I have always used antique keyboards like Cherry MX 1800 or Cherry MX 8100 and almost always have modified the switches in some way, like...
New

Latest in Apple Game Frameworks and Technologies

Apple Game Frameworks and Technologies Portal