Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AbrahamR, 1 invisible), 858 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Panel and Button #260490
04/11/09 13:21
04/11/09 13:21
Joined: Jan 2009
Posts: 38
Anonymous2009 Offline OP
Newbie
Anonymous2009  Offline OP
Newbie

Joined: Jan 2009
Posts: 38
I'm using Bloodshed Dev-C++ for C++ using A7 engine (version 7.06.1).

Showing panels itself is no problem, but I don't know how to implement buttons into them. When I try to implement button into my panel, both bmap and button give me an error that they are undeclared.

I tried all variations of buttons and different ways of putting them:
button_toggle(_VAR(0), _VAR(0), resume0_bmp, resume0_bmp, resume1_bmp, resume1_bmp, NULL, NULL, NULL);
and
button_toggle = _VAR(0), _VAR(0), resume0_bmp, resume0_bmp, resume1_bmp, resume1_bmp, NULL, NULL, NULL;

This is part of my codes (there are no functions inside my button, it is still in testing phase):

Code:
BMAP* resume0_bmp = bmap_create("button_resumeOut.bmp");
BMAP* resume1_bmp = bmap_create("button_resumeOver.bmp");
PANEL* pause_pan;

void loadHUD()
{
   pause_pan = pan_create("bmap = screen_pause.tga;", _VAR(2));

   pause_pan->pos_x = _VAR(373);
   pause_pan->pos_y = _VAR(197);
   pause_pan->flags |= OVERLAY | TRANSLUCENT;
   button_toggle(_VAR(0), _VAR(0), resume0_bmp, resume0_bmp, resume1_bmp, resume1_bmp, NULL, NULL, NULL);
}

void engine_init()
{
   ev = engine_open(NULL);
   SETV(video_mode, 8);
   SETV(max_particles, 20000);
   SETV(max_entities, 2000);
   SETV(fps_max, 60);
   SETV(ph_fps_max_lock, 60);
   SETV(shadow_stencil, ON);

   ...

   loadHUD();

   ...
}


Creating it using this method doesn't give any error on compiling but crash while running.

Code:
PANEL* pause_pan = pan_create("bmap = screen_pause.tga; pos_x = _VAR(373); pos_y = _VAR(197); button_toggle(_VAR(0), _VAR(0), resume0_bmp, resume0_bmp, resume1_bmp, resume1_bmp, NULL, NULL, NULL); flags |= OVERLAY | TRANSLUCENT | INVISIBLE;", _VAR(3));


Anyone know what is my problem? How can I solve it?

EDIT: typo

Last edited by Anonymous2009; 04/11/09 13:41.
Re: Panel and Button [Re: Anonymous2009] #260494
04/11/09 13:39
04/11/09 13:39
Joined: Aug 2008
Posts: 2,838
take me down to the paradise c...
Cowabanga Offline
Expert
Cowabanga  Offline
Expert

Joined: Aug 2008
Posts: 2,838
take me down to the paradise c...
I have no idea about the problem. But, try to update your Gamestudio. smile

Re: Panel and Button [Re: Cowabanga] #260545
04/11/09 21:30
04/11/09 21:30
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Your BMAPs are declared incorrectly for globals.

You would use this syntax if you were declaring LOCAL bmaps (INSIDE a function),
BMAP* resume0_bmp = bmap_create("button_resumeOut.bmp");
BMAP* resume1_bmp = bmap_create("button_resumeOver.bmp");

But you are defining GLOBAL bmaps (OUTSIDE a function), so you need to use
BMAP* resume0_bmp = "button_resumeOut.bmp";
BMAP* resume1_bmp = "button_resumeOver.bmp";

Its weird I know, but thats how it goes....

[EDIT] Sorry, just remembered you are using C++, not lite-c.
This comment may not be applicable...




Last edited by EvilSOB; 04/11/09 21:33. Reason: Possible oops?

"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Panel and Button [Re: EvilSOB] #260608
04/12/09 12:41
04/12/09 12:41
Joined: Jan 2009
Posts: 38
Anonymous2009 Offline OP
Newbie
Anonymous2009  Offline OP
Newbie

Joined: Jan 2009
Posts: 38
Thanks, EvilSOB, will try that nevertheless.

Re: Panel and Button [Re: Anonymous2009] #260706
04/13/09 04:08
04/13/09 04:08
Joined: Jan 2009
Posts: 38
Anonymous2009 Offline OP
Newbie
Anonymous2009  Offline OP
Newbie

Joined: Jan 2009
Posts: 38
EvilSOB > I can't use your method, it will say it "cannot convert from to BMAP*"

Anyway, my main problem is with the button, any other suggestion?

Re: Panel and Button [Re: Anonymous2009] #260707
04/13/09 04:51
04/13/09 04:51
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
This is largely educated guessing but try this.
WARNING - requires 7.71
Code:
BMAP  *resume0_bmp, *resume1_bmp;
PANEL *pause_pan;

void loadHUD()
{
   resume0_bmp = bmap_create("button_resumeOut.bmp");
   resume1_bmp = bmap_create("button_resumeOver.bmp");
   pause_pan = pan_create("bmap = screen_pause.tga;", _VAR(2));
   pause_pan->pos_x = _VAR(373);
   pause_pan->pos_y = _VAR(197);
   pause_pan->flags |= OVERLAY | TRANSLUCENT;
   pan_setbutton(pause_pan, _VAR(0), _VAR(2), _VAR(0), _VAR(0), resume0_bmp, resume0_bmp, resume1_bmp, resume1_bmp, NULL, NULL, NULL);
}





"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Panel and Button [Re: EvilSOB] #260999
04/15/09 08:26
04/15/09 08:26
Joined: Jan 2009
Posts: 38
Anonymous2009 Offline OP
Newbie
Anonymous2009  Offline OP
Newbie

Joined: Jan 2009
Posts: 38
I didn't try upgrading my version because my friend managed to make it work, anyway, I can make the button show, but it is not responding to any of the mouse over/click...

PANEL* panel2 = pan_create("button_toggle(0, 0, red.bmp, green.bmp, blue.bmp, white.bmp, clickMe, leaveMe, overMe);", _VAR(999));

And the image of the button is always in green.bmp, which is the off state. The clickMe, leaveMe, overMe are just simple functions to do a cout message.

Do you see any mistake in that line?

Re: Panel and Button [Re: Anonymous2009] #261795
04/20/09 09:35
04/20/09 09:35
Joined: Jan 2009
Posts: 9
Russia
O
Olorin Offline
Newbie
Olorin  Offline
Newbie
O

Joined: Jan 2009
Posts: 9
Russia
Hi. I had same problem. Try this code:

char *sStart_pan; // this is a pointer to char array with code of panel
ev = engine_open(NULL);

if (!ev) return 1; // acknex.dll not found

//folder with button images
add_folder("%EXE_DIR%\\DATA\\Btn\\");

...
//Allocation of memory
sStart_pan = new char[strlen("bmap = Start_pan.jpg;\
button (381, 229, btnStart_d.jpg, btnStart_u.jpg, btnStart_u.jpg, meth1, NULL, NULL);\
flags = OVERLAY;")];

//copy code of panel to char array
strcpy(sStart_pan,"bmap = Start_pan.jpg;\
button (381, 229, btnStart_d.jpg, btnStart_u.jpg, btnStart_u.jpg, meth1, NULL, NULL);\
flags = OVERLAY;");

//create a new panel
Start_pan = pan_create(sStart_pan,1);

// make it visible
Start_pan->flags|=VISIBLE;

// wait some frame for visualisation of panel
for (int i=0; i<3; i++) engine_frame();

It's working on my computer.
The buttons is shown and method "meth1" is working.
I'm using MS Visual Studio 2005 and A7 engine (version 7.06.1)

With best regards.

Last edited by Olorin; 04/20/09 09:36.
Re: Panel and Button [Re: Olorin] #261806
04/20/09 10:38
04/20/09 10:38
Joined: Jan 2009
Posts: 9
Russia
O
Olorin Offline
Newbie
Olorin  Offline
Newbie
O

Joined: Jan 2009
Posts: 9
Russia
And If you want to add Event on the button you should use
"pan_setevent" function

In my project (see example in previous post) i use this code:

pan_setevent(Start_pan,_VAR(3),_VAR(1),(EVENT)Change_Mode);
You can read more about this function in acknex help


Moderated by  HeelX, Spirit 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1