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
1 registered members (AbrahamR), 717 guests, and 4 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
Page 1 of 2 1 2
Fading panel problem. #331094
07/01/10 21:11
07/01/10 21:11
Joined: Jul 2004
Posts: 1,710
MMike Offline OP
Serious User
MMike  Offline OP
Serious User

Joined: Jul 2004
Posts: 1,710
Hello, o already posted this on the bug section, but i would like you guys to check this.

you can download the file here: GO TO BUG SECTION LINK

or you can read the code here.

Code:
#include <acknex.h>
#include <default.c>
#include <litec.h>
BMAP* c_map;


function fade_pan_out(PANEL*p){
set(p,TRANSLUCENT); //Allow alpha
while(p.alpha>0){
p.alpha-=20*time_step;
wait(1);	
}
///After faded, make it invisible
p.alpha=0;set(p,UNTOUCHABLE);reset(p,SHOW);		
}



function load_wait(short a, short b, var time){
PANEL* ar=pan_create("bmap=c_map;",5);
var timex=0;
set(ar,SHOW);
ar.pos_x=a;ar.pos_y=b;
while(timex<time){wait(1); timex++;}

//reset(ar,SHOW); //switch with fade , and it wont happen again
fade_pan_out(ar);  //remove the panel ,     <<<<<<<< this is one thing that causes a "bug" to dissapear "no related" further panels.

ptr_remove(ar); //remove the local created panel pointer
}

PANEL* addd_pan;
function add_contact_start2(){addd_pan=pan_create("bmap=c_map; pos_x=100; pos_y=50;flags=SHOW;",4);}


function main(){
vec_set(screen_color,vector(53,53,53)); 
video_window(NULL,NULL,16,"TEST");
video_set(800,600,0,0);
level_load(NULL);
wait(1);
reset(camera,SHOW);
c_map=bmap_createblack(100,100,32);  //something to just show
wait(1);
bmap_fill(c_map,vector(100,200,100),100);
wait(1);

//real script
load_wait(300,300,100); //waits 200 to fade out, and when over , keep this function bellow.
wait_for(load_wait);
add_contact_start2(); //create a new panel...
}




Like JCl said there is timming problem with the fade out, and then ptr remove (which wont wait for the fade out function)
but that is not reason to fade the 2nd panel anyway

Last edited by MMike; 07/01/10 21:15.
Re: Fading panel problem. [Re: MMike] #331101
07/01/10 21:22
07/01/10 21:22
Joined: May 2007
Posts: 2,043
Germany
Lukas Offline

Programmer
Lukas  Offline

Programmer

Joined: May 2007
Posts: 2,043
Germany
Your fade_pan_out continues to run even after you destroyed the panel. When you create your second panel, it mostly gets the pointer that was formerly used for the first panel.

The solution would be either putting the ptr_remove to the end of fade_pan_out, using wait_for(fade_pan_out) before the ptr_remove or proc_kill(fade_pan_out) after the ptr_remove.

Re: Fading panel problem. [Re: Lukas] #331102
07/01/10 21:24
07/01/10 21:24
Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
Rei_Ayanami Offline
Expert
Rei_Ayanami  Offline
Expert

Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
The pointer will change when the remove function runs...

edit: lukas was faster...

Last edited by Rei_Ayanami; 07/01/10 21:24.
Re: Fading panel problem. [Re: MMike] #331105
07/01/10 21:45
07/01/10 21:45
Joined: Nov 2002
Posts: 913
Berlin, Germany
S
SchokoKeks Offline
User
SchokoKeks  Offline
User
S

Joined: Nov 2002
Posts: 913
Berlin, Germany
damn, you were faster wink

Last edited by SchokoKeks; 07/01/10 21:45.
Re: Fading panel problem. [Re: SchokoKeks] #331111
07/01/10 22:22
07/01/10 22:22
Joined: Jul 2004
Posts: 1,710
MMike Offline OP
Serious User
MMike  Offline OP
Serious User

Joined: Jul 2004
Posts: 1,710
so when i remove the first panel, it will affect the second panel pointer that was created external to all this, and that will "assign a function" to that second panel that is fade out.
never though that would happen,

i know that code is dirty ptr removing while fading.. though there is no error output. and the ptr removed the first panel. "add_contact_start2()" is an isolated function.

but dont understand how it affects the second creation, that has nothing to do with the ptr remove.



Last edited by MMike; 07/01/10 22:25.
Re: Fading panel problem. [Re: Rei_Ayanami] #331112
07/01/10 22:25
07/01/10 22:25
Joined: Jul 2004
Posts: 1,710
MMike Offline OP
Serious User
MMike  Offline OP
Serious User

Joined: Jul 2004
Posts: 1,710
Originally Posted By: Rei_Ayanami
The pointer will change when the remove function runs...

edit: lukas was faster...

so the pointer of panel 1 will be assigned to panel 2 , is that what you saying.?

Re: Fading panel problem. [Re: MMike] #331113
07/01/10 22:32
07/01/10 22:32
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
function load_wait(short a, short b, var time){
PANEL* ar=pan_create("bmap=c_map;",5);
var timex=0;
set(ar,SHOW);
ar.pos_x=a;ar.pos_y=b;
while(timex<time){wait(1); timex++;}

set(ar,TRANSLUCENT); //Allow alpha
while(ar.alpha>0){
ar.alpha-=20*time_step;
wait(1);
}


ptr_remove(ar); //remove the local created panel pointer
}




Last edited by Superku; 07/01/10 22:33.

"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Fading panel problem. [Re: Superku] #331115
07/01/10 22:44
07/01/10 22:44
Joined: Jul 2004
Posts: 1,710
MMike Offline OP
Serious User
MMike  Offline OP
Serious User

Joined: Jul 2004
Posts: 1,710
well ok , thats the solution of course, the use of the fade function was just a short cut.
But thanks for the input.

Re: Fading panel problem. [Re: MMike] #331119
07/01/10 23:56
07/01/10 23:56
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Not exactly, the fade function was the mistake! When you call it, it will be executed until the engine finds the first wait(1), then your load_wait() function will continue. The next instruction ptr_remove(ar) kills the panel instantly, but your fade function still tries to fade the panel out smoothly. As the panels probably are linked lists, the engine now fades the next pointer in the list which is your second panel (just a guess).


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Fading panel problem. [Re: Superku] #331121
07/02/10 01:06
07/02/10 01:06
Joined: Jul 2004
Posts: 1,710
MMike Offline OP
Serious User
MMike  Offline OP
Serious User

Joined: Jul 2004
Posts: 1,710
yeah that was my point, the next on the list.
hey but thanks for your help

Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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