Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1]   Go Down

Author Topic: Transitional Tutorial  (Read 830 times)

0 Members and 1 Guest are viewing this topic.

Koh

Transitional Tutorial
« on: April 06, 2007, 12:00:19 pm »
  • Tamer Koh
  • *
  • Reputation: +6/-0
  • Offline Offline
  • Gender: Male
  • Posts: 980
Well first you want to define a few variables.

Code: [Select]
global.transition = 0;
global.transDir = ""
global.viewTargX = view_xview;
global.viewTargY = view_yview;
lvx=view_xview
lvy=view_yview
^
These variables help the transition.  The first 4 are for the transition and the bottom to stand for "Last X_View" and "Last Y_View" which we will get to later.


Then you want to go the End Step event and put this first:

Code: [Select]
//Check if player is outside the view
if (global.transition) exit;
vx = view_xview[0] //Set up some placeholders to save space
vw = view_wview[0]
vy = view_yview[0]
vh = view_hview[0]

if (x< vx){
global.transDir = "left"
global.transition = 1;
global.viewTargX = (vx-vw)
}

else if ((x+sprite_width) > vx+vw){
global.transDir = "right"
global.transition = 1;
global.viewTargX = (vx+vw)
}

else if (y< vy){
global.transDir = "up"
global.transition = 1;
global.viewTargY = (vy-vh)
}

else if ((y+sprite_height) > vy+vh){
global.transDir = "down"
global.transition = 1;
global.viewTargY = (vy+vh)
}

^
That Checks for the direction in which to do the transitioning.   Down, Up, Left, or Right.


Then Execute Another piece of code after that containing:
Code: [Select]
if (!global.transition) exit;
//Check if the view is in the right place and, if not, move it closer
//Move Right
if (global.viewTargX > view_xview[0]){
  view_xview[0] += 8;
  if place_free(x+1,y){
    x+=1
  }
  lvx=view_xview[0]
  lvy=view_yview[0]
 }
else if global.transDir = "right"{view_xview[0] = global.viewTargX; global.transition = 0}
//Move left
if (global.viewTargX < view_xview[0]){
  view_xview[0] -= 8;
  if place_free(x-1,y){
    x-=1
  }
  lvx=view_xview[0]
  lvy=view_yview[0]
 }
  else if global.transDir = "left"{view_xview[0] = global.viewTargX; global.transition = 0}
 //Move down
if (global.viewTargY > view_yview[0]){
  view_yview[0] += 8;
  if place_free(x,y+1){
    y+=1
  }
  lvx=view_xview[0]
  lvy=view_yview[0]
  }
  else if global.transDir = "down"{view_yview[0] = global.viewTargY; global.transition = 0}
//Move up
if (global.viewTargY < view_yview[0]){
  view_yview[0] -= 8;
  if place_free(x,y-1){
    y-=1
  }
  lvx=view_xview[0]
  lvy=view_yview[0]
 }
  else if global.transDir = "up"{view_yview[0] = global.viewTargY; global.transition = 0}
^
That is the actual transitioning where the screen moves depending on which direction its going.  It stops itself at a multiple of 160 for left and right and a multiple of 144 on Down and Up.  You can change that.


Oh and when you go to your step event code, put this at the very top:

Code: [Select]
if(global.transition) exit;
^
This will prevent Link from moving or doing anything during a transition.

Lastly, put this in your main rooms and dungeons code:

Code: [Select]
if(instance_exists(objLink) && objLink.moveable && !global.died){
    view_xview=objLink.lvx
    view_yview=objLink.lvy
}
^
Which will put the view back from where it was before you entered the builging or dungeon.  Change objLink to the name of your players object.

Hope that helped those who needs the transitions...
Logged
  • Megaclipse Games
Pages: [1]   Go Up

 


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.226 seconds with 39 queries.