Omegasprite

Properties


Name
The Name of your Omegasprite-Engine.

Tag
This one is free for your own use and does nothing.




Some methods

OmegaSprite1.Draw;
Draws all the sprites in your Sprite-Engine on the Omegascreen.

OmegaSprite1.Collision;
Checks the collision method for your Sprites and then calls their onCollision Method.

omegasprite1.dead;
Kills all the sprites in the Sprite-Engine that are marked Dead.

OmegaSprite1.Move(const moveCount: single);
Moves all the sprites in the SpriteEngine. You will see later how to override the Move-method.

for i:=0 to omegasprite1.Count-1 do begin
omegasprite1.Items[i].Dead;
end;
You can kill all the Sprites in your Sprite-Engine just like this.


How to create your own sprites

TBullet = class(TSprite)
//add your properties here
Energy: Byte;
procedure Move(movecount: single); override;
procedure oncollision(sprite:tsprite); override;
end;

This creates a new sprite class Bullet. You can add your properties here, like Energy or something.

with TBullet.Create(Form1.OmegaSprite1) do begin
Name := 'Bullet'; // set the sprite's name
x:=400;
y:=300;
Image:=Omegaimagelist1.ImageList.Items[0];
pixelcheck:=true; //pixelcheck or not
DoCollision := True; // if DoCollision is true, the sprite can be collided with
DoCollisionPosition := True // if DoCollisionPosition is true, the Collision method passes you the coordinates of the Collision (relative to the top left corner of the Sprite). If you don't need the Position, turn this off to save time. When using Pixelcheck, the Collision position will always be passed, regardless of DoCollisionPosition.
Red := 255; // rgb value for Red coloring
Green := 255; // rgb value for Green coloring
Blue := 255; // rgb value for Blue coloring
Alpha := 120; // alpha setting, the lower the number the more transparent your sprite is
DoAlphaBlend := True; //Blending
ScaleX := 0; // if you set this to 2, your sprite will be twice as wide as your image
ScaleY := 0; // if you set this to 2, your sprite will be twice as tall as your image
Width := 80; // width of sprite - should be same as your tile's width
Height := 80; // height of sprite - should be same as your tile's height
end;
This creates a Bullet on the Omegascreen, it can be collided with (pixelcheck), is a bit transparent

procedure TBullet.Move(const movecount: single); begin
x:=x-2;
if x<0 then dead;
end;
This overrides the move method, which is called whenever you call TOmegaSprite.Move.
The Bullet will fly 2 pixels to the left each frame.
When it leaves the screen, it is killed.

procedure TGeschoss.oncollision(const sprite: tsprite; const X, Y: integer);
begin
if sprite is TMonster then begin //If the collisioned Sprites is of class TMonster
inc(player.score,100); //do something here
dead:=true; //kill the bullet
TMonster(Sprite).hurt; //hurt the Monster here or whatever
end;
end;
This overrides the onCollision method, which is called when the Sprite collides with another Sprite.
You can kill sprites here, play sounds, whatever.

Back to the Index