• Register
Forum Thread
  Posts  
How (Forums : Coding & Scripting : How) Locked
Thread Options
Nov 11 2016 Anchor

Hello everyone

I'm trying to develop an endless runner game, using Apple SpriteKit. My problem is that I don't really know how to create pseudo-2D perspective landscape moving (Like in subway surfers). So, my main idea is: instead of drawing thousands of pictures where landscape is perspectively moving, just move and resize each house picture. (I attached images for clear understanding)
1) Is it good practice to develop such a game using Apple SpriteKit?

2) Ift's not, what would you suggest to develop such a game?


background1

class GameScene: SKScene, SKPhysicsContactDelegate {
    var background = SKSpriteNode(imageNamed: "background.png")
    
    var house1Left = SKSpriteNode(imageNamed: "House1Left.png")
    
    override func didMove(to view: SKView) {
        self.anchorPoint = CGPoint(x: 0.5, y: 0.5)
        
        addChild(background)
        
        house1Left.position = CGPoint(x: -self.frame.size.width/2, y: 0)
        addChild(house1Left)
        
        let move = SKAction.moveTo(x: 0.0, duration: 2.0)
        let resize = SKAction.scale(by: 0.1, duration: 2.0)
        let group = SKAction.group([move, resize])
        
        let resetPosition = SKAction.move(to: CGPoint(x: -self.frame.size.width/2, y:0), duration: 0.0)
        let resetSize = SKAction.scale(by: 10.0, duration: 0.0)
        let resetGroup = SKAction.group([resetPosition, resetSize])
        
        let sequence = SKAction.sequence([group, resetGroup])
    
        let runAction = SKAction.repeatForever(sequence)
        
        house1Left.run(runAction)
    }
}

Edited by: AeonChameleon

Nightshade
Nightshade Unemployed 3D artist
Nov 16 2016 Anchor

1) No I do not think so. I was introduced to SpriteKit a few days ago and can't say I was very impressed. For starters, setting up a SpriteKit project is much harder than what it should be - in fact I think it's crap compared to a lot of other stuff out there. You do not have -one- single game editor package like you have with most other tools and engines out there. Instead you have to create an XCode project, load in their libs and then for creating scenes and physics and stuff you will have to use DIFFERENT EDITORS. Also the language is their own creation (why would anyone create their own language when you have things like C#, Python, Lua, C++, Java is beyond me!) - a messy abomination that looks like a combination of Objective C with JavaScript and Python. With all of these things said, I do not recommend people to start out using SpriteKit when there are other tools and engines out there.


2) If you want 2D engine with 3D capabilities that is also easy to get started with, try out Defold (our engine).

www.defold.com

Defold is free, very easy to get started with, multi-platform, the Box2D physics engine, has an integrated git-client and builds the project exceptionally fast (in seconds!) for windows, OSX, Android, iOS and Linux.

Start with the side-scroller tutorial project, understand what is going on there and then you can apply these insights into making an endless runner like in your picture above. Contrary to what people believe, Defold is at it's core a 3d engine - even though the focus is on 2D.

You can easily setup a project and change the render script to use a perspective projection instead of ortographic (you change ONE function name). Then for the core game mechanic (world spawning, moving towards the camera along the Z axis) you setup a factory for creating game objects in the distance, and destroy them once they are "behind" the near-clip plane of the camera. For level/stage switching and transitions, simply use different factories. You can make the world geometry as models (3D) or just use sprites (2D) if you want that 2.5D feeling.

Edited by: Nightshade

--

   - My portfolio
“There he goes. One of God's own prototypes. Some kind of high powered mutant never even considered for mass production. Too weird to live, and too rare to die.” Hunter S. Thompson

Reply to thread
click to sign in and post

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.