Hit Animations in Spritekit - ios

I been playing around with xcode using swift for a while. i recently got into using Spritekit.
I wanted to experiment with animations for when the player shoots a bullet at an enemy and to show that the sprite took damage (or contacted it) it would switch the sprite image for half a second then switch back to the regular image.
I guess an example of this would be in super mario RPG, when mario hits an enemy, their eyes pop out
Is this a good way to approach the hit animation by switching the images back and forth or is there an easier way?

Switching the texture would work, but give a sudden change. Animating the sprite through a short series of textures (e.g eyes beginning to pop, eyes half way popped, eyes popped) would look better and can be implemented easily using SKActions. See Apple's Sprite Programming Guide, Changing a Sprites Texture

Related

Making a Platform game with Corona SDK

I'm trying to develop a platform game similar to Geometry Dash but i'm facing a lot of problems during the making of the algorithm.
I don't barely know how to proceed. Are the levels structured with a long image ( that is the ground) with obstacles added, or there are many obstacles generated progressively during the game?
I'd like to know where to start from, what to draw and how to place it in my game, how to build the collision detection.
The game will be an auto-scrolling platformer, so, will the character's asset be moving right or will all the level except for the character be moving left?
I'm a beginner, so i would like to receive detailed answers and not too difficult to understand. Thank you.
if you have any advice I would gladly listen to it.
I've done all corona tutorials but they doesn't explain how to do a platformer. - Luca Pasini
Looks like you still don't feel how game work from inside. Tutorials probably will not help you much. I think you need to start something very simple by your own - not by tutorials.
For example:
Show red rectangle
Show blue recatngle
Tap on the screen and red rectangle must change his position (not by transitions - just by core x,y change)
If they are collide - show text: "You win". Collision check just by raw calculations.
Then go with updates, that will make it looks more like a game.

How to spawn power ups and detect when they are picked up without enemies being to interact with them

I am currently making a game with sprite and the spritekit library, and I am trying to add power ups. I have tried to use physics bodies to detect when the player touches the power up, however that has not worked for me as the enemies are also able to interact with it. This is a problem, as I only want the player to be able to pick up the power up and have enemies walk straight over the power ups.(The game is top down) I was wondering how I could achieve this. Thank you.
There are a lot of different ways to achieve this.
You could add in some code to the power-up sprite that checks that the colliding sprite is the player.
You could also add in some code to the enemy sprite so that when it collides with the power-up sprite nothing is done.
I'd recommend looking up some tutorials on game development with Swift.
Good luck!

SpriteKit: Should I pan the camera or move the background?

When building a game with SpriteKit, with a platformer game (like Doodle Jump for example), is it preferable to move the camera up, or the background nodes down ?
What is the standard practice in other frameworks ?
MOVE THE CAMERA!!!
One of the weirdest things about 2D game engines is that it often takes them a series of versions to get a camera.
They should be born with them.
SpriteKit was no different, it took forever to get a camera.
Now that it has one, never ever think of not using it.
Will make your life a million times simpler.
I can think of no exceptions, but look forward to being proven wrong.
move background was HOTFIX until proper cam support added.
use the cam. its easy and fun. no reason to not imo.

Split Screen 2 Player Local Multiplayer with SpriteKit

I want to make a 2 player mode, split screen style, like Tiny Wings HD did where each side of an iPad gets a flipped orientation screen of the current Level.
I wanted to also implement it on tvOS (without the flipped orientation) as I feel TV begs for this sort of gameplay as it's pretty classic to have this style of gameplay on TV (e.g. Mario Kart 64 or Goldeneye).
Over on the Apple Developer forum, someone suggested that it could be done as follows, but, there we're no other responses.
"You can have two views attached to the main window (add a subview in your viewcontroller). To both views you can present a copy of the scene. Then you can exchange game data between scenes via singletons."
I was looking for a more in-depth explanation as I don't exactly understand what the answer is saying.
I'd just like to be able to have two cameras both rendering the same scene but one focusing on player 1 and the other player 2.
Obviously this isn't a simple answer, so I don't expect a full in-depth tutorial.
Unfortunately I could find no info on this.
Has anyone tried this?
A sample project would be ideal or some documentation/links that might help.
I'm sure a demonstration of this would be valuable to quite a lot of people.
No Cameras involved or necessary
The players just look like they're moving along the x axis because the backgrounds are scrolling by. You can allow the players to move up & down on the y axis whether jumping, ducking, rolling or following a path like in Tiny Wings, but the player never leaves their x position. You can even have each half of the screen background scrolling at different speeds to represent that one player is moving faster than the other.
In your update method in you scene file you can scroll your backgrounds, and in your touches methods you can jump, duck etc the players
Instead of using an SKView to present an SKScene, you can use SKRenderer and MTKView. SKRenderer renders a scene into a Metal pipeline, which in turn can be presented by an MTView.
Crucially, you can decide if SKRenderer updates the scene, allowing you to render the same scene frame multiple times (possibly using different cameras).
So a pipeline might look like this:
Apple actually talk about this option in Choosing a SpriteKit Scene Renderer. There's also a section about using SKRenderer in Going Beyond 2D with SpriteKit from WWDC17 which is quite helpful. This answer also shows how to use SKRenderer (albeit in Objective-C).

iOS SpriteKit split screen for lazy eye exercise

A Little Background
My son Seth has a Lazy Eye and there is evidence that his condition can be improved by playing video games.
Tetris Video Game Helps Treat Lazy Eye
Basically he has poor focus in one eye and perfect focus in the other eye. Over time his brain has started the process of shutting off and ignoring the bad eye. He wears a contact now to correct the focus issue but, his brain is still in the habit of ignoring that eye.
So not just any game will work. He needs something that forces his eyes to collaborate to bring together and track images.
I can use Durovis Dive or Google Cardboard to separate the images he will be processing.
He is a fan of Flappy Bird so a clone of this would be a good start.
My thought is to have the bird visible only to his left eye and the pipes only visible to his right eye. The background is visible to both eyes to give his brain a reference to bring the images together.
So Here is the actual question
I have ran into an issue trying to get a scrolling background and scrolling pipes working in two screens that clip at the right point.
How can I create a screen like below that
The background scrolls in sync in both windows?
The pipes clip at the center?
Thanks!
A crop node (or two) might do the trick so that it masks out the other half of the screen.

Resources