Lazarus

Programming => Graphics and Multimedia => Graphics => Topic started by: JasonLugg on March 14, 2018, 12:09:32 pm

Title: BGRA Sprites
Post by: JasonLugg on March 14, 2018, 12:09:32 pm
Hi all and thx in advance

I have been using BGRABitmap and have noticed it has a Sprite Type and Sprite Engine, but cannot see any demos of how to implement it?

1) I want to draw on a TBGRABitmap and then use this image as a sprite.
2) I want to use sprites as I wish to implement animation and also scale them easily ad hoc.

I am able to animate using a IBGLTexture and achieve most of the above but thought it would have better batch rendering using the sprites/sprite engine?

Any input appreciated.
Title: Re: BGRA Sprites
Post by: circular on April 04, 2018, 11:04:07 am
Here is an example:
https://github.com/bgrabitmap/bgrabitmap/tree/master/test/test4lcl_opengl/tux_game

Basically you can create a sprite by instantiating TBGLSprite class during the LoadTexture event. You can derive the TBGLSprite to define a custom behavior for the sprite.

In the TBGLContext, you can access all the sprites using the Sprites property. By calling Sprites.OnTimer, it will call that event for all sprites, so that they move according to their behavior. Calling Sprites.OnDraw will draw all the sprites.

TinyPortal © 2005-2018