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: Problem with rotate sprite  (Read 3241 times)

0 Members and 1 Guest are viewing this topic.

keybone

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 112
    • View Profile
    • Lucine
Problem with rotate sprite
« 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
Logged
Lucine Company http://www.lucine.it/
Tales of Lucine: The Realm of Hobdark http://www.lucine.it/TalesOfLucine

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Problem with rotate sprite
« Reply #1 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;
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

keybone

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 112
    • View Profile
    • Lucine
Re: Problem with rotate sprite
« Reply #2 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*
Logged
Lucine Company http://www.lucine.it/
Tales of Lucine: The Realm of Hobdark http://www.lucine.it/TalesOfLucine

keybone

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 112
    • View Profile
    • Lucine
Re: Problem with rotate sprite
« Reply #3 on: July 15, 2011, 09:46:24 AM »

tk ^^
Logged
Lucine Company http://www.lucine.it/
Tales of Lucine: The Realm of Hobdark http://www.lucine.it/TalesOfLucine
 

Page created in 0.022 seconds with 25 queries.