I tried turning off the sprite's physics but still no luck.
I tried to use debug, and found out that the problem is not in the deletion of sprite but in the creation of new sprite with sprite shape polygon. The problem is not happening when I only use the default square shape for sprite physics. Any idea?
With regards to my problem in text not showing/displaying. It seems the texts are always rendered below the sprites (in my case a background image sprite) despite setting the texts' depth to 0 and sprites' depth to 2 and above.
I tried to create a new simple project with my AppGameKit in mac, and the text problem really happens even on a newly created project. Is this a bug in AGK's Mac version?
Here's my code:
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "MacTrial" )
SetWindowSize( 720, 1280, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 720, 1280 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
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
SetPhysicsDebugOn()
global text as integer
global spr as integer
global isHide as integer = 0
global titleFont as integer
global gameBackground as integer
titleFont = LoadFont("IndieFlower.ttf")
gameBackground = CreateSprite(LoadImage("background.png"))
SetSpriteSize(gameBackground, 720, 1280)
SetSpritePosition(gameBackground, 0, 0)
SetSpriteDepth(gameBackground, 2)
do
if not GetTextExists(text)
text = CreateText("This is a test text")
SetTextPosition(text, 200, 200)
SetTextAlignment(text, 0)
SetTextSize(text, 40)
SetTextColor(text, 255, 255, 255, 255)
SetTextFont(text, titleFont)
SetTextDepth(text, 0)
endif
if not GetSpriteExists(spr) and isHide = 0
spr = CreateSprite(LoadImage("thorn_left.png"))
SetSpritePosition(spr, 36, 72)
SetSpriteSize(spr, 72, 72)
SetSpritePhysicsOn(spr, 1)
SetSpriteShapePolygon(spr, 3, 0, -36, -36, 0)
SetSpriteShapePolygon(spr, 3, 1, 36, 0, 0)
SetSpriteShapePolygon(spr, 3, 2, -36, 36, 0)
endif
if GetPointerPressed()
if isHide = 1
isHide = 0
else
isHide = 1
DeleteSprite(spr)
endif
endif
Print( ScreenFPS() )
Sync()
loop