Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/28/24 09:55
basik85278
by basik85278. 04/28/24 08:56
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, NeoDumont), 761 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Panel do not center #316055
03/21/10 03:55
03/21/10 03:55
Joined: Oct 2009
Posts: 110
Porto-Portugal
Elektron Offline OP
Member
Elektron  Offline OP
Member

Joined: Oct 2009
Posts: 110
Porto-Portugal
I want a centred panel, idependently of screen ratio.
I tried this:
Code:
var panel_pos_x=screen_size.x/2-50;
	var panel_pos_y=screen_size.y/2-25;
	PANEL* splash_panel = pan_create
	("
	pos_x=panel_pos_x;
	pos_y=panel_pos_y;
	bmap=logo16.bmp;",1);
	set(splash_panel,SHOW);
	wait(-5);
	ptr_remove(* splash_panel);



But, it shows bitmap on left upper corner.

P.S. Please any moderator if it is a engine bug move this thread for proper forum.

Thanks in advance


Carlos Ribeiro aka Elektron
Check my blog: http://indiegamedeveloper71.wordpress.com/
Re: Panel do not center [Re: Elektron] #316066
03/21/10 08:24
03/21/10 08:24
Joined: Mar 2009
Posts: 88
Walori Offline
Junior Member
Walori  Offline
Junior Member

Joined: Mar 2009
Posts: 88
The problem is that you're using global variables, right? Now for some reason (someone with more experience may tell you why) you can't define global variables to use screen_size as a value. So you have two options:

-Use local variables
-Define variable later inside of a function

Then it'll work just fine

Re: Panel do not center [Re: Walori] #316079
03/21/10 10:46
03/21/10 10:46
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
It can't be a global variable, because 'screen_size' is not known at compile time, only at runtime.

Also it seems only constants can be passed to pos_x/pos_y, so that might also be a problem, although i'm not sure about Panels defined at runtime.

Finally 'ptr_remove(* splash_panel);' shouldn't compile. as 'ptr_remove' wants a pointer and '*splash_panel' is a pointer-to-a-pointer.

Re: Panel do not center [Re: DJBMASTER] #316090
03/21/10 12:24
03/21/10 12:24
Joined: Sep 2009
Posts: 496
P
Progger Offline
Senior Member
Progger  Offline
Senior Member
P

Joined: Sep 2009
Posts: 496
try it with brackets
var panel_pos_x=(screen_size.x/2)-50;
var panel_pos_y=(screen_size.y/2)-25;
perhaps it will work
Hope that helps
here is something out of the manual with centered Panel (:

// startup with 300x300 window resolution
function main()
{
screen_size.x = 300; screen_size.y = 300;
...}

// place panel in the center of the screen
function center_panel(PANEL* panel)
{
panel.pos_x = (screen_size.x - bmap_width(panel.bmap))/2;
panel.pos_y = (screen_size.y - bmap_height(panel.bmap))/2;
}

WFG Progger laugh


Last edited by Progger; 03/21/10 12:30.

asking is the best Way to get help laugh laugh laugh

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