Please login or register.

Login with username, password and session length
Advanced search  

News:

This forum provides RSS feed. To query recent posts use this url. More...


Pages: [1] 2  All

Author Topic: MENU animations 2  (Read 14109 times)

0 Members and 1 Guest are viewing this topic.

SBOVIS

  • Frequent poster
  • ****
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 404
  • FORGET REALITY SURRENDER TO YOUR DARKEST DREAMS
    • View Profile
    • LIMBO of the LOST
MENU animations 2
« on: July 30, 2004, 01:12:29 PM »

Hi all,
        Following on from my query regarding animateing menus and Inventory, I have done just that following Mnemonics advice to create a Sprite rather than a BMP.

But the animation only plays once, when you go into the Inventory or access the Menu.

How can I do it so that it plays everytime the player opens Inventory or a menu??


Any ideas??

By the way I am using the Demo Inventory and the Demo menu scripts.



Many thanks


Steve
Logged
kind Regards
Steve Bovis
MAJESTIC STUDIOS

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: MENU animations 2
« Reply #1 on: July 30, 2004, 02:20:22 PM »

Hmm, you will have to re-assign the background image to your inventory/menu windows when you are about to display them.
Currently, to display the inventory you do something like Game.InventoryVisible = true; (in game_daemon.script). You'll have to replace it by something like:

var InvWin = Game.GetInventoryWindow();
InvWin.SetImage("path\some_background.sprite");
Game.InventoryVisible = true;

Similarly the menu window, except the first line, since you already have the menu window stored in a global variable (WinMenu by default).

WinMenu.SetImage("path\some_menu_background.sprite");
WinMenu.Visible = true;


I can't test it right now but it should work this way.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

SBOVIS

  • Frequent poster
  • ****
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 404
  • FORGET REALITY SURRENDER TO YOUR DARKEST DREAMS
    • View Profile
    • LIMBO of the LOST
Re: MENU animations 2
« Reply #2 on: July 30, 2004, 02:51:04 PM »

thanks mnemonic but having trouble implementing this.

This is the script:

global WinMenu;

// infinite loop
while(true){

  // save the active object for later
  var ActObj = Game.ActiveObject;

  // handle the standard foating caption
  if(Game.Interactive && ActObj!=null)
  {
    if (Game.SelectedItem==null)
    {
      WinCaption.X = Game.MouseX;
      WinCaption.Y = Game.MouseY + 20;
      WinCaption.TextAlign = TAL_LEFT;
      WinCaption.Text = ActObj.Caption;

      // keep the caption on screen
      WinCaption.SizeToFit();
      if(WinCaption.X + WinCaption.Width > Game.ScreenWidth) WinCaption.X = Game.ScreenWidth - WinCaption.Width;
      if(WinCaption.Y + WinCaption.Height > Game.ScreenHeight) WinCaption.Y = Game.ScreenHeight - WinCaption.Height;
     }
    // handle the caption when you want to use an object with another
    else {
      var Item = Game.SelectedItem;

      WinCaption.X = 0;
      WinCaption.Y = 580;
      WinCaption.Width = Game.ScreenWidth;
      WinCaption.TextAlign = TAL_CENTER;
      WinCaption.Text = "Use " + Item.Caption + " with " + ActObj.Caption;
    }
    WinCaption.Visible = true;
    WinCaption.Focus();
  }
  else WinCaption.Visible = false;

  // display the inventory window
 
if(Game.Interactive && Game.MouseY < 45 && !Game.ResponsesVisible && !WinMenu.Visible) Game.InventoryVisible = true;
  else if(Game.MouseY > 100 || Game.ResponsesVisible || !Game.Interactive) Game.InventoryVisible = false;



  // go to sleep for 20 miliseconds to allow the engine to perform other tasks
  // it is important for the "endless" scripts to call the Sleep command, otherwise the game will get stuck
  Sleep(20);
}



Do I delete the whole part of the Inventory code - 

// display the inventory window
 if(Game.Interactive && Game.MouseY < 45 && !Game.ResponsesVisible && !WinMenu.Visible) Game.InventoryVisible = true;
  else if(Game.MouseY > 100 || Game.ResponsesVisible || !Game.Interactive) Game.InventoryVisible = false;

and put your code?


I am a bit lost.



Steve

Logged
kind Regards
Steve Bovis
MAJESTIC STUDIOS

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: MENU animations 2
« Reply #3 on: July 30, 2004, 02:55:56 PM »

Replace:

Code: [Select]
if(Game.Interactive && Game.MouseY < 45 && !Game.ResponsesVisible && !WinMenu.Visible) Game.InventoryVisible = true;
else if(Game.MouseY > 100 || Game.ResponsesVisible || !Game.Interactive) Game.InventoryVisible = false;

with:

[code]
if(Game.Interactive && Game.MouseY < 45 && !Game.ResponsesVisible && !WinMenu.Visible)
{
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

SBOVIS

  • Frequent poster
  • ****
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 404
  • FORGET REALITY SURRENDER TO YOUR DARKEST DREAMS
    • View Profile
    • LIMBO of the LOST
Re: MENU animations 2
« Reply #4 on: July 30, 2004, 03:10:53 PM »

I have done this, but it only animates when I press Quit or Esc not when the Inventory pops up.

It also animates if the mouse pointer is on Y position 45 after the screen is shown.

I need it to animate exactly as the inventory screen appears.


Steve


Logged
kind Regards
Steve Bovis
MAJESTIC STUDIOS

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: MENU animations 2
« Reply #5 on: July 30, 2004, 04:24:52 PM »

Ok, sorry about that, one more try:

[code]
if(Game.Interactive && Game.MouseY < 45 && !Game.ResponsesVisible && !WinMenu.Visible)
{
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

SBOVIS

  • Frequent poster
  • ****
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 404
  • FORGET REALITY SURRENDER TO YOUR DARKEST DREAMS
    • View Profile
    • LIMBO of the LOST
Re: MENU animations 2
« Reply #6 on: July 30, 2004, 04:37:22 PM »

great it works now, thanks mnemonic, will try menu and let you know.


Many thanks.


Steve
Logged
kind Regards
Steve Bovis
MAJESTIC STUDIOS

SBOVIS

  • Frequent poster
  • ****
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 404
  • FORGET REALITY SURRENDER TO YOUR DARKEST DREAMS
    • View Profile
    • LIMBO of the LOST
Re: MENU animations 2
« Reply #7 on: August 03, 2004, 02:15:46 PM »

The inventory works great now, but still stuck on the menu animation.


Have changed the game-demon script to include what you said above but nothing happens.


Any ideas where I am going wrong?


Many thanks mnemonic and the forum.



Steve
Logged
kind Regards
Steve Bovis
MAJESTIC STUDIOS

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: MENU animations 2
« Reply #8 on: August 03, 2004, 02:33:12 PM »

Ok, can you post your modified script here, please?
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

SBOVIS

  • Frequent poster
  • ****
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 404
  • FORGET REALITY SURRENDER TO YOUR DARKEST DREAMS
    • View Profile
    • LIMBO of the LOST
Re: MENU animations 2
« Reply #9 on: August 03, 2004, 02:53:51 PM »

MODIFIED SCRIPT:

#include "scripts\base.inc"

global WinCaption;
global WinMenu;

// infinite loop
while(true){

  // save the active object for later
  var ActObj = Game.ActiveObject;

  // handle the standard foating caption
  if(Game.Interactive && ActObj!=null)
  {
    if (Game.SelectedItem==null)
    {
      WinCaption.X = Game.MouseX;
      WinCaption.Y = Game.MouseY + 20;
      WinCaption.TextAlign = TAL_LEFT;
      WinCaption.Text = ActObj.Caption;

      // keep the caption on screen
      WinCaption.SizeToFit();
      if(WinCaption.X + WinCaption.Width > Game.ScreenWidth) WinCaption.X = Game.ScreenWidth - WinCaption.Width;
      if(WinCaption.Y + WinCaption.Height > Game.ScreenHeight) WinCaption.Y = Game.ScreenHeight - WinCaption.Height;
     }
    // handle the caption when you want to use an object with another
    else {
      var Item = Game.SelectedItem;

      WinCaption.X = 0;
      WinCaption.Y = 580;
      WinCaption.Width = Game.ScreenWidth;
      WinCaption.TextAlign = TAL_CENTER;
      WinCaption.Text = "Use " + Item.Caption + " with " + ActObj.Caption;
    }
    WinCaption.Visible = true;
    WinCaption.Focus();
  }
  else WinCaption.Visible = false;

  // display the inventory window
if(Game.Interactive && Game.MouseY < 10 && !Game.ResponsesVisible && !WinMenu.Visible)
{
  if(!Game.InventoryVisible)
  {
    var InvWin = Game.GetInventoryWindow();
    InvWin.SetImage("data\interface\inventory.sprite");
    Game.InventoryVisible = true;
  }
}
else if(Game.MouseY > 110 || Game.ResponsesVisible || !Game.Interactive) Game.InventoryVisible = false;
  // go to sleep for 20 miliseconds to allow the engine to perform other tasks
  // it is important for the "endless" scripts to call the Sleep command, otherwise the game will get stuck
  Sleep(20);
}


Cheers

steve
Logged
kind Regards
Steve Bovis
MAJESTIC STUDIOS

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: MENU animations 2
« Reply #10 on: August 03, 2004, 03:10:42 PM »

Umm...wait a minute, this only handles the inventory. The menu display is handled in game.script in the "RightClick" handler. Edit game.script, locate these two lines:

// and show the right-click menu
WinMenu.Visible = true;

and replace them with:

// and show the right-click menu
WinMenu.SetImage("path\some_menu_background.sprite");
WinMenu.Visible = true;


That should do the trick.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

SBOVIS

  • Frequent poster
  • ****
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 404
  • FORGET REALITY SURRENDER TO YOUR DARKEST DREAMS
    • View Profile
    • LIMBO of the LOST
Re: MENU animations 2
« Reply #11 on: August 03, 2004, 03:41:43 PM »

sorry Mnemonic was unclear on this.

Works well now thank you.



Steve
Logged
kind Regards
Steve Bovis
MAJESTIC STUDIOS

SBOVIS

  • Frequent poster
  • ****
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 404
  • FORGET REALITY SURRENDER TO YOUR DARKEST DREAMS
    • View Profile
    • LIMBO of the LOST
Re: MENU animations 2
« Reply #12 on: August 11, 2004, 11:51:08 AM »

Hi Mnemonic,
                  All works great but need a change to it, what i want is the initail animation to play when the user first selects the menu then everytime after that it plays an animation that is different to the initail one.

Also on both animations because they are sprites can I add a sound effect via sprite edit or do I need to code it?


Last post on this subject honest.

I am going to add you to my game credits as Engine creator and co-scripter is this ok?

link to game website:-

http://www.geocities.com/stevenbovis/LIMBO_of_the_LOST.html


Many thanks


Steve
Logged
kind Regards
Steve Bovis
MAJESTIC STUDIOS

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: MENU animations 2
« Reply #13 on: August 11, 2004, 01:08:17 PM »

Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

SBOVIS

  • Frequent poster
  • ****
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 404
  • FORGET REALITY SURRENDER TO YOUR DARKEST DREAMS
    • View Profile
    • LIMBO of the LOST
Re: MENU animations 2
« Reply #14 on: August 11, 2004, 03:09:17 PM »

Do i put this global variable in the data\scripts\game.script ?

and put it where the menu is called?

     // and show the right-click menu
 
WinMenu.SetImage("data\interface\menu\menu.sprite");
WinMenu.Visible = true;



steve
Logged
kind Regards
Steve Bovis
MAJESTIC STUDIOS
Pages: [1] 2  All
 

Page created in 0.05 seconds with 23 queries.