Wintermute Engine Forum

Wintermute Engine => Technical forum => Topic started by: keybone on July 15, 2011, 08:51:13 AM

Title: Problem with rotate sprite
Post by: keybone on July 15, 2011, 08:51:13 AM
hi

i need help for a script.
Need to rotate a sprite in a right position. At each left click the sprite need rotate of the 45 °m with my script the spirte rotate only a time of 45° and stop.

My Wrong Script is
Code: [Select]
#include "scripts\base.inc"

global tavola=Scene.GetNode("Tavola");

global degree;
degree= 45;
tavola.Rotatable = true;

on "LeftClick"
if (degree==45)
{
tavola.Rotate = degree;
degree=90;
}
on "LeftClick"
if (degree==90)
{
tavola.Rotate = degree;
degree=135;
}
on "LeftClick"
if (degree==135)
{
degree.Rotate = degree;
degree=180;
}
on "LeftClick"
if (degree==180)
{
tavola.Rotate = degree;
degree=180;
}


tk for help
Title: Re: Problem with rotate sprite
Post by: Mnemonic on July 15, 2011, 09:03:06 AM
You need to have a single LeftClick handler, and do all the processing in it.

Code: WME Script
  1. on "LeftClick"
  2. {
  3.   if (degree == 45)
  4.   {
  5.     // ...
  6.   }
  7.   else if (degree == 90)
  8.   {
  9.     // ...
  10.   }
  11.   else if (etc.)
  12.  
  13. }
  14.  

Or consider just increasing the angle, like degree = degree + 45;
Title: Re: Problem with rotate sprite
Post by: keybone on July 15, 2011, 09:45:02 AM
work!!  ::rock

for help 
complete scritpt in loop

Code: [Select]
#include "scripts\base.inc"

global tavola=Scene.GetNode("Tavola");

global degree;
degree= 45;
tavola.Rotatable = true;

on "LeftClick"
if (degree==45)
{
tavola.Rotate = degree;
degree=90;
}

 else if (degree==90)
{
tavola.Rotate = degree;
degree=135;
}
 else if (degree==135)
{
tavola.Rotate = degree;
degree=180;
}
 else if (degree==180)
{
tavola.Rotate = degree;
degree=225;
}
else if (degree==225)
{
tavola.Rotate = degree;
degree=270;
}
else if (degree==270)
{
tavola.Rotate = degree;
degree=315;
}
else if (degree==315)
{
tavola.Rotate = degree;
degree=360;
}
else if (degree==360)
{
tavola.Rotate = degree;
degree=45;
}
[/code*
Title: Re: Problem with rotate sprite
Post by: keybone on July 15, 2011, 09:46:24 AM
tk ^^