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:

Where Next?

Popular Pragmatic Bookshelf topics Top

iPaul
page 37 ANTLRInputStream input = new ANTLRInputStream(is); as of ANTLR 4 .8 should be: CharStream stream = CharStreams.fromStream(i...
New
johnp
Hi Brian, Looks like the api for tinydb has changed a little. Noticed while working on chapter 7 that the .purge() call to the db throws...
New
herminiotorres
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
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
gilesdotcodes
In case this helps anyone, I’ve had issues setting up the rails source code. Here were the solutions: In Gemfile, change gem 'rails' t...
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
jonmac
The allprojects block listed on page 245 produces the following error when syncing gradle: “org.gradle.api.GradleScriptException: A prob...
New
Keton
When running the program in chapter 8, “Implementing Combat”, the printout Health before attack was never printed so I assumed something ...
New
dtonhofer
@parrt In the context of Chapter 4.3, the grammar Java.g4, meant to parse Java 6 compilation units, no longer passes ANTLR (currently 4....
New
davetron5000
Hello faithful readers! If you have tried to follow along in the book, you are asked to start up the dev environment via dx/build and ar...
New

Other popular topics Top

ohm
Which, if any, games do you play? On what platform? I just bought (and completed) Minecraft Dungeons for my Nintendo Switch. Other than ...
New
PragmaticBookshelf
Design and develop sophisticated 2D games that are as much fun to make as they are to play. From particle effects and pathfinding to soci...
New
AstonJ
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
AstonJ
I have seen the keycaps I want - they are due for a group-buy this week but won’t be delivered until October next year!!! :rofl: The Ser...
New
DevotionGeo
The V Programming Language Simple language for building maintainable programs V is already mentioned couple of times in the forum, but I...
New
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
AstonJ
If you want a quick and easy way to block any website on your Mac using Little Snitch simply… File > New Rule: And select Deny, O...
New
PragmaticBookshelf
Author Spotlight: Peter Ullrich @PJUllrich Data is at the core of every business, but it is useless if nobody can access and analyze ...
New
New

Sub Categories: