I read this article on creating a old school racing game like Outrun or Lotus.
The code there is based on a HTML canvas element and JavaScript. To achieve the 3D effect the author segments the race track and draws simple 2D polygons for each segment which are projected into "3D space". The code to draw these polygons is this:
polygon: function(ctx, x1, y1, x2, y2, x3, y3, x4, y4, color) {
ctx.fillStyle = color;
ctx.beginPath();
ctx.moveTo(x1, y1);
ctx.lineTo(x2, y2);
ctx.lineTo(x3, y3);
ctx.lineTo(x4, y4);
ctx.closePath();
ctx.fill();
}
These polygons are drawn in every frame. I was wondering how the same concept might translate to SpriteKit. Since pretty much the only option to draw custom polygonal stuff in SpriteKit is a SKShapeNode I thought of using these. However, I feel that there might be some serious problems with that solution:
- I heard that SKShapeNodes have a really bad overall performance, memory leaking issues and whatnot
- According to the above concept one would have to create hundreds or thousands of SKShapeNodes in each frame to layout and render the track on screen which would probably kill the frame rate completely
I started wondering if it is actually possible at all to create games like that in SpriteKit. Do you have any advice on how to go about it? Or do I need to make the shift to SceneKit and use real polygons to achieve the desired effect? Any help or suggestions are highly appreciated. Thanks in advance.
If you are questioning what a 3d game is easier to make is, then you will get the easy answer: Of course is an 3d engine easier to use then faking 3d in a 2d engine.
And also if you are in trouble in your code and you are trying to fake 3d with SpriteKit you will get less help than using SceneKit.
I hope this helps