Find Object of a Type

Blitz3D Forums/Blitz3D Programming/Find Object of a Type

Do a search for Handle and Object on the forums - plenty of code there to demonstrate it uses. Alot of folk store the Handle of the type instance in the Entities Name - not sure if you can do this with sprites.

Anyhoo, you may want to consider using an array of types for this purpose.

Global sprites = 100

Type sprite_type
 field sprite 
 field x, y
end type

dim sprite. sprite_type ( sprites-1 )


Then to construct the type instance use something like this ..

for l = 0 to sprites-1
 sprite ( l ) = new sprite_type
 sprite ( l )\x = whatever
 sprite ( l )\y = whatever
next


Then you can directly access the type instance with this ..

update_sprite ( sprite( current_sprite ) , 5, 6 )

Function update_sprite ( check.sprite_type, x, y )
  check\x = x
  check\y = y
End Function


This should probably work quite well for you although I'd recommend recyling the type instances rather than deleting and creating new ones when required.

Stevie.