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: executing animated sprites via the mouse pointer  (Read 10809 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
executing animated sprites via the mouse pointer
« on: September 07, 2004, 09:20:52 AM »

Hi all,
        I have a credits scene, and I also have an animated sprite in the design of a scroll.

What i want is when the mouse pointer enters the region the scroll sprite is activated (unravels) and when the mouse pointer moves out of the region another sprite (the scroll animating - closeing) executes.

I know how to define the region in scene edit and i know how to attach a script, just do not know the code to make this work.

Any snippets??


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: executing animated sprites via the mouse pointer
« Reply #1 on: September 07, 2004, 12:58:48 PM »

ok i have had a go at this, but keep getting syntax errors, i think the code is ok but brackets are not?

here is the code.


#include "scripts\base.inc"


////////////////////////////////////////////////////////////////////////////////
on "LeftClick"
{

  // get the scroll entity
  var EntscrollLF = Scene.GetNode("scrollLF");

  // set the scroll entity sprite depending on the state variable
  // (0-OPEN, 1-CLOSED)

  if(StateCREDITS.scrollLF==0)
    EntscrollLF.SetSprite("scenes\CREDITS\sprites\scrollopen.sprite");
    StateCREDITS.scrollLF = 1;




else if(StateCREDITS.scrollLF==1)
{
    EntscrollLF.SetSprite("scenes\CREDITS\sprites\scrollclosed.sprite");
    StateCREDITS.scrollLF = 0;
}



this script is attached to a sprite entity called scrollLF


I am trying with this code honest...... hahahahhaa



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: executing animated sprites via the mouse pointer
« Reply #2 on: September 07, 2004, 03:35:21 PM »

The brackets should probably look like this:

Code: [Select]
////////////////////////////////////////////////////////////////////////////////
on "LeftClick"
{
  // get the scroll entity
  var EntscrollLF = Scene.GetNode("scrollLF");

  // set the scroll entity sprite depending on the state variable
  // (0-OPEN, 1-CLOSED)

  if(StateCREDITS.scrollLF==0)
  {
    EntscrollLF.SetSprite("scenes\CREDITS\sprites\scrollopen.sprite");
    StateCREDITS.scrollLF = 1;
  }
  else if(StateCREDITS.scrollLF==1)
  {
    EntscrollLF.SetSprite("scenes\CREDITS\sprites\scrollclosed.sprite");
    StateCREDITS.scrollLF = 0;
  }
}

Indenting helps to keep track of your brackets :)

Will there be only one active area on screen? And do you want to activate it on mouse-over only or will the player have to click it?
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: executing animated sprites via the mouse pointer
« Reply #3 on: September 07, 2004, 03:41:35 PM »

there will be 3 areas and the player will click the scroll to open it, click to close it



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: executing animated sprites via the mouse pointer
« Reply #4 on: September 07, 2004, 03:47:17 PM »

I keep geeting errors with this script


Is it bad syntax, debug just says bad syntax


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: executing animated sprites via the mouse pointer
« Reply #5 on: September 07, 2004, 04:32:33 PM »

getting nowhere fast with this script.

To recap, I have a scroll when i click on it with left mouse button i want it to open, when I click on it again with left mouse button I want it to close.



Help please. aaaaaaaaaaaaaaggggggggghhhhhhhhh!!!

Loosing hair quickly...hahahahaha


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: executing animated sprites via the mouse pointer
« Reply #6 on: September 07, 2004, 04:59:16 PM »

I keep geeting errors with this script


Is it bad syntax, debug just says bad syntax

Hm, it's syntactically correct, I just tried to compile it. Providing the StateCREDITS variable is declared somewhere in that script, that is.
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: executing animated sprites via the mouse pointer
« Reply #7 on: September 07, 2004, 05:01:04 PM »

yes it nopw is correct syntax wise, but it does not change from one sprite to another, closed to open and vice versa?



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: executing animated sprites via the mouse pointer
« Reply #8 on: September 07, 2004, 05:07:19 PM »

Ok, how about this, that should work I think:

Code: [Select]
global StateCREDITS;
StateCREDITS.scrollLF = 0; // initial value


////////////////////////////////////////////////////////////////////////////////
on "LeftClick"
{
  // get the scroll entity
  var EntscrollLF = Scene.GetNode("scrollLF");

  // set the scroll entity sprite depending on the state variable
  // (0-OPEN, 1-CLOSED)

  if(StateCREDITS.scrollLF==0)
  {
    EntscrollLF.SetSprite("scenes\CREDITS\sprites\scrollopen.sprite");
    StateCREDITS.scrollLF = 1;
  }
  else if(StateCREDITS.scrollLF==1)
  {
    EntscrollLF.SetSprite("scenes\CREDITS\sprites\scrollclosed.sprite");
    StateCREDITS.scrollLF = 0;
  }
}
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: executing animated sprites via the mouse pointer
« Reply #9 on: September 08, 2004, 12:01:01 PM »

Hi all,
        Mnemonic I have tested this and initially it works fine, i click on the nameplate (entity in sceneedit with script assigned)
and the scroll appears and unravels.
I click again with the left mouse button and it rolls up (scrollLFclosed.sprite).

But if i try to click the name plate again (a second time) nothing happens.

Also when I exit this room and return after opening closing the scroll the first time, the scene loads and the scroll runs through the close animation automatically.


Any ideas why this is happening??

How can I change it so I can click on it multiple times, opening and closing the scroll?
How can I remove the automatic close animation when I return to the credits screen?



Many thanks for your superb help



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: executing animated sprites via the mouse pointer
« Reply #10 on: September 08, 2004, 01:47:44 PM »

Quote
How can I change it so I can click on it multiple times, opening and closing the scroll?
I can't see anything wrong with the code above. It should work, IMHO...

Quote
How can I remove the automatic close animation when I return to the credits screen?
In SceneEdit, on the scene properties pane, uncheck "Remember nodes states". That should help.
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: executing animated sprites via the mouse pointer
« Reply #11 on: September 08, 2004, 01:53:13 PM »

ok now the scrolls do not automatically open/close when you go back to the credits scene.

But you can still only open /close them once. This does get reset when you leave the scene and reenter it. But when you are in the scene you can only open, close the scrolls once, sounds to me as though somthing is not getting reset, but it is when you leave the scene and re-enter it.


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: executing animated sprites via the mouse pointer
« Reply #12 on: September 08, 2004, 02:03:35 PM »

here is the script.


#include "scripts\base.inc"

global StateCREDITS;

StateCREDITS.scrollLF = 0; // initial value


////////////////////////////////////////////////////////////////////////////////
on "LeftClick"
{
  // get the scroll entity
  var EntscrollLF = Scene.GetNode("scrollLF");

  // set the scroll entity sprite depending on the state variable
  // (0-OPEN, 1-CLOSED)

  if(StateCREDITS.scrollLF==0)
  {
    EntscrollLF.SetSprite("scenes\CREDITS\sprites\scrollLFopen.sprite");
    StateCREDITS.scrollLF = 1;
  }
  else if(StateCREDITS.scrollLF==1)
  {
    EntscrollLF.SetSprite("scenes\CREDITS\sprites\scrollLFclosed.sprite");
    StateCREDITS.scrollLF = 0;
  }
}

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: executing animated sprites via the mouse pointer
« Reply #13 on: September 09, 2004, 10:17:01 AM »

Any solution to this problem?

The scrolls only open and close once then when you revisit the scene you can do it again but only once, not open and close them multiple times.

The code is listed above.


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: executing animated sprites via the mouse pointer
« Reply #14 on: September 09, 2004, 10:37:33 AM »

No, the code seems ok to me. But you can send me the entire scene if you want. I'll test it.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave
Pages: [1] 2  All
 

Page created in 0.048 seconds with 20 queries.