Рет қаралды 7,666
Hello Everyone, in this video we will build a mini game with collisions in SwiftUI. The game will be a baby sorting toy dragging one shape to the right color.
How to get the position of a View in SwiftUI? How to build a game lifecycle?. We're going to solve these and more questions. This going to be fun! 😄
Content:
0:00 - Intro
0:31 - Before Starting
1:22 - Project Setup
1:35 - The Model
2:32 - DraggableToy View
6:53 - The main problem
8:35 - ToyContainer View
10:19 - Storing view's frame
11:32 - Adding the real containers
12:35 - Fix DraggableToy's position
15:08 - Detecting Collisions
16:54 - Feedback in the UI
22:28 - Game Lifecycle
27:28 - A Guest testing the game 😄!
28:31 - Do you want to learn more?
------
The full code is here:
github.com/pitt500/BabySortin...
------
Resources:
* DragGesture: developer.apple.com/documenta...
* GestureState: developer.apple.com/documenta...
* Transaction: developer.apple.com/documenta...
* Gesture Interactivity: developer.apple.com/documenta...
------
Other videos in the channel:
* Drag Gestures: • Drag Gestures in SwiftUI
* Protocols with associated types: • Generics in Swift: Pro...
* ViewBuilder: • Tip: @ViewBuilder in f...
* LazyVGrid: • How to replicate Apple...
* GeometryReader: • Building Apple Watch L...
-----
Don't forget to subscribe to the channel, like it, and follow me on social media!
Twitter:
/ swiftandtips
/ pitt500
Finally, ask me for a video you would like to see next 😄!
Credits:
- Music by Wataboi from pixabay.com/
- Thumbnail taken by Kelly Sikkema from unsplash.com/
- Video edited with Final Cut Pro