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 Prag Prog topics Top

jimschubert
In Chapter 3, the source for index introduces Config on page 31, followed by more code including tests; Config isn’t introduced until pag...
New
iPaul
page 37 ANTLRInputStream input = new ANTLRInputStream(is); as of ANTLR 4 .8 should be: CharStream stream = CharStreams.fromStream(i...
New
belgoros
Following the steps described in Chapter 6 of the book, I’m stuck with running the migration as described on page 84: bundle exec sequel...
New
brianokken
Many tasks_proj/tests directories exist in chapters 2, 3, 5 that have tests that use the custom markers smoke and get, which are not decl...
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
fynn
This is as much a suggestion as a question, as a note for others. Locally the SGP30 wasn’t available, so I ordered a SGP40. On page 53, ...
New
taguniversalmachine
It seems the second code snippet is missing the code to set the current_user: current_user: Accounts.get_user_by_session_token(session["...
New
rainforest
Hi, I’ve got a question about the implementation of PubSub when using a Phoenix.Socket.Transport behaviour rather than channels. Before ...
New
Henrai
Hi, I’m working on the Chapter 8 of the book. After I add add the point_offset, I’m still able to see acne: In the image above, I re...
New
New

Other popular topics Top

AstonJ
If it’s a mechanical keyboard, which switches do you have? Would you recommend it? Why? What will your next keyboard be? Pics always w...
New
DevotionGeo
I know that -t flag is used along with -i flag for getting an interactive shell. But I cannot digest what the man page for docker run com...
New
PragmaticBookshelf
“Finding the Boundaries” Hero’s Journey with Noel Rappin @noelrappin Even when you’re ultimately right about what the future ho...
New
AstonJ
Seems like a lot of people caught it - just wondered whether any of you did? As far as I know I didn’t, but it wouldn’t surprise me if I...
New
PragmaticBookshelf
A Hero’s Journey with Chris Pine @chrispine Chris Pine, author of Learn to Program, Third Edition, discusses his journey to beco...
New
Margaret
Hello everyone! This thread is to tell you about what authors from The Pragmatic Bookshelf are writing on Medium.
1122 25119 741
New
rustkas
Intensively researching Erlang books and additional resources on it, I have found that the topic of using Regular Expressions is either c...
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
PragmaticBookshelf
Author Spotlight: Sophie DeBenedetto @SophieDeBenedetto The days of the traditional request-response web application are long gone, b...
New
First poster: bot
zig/http.zig at 7cf2cbb33ef34c1d211135f56d30fe23b6cacd42 · ziglang/zig. General-purpose programming language and toolchain for maintaini...
New

Latest in PragProg

View all threads ❯