Building a SpriteKit game with physics, particles, and shaders - Swift on Sundays February 24th 2019

  Переглядів 55,779

Paul Hudson

Paul Hudson

5 років тому

In this episode we build a SpriteKit match three game with physics, particle effects, fragment shading, and more.
You can download the finished project for this and all Swift in Sundays streams: github.com/twostraws/SwiftOnS...

КОМЕНТАРІ: 50
@twostraws
@twostraws 4 роки тому
Watch next: Building a declarative user interface app using JSON and Codable - ukposts.info/have/v-deo/fp2manqjgpyDyZc.html Questions? Comments? Tweet me @twostraws.
@gwolanin
@gwolanin 4 роки тому
This tutorial is amazing. I have been out of the App creation mode for about 7 years and so much has changed. Thank you for providing these tutorials!
@ruptapas
@ruptapas 4 роки тому
Hi Paul, such a wonderful stream, enjoyed every bit of it. The way you explain the SpriteKit feature & the game was really great. Thank you...
@gregcampbell3493
@gregcampbell3493 5 років тому
Paul, thanks for this video. It was incredibly helpful.
@tehLilaQ
@tehLilaQ 3 роки тому
I love this so much, your videos are to the point, educational, and easy to follow. Thanks a lot!
@vels7181
@vels7181 4 роки тому
Thank you for amazing tutorial on Sprite Kit. It's really a good start for me on SpriteKit.
@Searchupunk
@Searchupunk 2 роки тому
thanks for everything you teach! you are one of the best and brightest teachers I have ever had. I bought the book, it's amazing! Thank you very much.
@arukshun2710
@arukshun2710 Рік тому
Still watching. About half way through. This was a great tutorial! Information still relevant today!
@marcoantoniobatista5564
@marcoantoniobatista5564 3 роки тому
Learned lots from this. Thank you!
@williamsquires3070
@williamsquires3070 5 років тому
For determining the ‘end of game condition’, do this. Define a var ballColorCount = [0, 0, 0, ..., 0, 0] where the # of elements in the array = # colors you have. When you initialize the random balls at the beginning, add 1 to the array index for that color ball (a good use of an enumeration with an Int raw value). As you make matches, subtract from the count for a particular color the # of balls in the set of “adjacent” balls, plus 1 for the original ball. Once no element of the array >= 3, the game is over; there’s no way to make a match-3 with any colored ball. The array is a histogram of the ball’s colors at any point in the game. This approach is a lot easier than trying to mathematically determining how many balls there must be to still have a match, taking into account that you might have 15 balls, but they’re all at the bottom of the screen, and no adjacent balls are the same color, even though you might still have - let’s say - 4 green ones, 3 red ones, 2 purple ones, 3 yellow ones and 3 blue ones. But they could make a match if you tilt the device and allow the balls (using the physics engine) to rearrange themselves.
@yarkil
@yarkil 4 роки тому
This is one of the best fast intro & tutorial I ever seen (on any technology tbh). Nice paced, clear and on point! Amazing work!
@williamsquires3070
@williamsquires3070 5 років тому
(@1:30:00) “...Metal is hard.” LOL! Good one! 😆
@zaurmahmudov1438
@zaurmahmudov1438 4 роки тому
Perfect Video
@kjmyatt4069
@kjmyatt4069 3 роки тому
👍 I’ll keep watching I need to learn haha
@HumbleHustle101
@HumbleHustle101 Рік тому
Nice video. Paul can you make a video about creating cloth physics with metal framework?
@clipartinc
@clipartinc 5 років тому
Thanks for your videos!!! Please do more game tutorials in Spritekit or Scenekit :) It would be great to get a game setup tutorial that includes the use of inventory to hold items for use during game play.
@petersuvara
@petersuvara 5 років тому
You can create an inventory by creating a protocol called InventoryItem, then have a character that has an array of those items. This can be then drawn when each inventoryitem has a reference to an image/animation asset. :) There you go...
@clipartinc
@clipartinc 5 років тому
@@petersuvara Thank you! I will give it a try :)
@semilife
@semilife 4 роки тому
Thanks so much Paul for a very entertaining and very informative and useful session.
@dragonangel001
@dragonangel001 2 роки тому
Hi Paul, thanks for the great tutorial, but when I follow your tutorial, I only get a frame width of 1024 using an iPad Pro 12.9. I tried to change the settings at many location but I can never get more then 23 balls to fit horizontally (23*44). In your video, you do not have that issue and we can see that you have 31 horizontal balls which is 1364 which sounds more like it should be at 2x scale right? What am I doing wrong. I'm using Xcode 12.5 with iOS 14.5. Cheers!
@roipropertypathfinderuae
@roipropertypathfinderuae 5 років тому
I've made everything on your lesson but in method update "if let accelerometerData = motionManager?.accelerometerData", accelerometerData is always nil. Therefore it never let me implement the down code "physicsWorld.gravity = CGVector(dx: accelerometerData.acceleration.y * 50.0, dy: accelerometerData.acceleration.x * 50.0)". So, what's the hitch? Help me plz, stunning lesson!!!
@mortisea2408
@mortisea2408 2 роки тому
What resource did you use to learn the basics and fundamentals of SpriteKit
@guptdas1140
@guptdas1140 Місяць тому
Great👍
@light-water
@light-water 9 місяців тому
How were the colors of the balls generated?
@light-water
@light-water 9 місяців тому
nvm, I realized it would be in the assets folder.
@williamchoy885
@williamchoy885 3 роки тому
Thanks Paul. Excellent presentation as usual. Minor Leak: Forgot to remove the omg nodes after they fadeout. let disappear = SKAction.group([ SKAction.scale(to: 2, duration: 0.25), SKAction.fadeOut(withDuration: 0.25), SKAction.removeFromParent() ]) Was able to finish the game with 9 nodes (6 remaining balls + background + score label + one unaccounted). Is there a way to debug SpriteKit to see the remaining nodes?
@williamchoy885
@williamchoy885 3 роки тому
Or you can reuse the same omg SpriteNode by moving the setup to the update function, and adding a reset action to scale it back to 0.001
@williamsquires3070
@williamsquires3070 5 років тому
Given these two implementations of getMatches(), would it be better to make touchesEnded() call another func called ‘removeBallsOfMatchingColor()’ that takes a closure that takes a Ball and returns Void, then move the existing code in touchesEnded() into this new func, and have it pass in a func that takes a Ball and returns Void (which each implementation of getMatches() does). You can now implement both: call the first func, ‘getExactMatches()’, and the second one ‘getMatchesWithLeeway().’ And pass in one or the other to see what the difference in game play or performance is with each implementation. 🤠 Now you can add a new type of Ball; a ‘PebblyBall’ that has a rough, pebbly surface. In addition, the PebblyBalls have a unique property. Whereas a normal (smooth) Ball will match any other normal Ball of matching color when tapped, the PebblyBall will match any normal or pebbly ball of the same color, but only if you tap on it first. Now, you’ll have another method, ‘getMatchesWithPebblyBall()’, and touchedEnded will check if the touched ball is a Ball or PebblyBall, and call the ‘removeBallsOfMatchingColor()’ with this new method, and no changes need be made to ‘removeBallsOfMatchingColor()’ as it’s already flexible enough to use any closure that takes a ‘Ball’ (or subclass thereof), and returns Void. Ta-daa!
@LucasAraujo-il5mm
@LucasAraujo-il5mm 3 роки тому
The zero patience police for harassment made me like your video as soon as I heard it
@ra9r
@ra9r Рік тому
Idea for a video ... Rendering a 3d dice app. Show how to use physics and 3d rendering within a swiftUI interface
@VeryBlueBot
@VeryBlueBot 4 роки тому
thanks this is very useful! Cant really find an answer anywhere in 2019.. are there any performance advantages in using SpirteKit over a modern engine (Unity/Godot)>
@koncr440
@koncr440 4 роки тому
well spritekit is specifically to use in xcode. Spritekit is used if you want to make a game you can publish into the appstore. Unity is used to make general games you can post onto the internet (which im not sure you can put onto the app store). Note that Spritekit is strictly 2d games while Unity can make both 2d and 3d. In summary, spritekit is for games you want to put onto the appstore.
@VeryBlueBot
@VeryBlueBot 4 роки тому
@@koncr440 Question is if you get any advantages using IOS specific tech? performance? ease of integration etc.. of course if Im going with SpriteKit stack for my mobile games ill have to find a tech to build to Android as well (LibGDX etc)
@koncr440
@koncr440 4 роки тому
Blue Bot well I’m not exactly sure, but Swift is a very powerful language, designed to be fast (faster than C++). So using SpriteKit with swift will increase performance
@VeryBlueBot
@VeryBlueBot 4 роки тому
@@koncr440 guess ill have to test them creating a simple game or even a scene and over populating it with objects to see where the diff starts (if any)
@yarkil
@yarkil 4 роки тому
@@koncr440 Dude, your lack of knowledge is profound. C++ is faster than Swift, and if you would know just a little bit about what is going on under the hood it would be obvious for you and you would never make that mistake. Please learn more and stop putting wrong information lol
@what4401
@what4401 2 роки тому
thx
@kbr8ck
@kbr8ck 2 роки тому
Could you share links to your plugs? You mentioned a fun choose your own adventure for $40 but I’m having trouble finding in the video - found at 1:20:00 links to shaders and SpriteKit game
@twostraws
@twostraws 2 роки тому
It's here: www.hackingwithswift.com/store/dive-into-spritekit HOWEVER: In a few hours I'll be launching my annual WWDC sale, so you can save $20 if you wait a little. I'll be announcing the sale on Twitter @twostraws.
@TheRealWinsletFan
@TheRealWinsletFan 5 років тому
Who's METAL book was that you mentioned? ( 1:02: )
@twostraws
@twostraws 5 років тому
Janie Clayton's.
@TheRealWinsletFan
@TheRealWinsletFan 5 років тому
@@twostraws Thx, located and ordered!
@nas-zu8xl
@nas-zu8xl 3 роки тому
hugh grant hudson
@neilsoulman
@neilsoulman 2 роки тому
So, would spritekit be considered a " real game changer"? Lol #nerdjoke
How much Money does my Free Mobile Game Make?
8:26
Sam Hogan
Переглядів 11 млн
Python vs Swift | Prime Reacts
19:44
ThePrimeTime
Переглядів 66 тис.
How Much Money my Mobile Game Made (After 1 month)
5:24
Pixel Tribe Game
Переглядів 816 тис.
Will ChatGPT Destroy iOS Developer Jobs? A Demonstration
24:05
Sean Allen
Переглядів 153 тис.
Building the $1,000,000 Computer
27:39
Linus Tech Tips
Переглядів 5 млн
Best OS for programming? Mac vs Windows vs Linux debate settled
8:40
OpenAI GPT-4o | First Impressions and Some Testing + API
13:12
All About AI
Переглядів 5 тис.
Presenting a SpriteKit GameScene - Mobile Games Development
4:56
Daniel Budd
Переглядів 2,1 тис.
I coded one project EVERY WEEK for a YEAR
13:13
Carter Semrad
Переглядів 423 тис.
Хомяк может разблокировать АЙФОН
0:14
Собиратель новостей
Переглядів 1,6 млн
Samsung UE40D5520RU перезагружается, замена nand памяти
0:46
Слава 100пудово!
Переглядів 3,8 млн
❌УШЛА ЭПОХА!🍏
0:37
Demin's Lounge
Переглядів 306 тис.
Купите ЭТОТ БЮДЖЕТНИК вместо флагманов от Samsung, Xiaomi и Apple!
13:03
Thebox - о технике и гаджетах
Переглядів 22 тис.
СЛОМАЛСЯ ПК ЗА 2000$🤬
0:59
Корнеич
Переглядів 2,2 млн