In this simple example we grab the sprites from the array group defined in the scene manager and add them to a new type. Once added to the new type we delete and dispose of the array group sprites and array. This has the added benefit of using the scene manager to place sprites then filling a type with them to give you more flexibility when managing sprites.
// Project: Zoikoids
// Created: 19-04-07
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle("Zoikoids")
SetWindowSize(1024, 768, 0)
SetWindowAllowResize(1) // allow the user to resize the window
// set display properties
SetVirtualResolution(1024, 768) // doesn't have to match the window
SetOrientationAllowed(1, 1, 1, 1) // allow both portrait and landscape on mobile devices
SetSyncRate(60, 0) // 30fps instead of 60 to save battery
SetScissor(0, 0, 0, 0) // use the maximum available screen space, no black borders
UseNewDefaultFonts(1)
#insert "game.scene"
game_setup()
img_Ligher = LoadImage( "Ligher.png" )
global player as integer
global playerx as float
global playery as float
playerx = GetVirtualWidth() / 2
playery = GetVirtualHeight() - GetImageHeight(img_Ligher) - 64
player = CreateSprite(img_Ligher)
SetSpriteAnimation(player, 32, 32, 4)
SetSpriteScale(player, 2, 2)
playsprite(player)
type Zoik
id as integer
x as float
y as float
endtype
global ZoikList as Zoik[]
for x = game_Zoikoids.length to 0 step -1
local z as zoik
z.id = CreateSprite(GetSpriteImageID(game_Zoikoids[x]))
SetSpriteScale(z.id, 2, 2)
z.x = GetSpriteX(game_Zoikoids[x])
z.y = GetSpriteY(game_Zoikoids[x])
ZoikList.insert(z)
next
for x = game_Zoikoids.length to 0 step -1
DeleteSprite(game_Zoikoids[x])
next
game_Zoikoids.length = -1
for x = ZoikList.length to 0 step -1
SetSpritePosition(Zoiklist[x].id, ZoikList[x].x, ZoikList[x].y)
next
do
setspriteposition(player, playerx, playery)
game_sync()
Print(ScreenFPS())
Sync()
loop
Imaginations' greatest gift is the knowledge you supply it.