You can have as many layers as you would want to and there are a few ways to do it...
in your case, you can break up sync() into
update()
Render()
Cleardepthbuffer()
SetObjectvisible(ship,1)
Drawobject(ship)
SetObjectvisible(ship,0)
swap()
this way the ship is drawn on top of all the 2d
There's a few other ways to do this generally
1) As stated above by others, you can render 3d objects to a renderimage and then show the render image on sprites with different depths so that you have the layers you want. You can use DrawObject() to draw only one item to the render image, then use sync() as normal to display the sprites on screen.
2) Alternatively you can break up AGK's rendering into 6 layers. By default, AppGameKit has 3 layers (2DBack, 3D, 2DFront) but if you break up the render command into multiple calls of Render2DFront() and render3d() then you can add layers of 2d or 3d and have any number of layers that you want. You will have to change the view (2d offset or camera) or hide sprites in between render calls to draw what you need to on each layer.
Some very simple example code showing 6 layers (3x 3d and 3x 2d) - Press left mouse to turn the layers semi transparent
// Project: Layering
// Created: 2019-09-22
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "Layering" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetVSync(1)
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
// Create the sprite
spr = CreateSprite(0)
SetSpriteSize(spr,10,10)
// Create a cube
ob = CreateObjectBox(10,10,10)
do
if GetRawMouseLeftState() = 1
Alpha = 128
else
Alpha = 255
endif
// update
Update(getframetime())
// Begin rendering
// Layer 6 - blue square
SetSpriteColor(spr,0,0,40,255)
SetSpritesize(spr,50,50)
SetSpritePositionByOffset(spr,50,50)
Render2DFront()
// layer 5 - red cube
SetObjectColor(ob,200,0,0,alpha)
SetObjectrotation(ob,0,Timer()*30,0)
SetObjectScale(ob,1,1,1)
Render3D()
// layer 4 - Green square
SetSpritesize(spr,35,35)
SetSpriteColor(spr,40,255,40,alpha)
Render2DFront()
// layer 3 - Blue cube
SetObjectColor(ob,20,20,200,alpha)
SetObjectrotation(ob,0,-Timer()*40,0)
SetObjectScale(ob,0.5,0.5,0.5)
ClearDepthBuffer()
Render3D()
// layer 2 - yellow square
SetSpritesize(spr,18,18)
SetSpriteColor(spr,180,180,0,alpha)
Render2DFront()
// layer 1 - Magenta cube
SetObjectColor(ob,0,180,180,alpha)
SetObjectrotation(ob,0,Timer()*20,0)
SetObjectScale(ob,0.25,0.25,0.25)
ClearDepthBuffer()
Render3D()
// display the layers on the screen
Swap()
loop
3) similar to 2 above - you can individually call DrawSprite() and DrawObject() in stead of using Render commands to get the draw order that you want.