Wintermute Engine Forum
Wintermute Engine => Technical forum => Topic started 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
#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
-
You need to have a single LeftClick handler, and do all the processing in it.
on "LeftClick"
{
if (degree == 45)
{
// ...
}
else if (degree == 90)
{
// ...
}
else if (etc.)
}
Or consider just increasing the angle, like degree = degree + 45;
-
work!! ::rock
for help
complete scritpt in loop
#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*
-
tk ^^