WhoCares357
2008-08-27 19:35:02
I'm trying to create a menu from bitmap buttons. Here are the parts of the script that do this:
The script starts with no errors but it does not show the button bitmaps. I double checked the bitmap locations and they are correct.
PS I added the images folder to the attachments. Just place the folder in the same directory as the script.
type
Button = record
x1, y1, x2, y2: Integer; //position
img01, img02: Integer; //images
end;
var
t_buffer: Integer;
ourButton: Array [0..3] of Button;
procedure SetupBackground;
begin
//set up window
DisplayDebugImgWindow(800, 600);
t_buffer := BitmapFromString(800, 600, '');
end;
function IsButtonClicked_2IMG(whichButton: Button; whichBuffer: Integer): Boolean;
var
x, y: Integer;
begin
GetMousePos(x, y);
if (x >= whichButton.x1) and (x <= whichButton.x2) and
(y >= whichButton.y1) and (y <= whichButton.y2) then
begin
result := IsMouseButtonDown(true);
FastDrawSizeTransparent(whichButton.x1, whichButton.y1,
whichButton.x2, whichButton.y2,
whichButton.img02, whichBuffer);
end else
begin
FastDrawSizeTransparent(whichButton.x1, whichButton.y1,
whichButton.x2, whichButton.y2,
whichButton.img01, whichBuffer);
result := false;
end;
end;
procedure DeclareButton(var whichButton: Button; x, y, length, height: Integer;
img01Loc, img02Loc: String);
begin
whichButton.x1 := x;
whichButton.y1 := y;
whichButton.x2 := x + length;
whichButton.y2 := y + height;
whichButton.img01 := LoadBitmap(img01Loc);
whichButton.img02 := LoadBitmap(img02Loc);
SetTransparentColor(whichButton.img01, clblack);
SetTransparentColor(whichButton.img02, clblack);
end;
procedure SetAllButtons;
begin
DeclareButton(ourButton[0], 100, 70, 100, 50, ScriptPath + '\images\playButton01.bmp',
ScriptPath + '\images\playButton02.bmp');
DeclareButton(ourButton[1], 100, 210, 100, 50, ScriptPath + '\images\optionsButton01.bmp',
ScriptPath + '\images\optionsButton02.bmp');
DeclareButton(ourButton[2], 100, 350, 100, 50, ScriptPath + '\images\exitButton01.bmp',
ScriptPath + '\images\exitButton02.bmp');
end;
function CheckButton(buttonN: Integer): Boolean;
begin
result := IsButtonClicked_2IMG(ourButton[buttonN], t_buffer);
end;
begin
SetupBackground;
SetAllButtons;
repeat
FastDrawClear(t_buffer, clblack);
if (CheckButton(0)) then
Exit;
if (CheckButton(2)) then
TerminateScript;
CheckButton(1); //not yet functional
Wait(1);
until(false);
end.The script starts with no errors but it does not show the button bitmaps. I double checked the bitmap locations and they are correct.
PS I added the images folder to the attachments. Just place the folder in the same directory as the script.