Android Question Gameview - Sprite array

OdyMiles

Member
Licensed User
Hi,

after reading, testing and frustrating give-up-thoughts I hope somebody can help me...


I have an array of 10 sprites.

Dim GV As GameView
Dim BD(11) As BitmapData ' I dont care here about #0

GV.initialize("GV")
Activity.AddView(GV,0,0,100%x,100%y)


My goal:

Depending on a variable e.g. sight(x) I want to show a sprite or not.
I am calculating all (INT) coordinates by myself, so I definetly do not want to use dip.
I have a tick already running and working

My problem:

I have no clue (and no documentation) how to display the moving sprites within the array
When to initialize?
How do I handle the DestRect?
When to invalidate the GV?

Idea:

For count = 1 To 10
BD(count).Bitmap = LoadBitmap(File.DirAssets,"pic50x50.gif")
BD(count).DestRect.Initialize(20,20,50,50) ' later e.g. ... Left(count),Top(count,Right(count),B(count)
GV.BitmapsData.Add(BD(count))
Next

GV.invalidate


Within my code I am going to change the coordinates and going to display the sprites again


btw.
To show one bitmap as sprite and the unwanted dip is not a problem and working...
I cannot show any more code since its really to embarrasing ;-)


Thanks...
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Please use [code]code here...[/code] tags when posting code.

I am calculating all (INT) coordinates by myself, so I definetly do not want to use dip.
Sounds strange.

You need to add the BitmapData objects (sprites) to GV.BitmapData list.
GameView goes over the list after each call to GV.Invalidate and draws the sprites based. BitmapData.DestRect sets the drawing area.

There are two ways to remove sprites:
1. Set the Delete flag to True.
2. Remove the object from GV.BitmapData.
 
Upvote 0

OdyMiles

Member
Licensed User
Hi Erel,

thanks for your fast answer.

You need to add the BitmapData objects (sprites) to GV.BitmapData list.

hmmh, that's already in my code but it still does no work. Something is missing :(
B4X:
GV.BitmapsData.Add(BD(count))

BitmapData.DestRect sets the drawing area.

B4X:
Dim GV As GameView
GV.initialize("GV")
Activity.AddView(GV,0,0,100%x,100%y)

For count = 1 To 10
BD(count).Bitmap = LoadBitmap(File.DirAssets,"pic50x50.gif")
BD(count).DestRect.Initialize(20,20,50,50) ' later e.g. ... Left(count),Top(count,Right(count),B(count)
GV.BitmapsData.Add(BD(count))
Next

GV.invalidate

Does DestRect refer to to one sprite only? How do I achieve to display the entire sprite?
By
B4X:
BD(count).DestRect.Initialize(0,0,50,50)
?

Thanks.
Chris
 
Upvote 0
Top