View Single Post
  #1  
Old 09-17-2010, 06:47 PM
Soala Soala is offline
Ideas on Fire
Soala's Avatar
Join Date: Jun 2007
Location: In my head
Posts: 3,208
Soala is a jewel in the roughSoala is a jewel in the rough
Level transition fade in/out

You probably went on Ruins lately, and saw the level transition effects (fade in/out). A lot of people are asking me how it was made, so I decided to simply share it. Might be useful for people later on!

Class (named level_link)
PHP Code:
function onCreated() {
  
this.setshape(1, this.w*16, this.h*16);
  
this.blockagain();
}

//#CLIENTSIDE
function onCreated() {
  
this.setshape(1, this.w*16, this.h*16);
  
this.blockagain();
}

function 
onPlayerTouchsMe() {
  if (
this.touched) return;
  
temp.data = {this.lvl, this.lvlx, this.lvly};
  
interfaceVisuals.fadelevel(temp.data);
  
this.touched = true;
  
setTimer(3);
}

function 
onTimeout()
  
this.touched = false; 
interfaceVisuals is our wNPC handling all the visuals, along with the fade in/out effects, here are the bits of it for the fade effect
PHP Code:
public function fadelevel(lvldata) {
  
client.freezed = true;
  
fadeOut(lvldata);
}
  

function 
fadeIn() {
  for(
temp.i = 1; temp.i >= -0.30; temp.i -= 0.30) {
    
findimg(this.poly).alpha = temp.i;
    
sleep(0.05);
  }
  
hideimg(this.poly);
  
this.poly = 0;
  
client.freezed = false;
}

function 
fadeOut(lvldata) {
  
temp.data = lvldata;
  
client.warpdata = lvldata;
  if (
this.poly == 0) this.poly = drawScreenPoly(); 
  for(
temp.i = 0; temp.i < 1.35; temp.i += 0.35) {
    
findimg(this.poly).alpha = temp.i;
    
sleep(0.05);
  }
  
setani("your idle gani name", 0);
  
sleep(0.25);
  
triggerserver("gui", "interfaceVisuals", "warpplayer", 0);
  
sleep(0.5);
  
fadeIn();
} 

Here's an example of level npc you can use in order to use the link and level transition:
PHP Code:
this.join("level_link");
this.w = 6;
this.h = 1;
//#CLIENTSIDE
this.w = 6;
this.h = 1;
this.lvl = "level name it links to.nw";
this.lvlx = 24;
this.lvly = 1; 
this.w is the link's width and this.h the link's height (in tiles of course)

Credits to Axel (account: Contrast, go +rep him if you want!) for making it, and to Tig who gave us some hints on how GK's was made. Enjoy

Last edited by Soala; 09-17-2010 at 07:15 PM..
Reply With Quote