Debug sprites by blink0k14th Nov 2020 1:20
|
---|
Summary Handy function to help debug sprites. Just add a call to DumpDebug() where you want to examine where sprites are Description This will draw a box around all sprites and show the name of the image Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com // File: debug.agc // Created: 20-10-03 type tDebug sprite as integer image as string text as integer x as float y as float z as float endtype function DumpDebug() i as integer n as string t as integer c as integer id as integer d as tDebug sprites as tDebug[] for i=1 to 1000000 d.sprite = i if GetSpriteExists(d.sprite) <> 1 continue endif d.x = GetSpriteX(d.sprite) d.y = GetSpriteY(d.sprite) if GetImageExists(GetSpriteImageID(d.sprite)) n = GetImageFilename(GetSpriteImageID(i)) c = CountStringTokens(n, "/") if c > 1 n = GetStringToken(n,"/",c) endif d.image = n else d.image = "No image" endif d.text = CreateText(d.image) SetTextSize(d.text, 12) SetTextPosition(d.text, d.x, d.y) SetTextDepth(d.text,2) sprites.insert(d) next repeat for i=0 to sprites.length d = sprites[i] DrawBox(d.x, d.y, d.x + GetSpriteWidth(d.sprite), d.y + GetSpriteHeight(d.sprite), 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,0) DrawText(d.text) next sync() until GetRawKeyPressed(27) for i=0 to sprites.length d = sprites[i] DeleteText(d.text) next endfunction |