0

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).

Tiny Wings HD Screenshot

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.

Corey F
  • 621
  • 4
  • 14
  • 1
    I've looked into this extensively and could not find an easy answer. I could not find anyway of implementing 2 cameras (that was the first way I was going to go about it) I have 5 multiplayer games for tvOS now and I wasn't able to get true split screen working due to the limitations of SpriteKit, and was willing to invest the time at the moment to write a engine to do this. One of my games "Super Swine Vs. Swine" on tvOS looks very similar to that screen shot just rotated. I was able to accomplish this without having to use split screen and just moving the 2 background halves separately – Ron Myschuk Jun 16 '16 at 18:05
  • You just put two identical backgrounds in a single scene and have the players stick to their half of the scene while having a sprite "ghost" the movement of the other player on each side? What method did you use to get each half to follow the player like a camera? – Corey F Jun 16 '16 at 18:32

2 Answers2

1

No Cameras involved or necessary

enter image description here

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

Ron Myschuk
  • 6,011
  • 2
  • 20
  • 32
  • Oh ok that makes sense. How did you mirror what was happening with player 1's scene in player 2's scene and vice versa? That's whats a reach for me. Is there a simple function to do it? Like a "func mirrorNodeActionsOfOnEachSide()" ? e.g. If player 1 gets a coin , and it must be removed from player 2's scene. Or making an enemies movement mirror itself on both sides. Like if two players are attacking an enemy together.. How did you make each side show the same thing...? I'd rather add the 2 player mode without redoing the entire 1 player mode code I have... – Corey F Jun 16 '16 at 20:18
  • Ok, so I downloaded tiny wings (haven't played it years) I don't think that you'll have to redo much of your logic providing that it is object oriented code (classes, sub classes, broke down into smaller functions etc.). I made a game a while back in iOS that used multipeerContectivity to play on 2 ipads. It created the game on 2 halves of the screen using the same variables. When one player would get a power up or coin it would send a message to the other player so that score, coins etc. could be updated on their screen (important to note that only one ipad can control functionality). – Ron Myschuk Jun 17 '16 at 02:52
  • the interesting thing about this game is that even though it was played on 2 ipads it mirrored both sides on each ipad. Sooooo.....it really is no different than playing a game on one screen. Yes you have to run the game on both halves but as long as it is object oriented it should be obtainable. When one player gets a coin you can then remove that coin from an array of coins waiting to appear on the other players half so that it doesn't appear any more. as far as if both players appear on the screen at both times. you will need to track progress for each player, if progress overlaps then... – Ron Myschuk Jun 17 '16 at 02:59
  • create the 2nd player object on the other side of the screen as well. It really isn't a big deal to intercept the touches method figure out which side of the screen the touch is on, then figure out does the player have a character on their screen and the other players screen and apply actions to one side or both. This is quite hard to explain in the limited comment boxes. – Ron Myschuk Jun 17 '16 at 03:03
  • But try this... divide a screen into 2 halves (player 1 (blue) and player 2(red)) have a ball on each side that pulses if the player touches their side. pretty simple right? now add a second ball of each color to the opposite side of the screen, so that each side has a red ball and a blue ball, now when you touch one side pulse each of that sides balls. easy peasy...no different than what you are trying to obtain but really simplified. I hope that helps explain it, it really doesn't need to be very complicated, sometimes the simplest solutions are the best – Ron Myschuk Jun 17 '16 at 03:06
0

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:

Rendering a single SKScene using two MTKViews

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).

Brendan Lane
  • 117
  • 2
  • 8