Please login or register.

Login with username, password and session length
Advanced search  

News:

For WME related articles and tutorials visit WME Resource Center.

Author Topic: I need help  (Read 4983 times)

0 Members and 1 Guest are viewing this topic.

lechuck

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 14
    • View Profile
I need help
« on: August 27, 2007, 07:39:39 PM »

Hello comunity:
I write this post because i need help with a script: i want that when a animation that moves continuity thru the screen go out of the resolution of the screen, it return to the initial position and continue the cycle.
Thanks.

Lechuck
Logged

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: I need help
« Reply #1 on: August 27, 2007, 07:59:22 PM »

do you have your animation in script or do you do it in Sprite Edit?
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

lechuck

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 14
    • View Profile
Re: I need help
« Reply #2 on: August 27, 2007, 08:21:16 PM »

I did the animation in Sprite edit.
Logged

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: I need help
« Reply #3 on: August 27, 2007, 09:11:19 PM »

try setting "Looping" on the properties tab.
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

lechuck

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 14
    • View Profile
Re: I need help
« Reply #4 on: August 30, 2007, 06:25:55 AM »

its didnt work....
what i want is that the sprite return to the initial position after it move thru the background...
Logged

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: I need help
« Reply #5 on: August 30, 2007, 08:06:15 AM »

You do make the position change through the moveby parameter in scene edit?

You can for example insert last frame, which will use MoveBy with a negative value. This would work only if you use a full frame set for the movement.

Much more elegant way for the movement is to script it. It's actually also much more simple. If you name your entity in Sprite Edit for example Car your code for this would look like this:

var car  = Scene.GetNode("Car");
global CarLoop = true;

while (CarLoop)
{
   for (var b=0;b<1024;b=b+1)
   {
       car.X = b;  // we move our car over the screen from 0 to 1024
       Sleep(100); // wait 100 miliseconds. At least Sleep(1) is required so your game won't freeze.
   }
}

Variable CarLoop is here because sometimes you might want to stop the car based on some other action which happens in different script. So Upon that action you simply set the CarLoop variable to false and car stops.
« Last Edit: August 30, 2007, 08:16:55 AM by metamorphium »
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

lechuck

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 14
    • View Profile
Re: I need help
« Reply #6 on: September 02, 2007, 09:10:44 PM »

thank you. i'll  try it.
but to use a global variable in another script that is not the one which create it, do i need to include the script file???
Logged

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: I need help
« Reply #7 on: September 02, 2007, 11:30:34 PM »

if you want to use global variables, you must declare its name in every script you use it like this:

global some_variable;

You might want to check this tutorial:

http://wiki.dead-code.org/wakka.php?wakka=ObjectsVariables
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

TheDerman

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 225
    • View Profile
Re: I need help
« Reply #8 on: September 03, 2007, 12:03:00 AM »

I did this for clouds moving across the sky. I had two sprites, which were made to be seamless. Each cloud sprite was the width of the entire screen, in this case 1370 pixels.

Initially in scene edit, I position one sprite (the right cloud sprite) so that it fills the entire screen, and the second sprite (the left cloud sprite) directly to the left, so that it is completely off screen.

This script I put on the left cloud sprite:

Code: WME Script
  1. #include "scripts\base.inc"
  2.  
  3.  
  4. while(true)
  5. {
  6.   this.X = -1370;
  7.   this.Y = 64;
  8.  
  9.   while(this.X < 1370)
  10.    {
  11.     this.X = this.X + 1;
  12.     Sleep(50);
  13.    }
  14. }
  15.  

And this script I put on the right cloud sprite:

Code: WME Script
  1. #include "scripts\base.inc"
  2.  
  3. var CloudRight = false;
  4.  
  5. while(true)
  6. {
  7.   if(CloudRight==false)
  8.    {
  9.     this.X = 0;
  10.     this.Y = 64;
  11.    }
  12.   else
  13.    {
  14.     this.X = -1370;
  15.     this.Y = 64;
  16.    }
  17.  
  18.   while(this.X < 1370)
  19.    {
  20.     this.X = this.X + 1;
  21.     Sleep(50);
  22.    }
  23.   CloudRight = true;
  24. }
  25.  

So, this means that the clouds appear to move across the sky forever, seamlessly. When the initial right cloud sprite gets to a position which is completely off screen, it is sent back to the left, behind the left cloud sprite - effectivly both sprites keep switching positions each time they get completely off screen to the right, which keep the clouds moving seamlessly forever. It sounds more complex than it is.

Hope it helps.
« Last Edit: September 03, 2007, 12:07:47 AM by TheDerman »
Logged

lechuck

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 14
    • View Profile
Re: I need help
« Reply #9 on: September 03, 2007, 06:58:06 PM »

thank you so much... i needed something like that
Logged
 

Page created in 0.063 seconds with 21 queries.