B4A Library Game Sprite Library

Hi all,
This is my first attempt at creating a library so I hope it works.
It is a heavily modified version of the code Erel kindly posted for his GameView library.

03/02/2014 - v0.1
First Release
04/02/2014 - v0.2
Added FPS code to the GameSpriteView
12/02/2014 - v0.3
Removed the list-based system replacing it with a sub _Draw() call instead. Also added a convenient DrawText() command. Useful for displaying basic text messages (FPS monitoring).
16/04/2014 - v0.4
Changed: AnimDelayRate to AnimDelayTime. Now using milliseconds for timing.
Added: Filter to the Sprite class
Added: DeltaTime to the GameSpriteView class


GameSprite Library v0.4
Gsv_Screenshot_zps1470806a.png
pi_screenshot2_zps8e3b2124.png
jellybean_screenshot_zps8ff4e89b.png



GameSprite a very light-weight (10K) library designed with 2D games creation in mind. As the name suggests the library is geared towards sprite handling with a simple to understand command set.
The library features a powerful one-call animation command to set up automated animation.

Hardware acceleration is supported.

The key features are:
  • GameSpriteView - the main display supporting virtual screen sizing, global rotation, global anchor point , get FPS, get DeltaTime
  • Sprite - A bitmap-based object with positioning, anchor, size, flip, rotate, colour, alpha, animation, region support, basic collision (overlap) checking, and distance checking.

GameSpriteView methods and variables
IsHardwareAccelerated()
VirtualDisplaySize() , VirtualWidth() , VirtualHeight() , VirtualX() , VirtualY()
Anchor() , AnchorX , AnchorY
DrawText()
Rotate
FPS
Sprite methods and variables
Bitmap
Position() , X , Y , CenterX , CenterY
Size() , ScaleSize() , Width , Height
Anchor() , MidAnchor, AnchorX, AnchorY,
Rotate , FlipX, FlipY
AnimDefineCells() , AnimSequence() , AnimCellRange() , AnimCellNumber , AnimDelayTime , AnimNextCell , AnimPreviousCell , AnimPlay
Region() , ResetRegion , CopyRegion()
isOver() , Overlaps() , DistanceTo()
ARGB() , RGB() , Alpha, Filter
Visible , Copy() , Reset​


You can get the library here, which includes some basic examples you get you started.
Included in the zip is an updated Pocket Invaders, which is a fully playable game to show-case the library.

DOWNLOAD LINK

Also now available, a companion tool written in B4J called SpriteMotion for assisting in the process of defining sprites contained within a sprite sheet.
 
Last edited:

Jim Brown

Active Member
Licensed User
Longtime User
Hi Salvador, everything should be there. The Jellybeans demo needs 2 files - bkg3.jpg, jellybean.png
These are in the GameSpriteExamples > Files folder within the zip.
I have uploaded version 4.0a just in case there is an issue with the current zip.
 
Last edited:

GMan

Well-Known Member
Licensed User
Longtime User
This line
B4X:
  gsv.Sprites.Add(bird)
(and according ones that uses .Sprites.
causes an error:
Unknown Member Sprites
The depending both libs are installed....
 

Phayao

Active Member
Licensed User
Longtime User
Hi Jim,
i played around with your library and have to say its really great - thanks a lot for your effort and like to encourage you to continue working on it, pls don't let the awkward discussions let you down. You are doing a great job for the community !
Chris
 

mkvidyashankar

Active Member
Licensed User
Longtime User
B4X:
Sub Button1_Click
    If birdAnimated.X < 50%x Then
            birdAnimated.Position(birdAnimated.X+gsv.Width*0.7,birdAnimated.Y)
            birdAnimated.FlipX=True
    End If       
    gsv.Invalidate
I am new to this animation. Trying to get the attached images to jump from left end of screen to right end vice versa depending on the touch of buttons. But not able to get smooth jump. Please guide me
jump.png
 
Top