﻿ Problem with rotate sprite
• May 31, 2020, 10:50:12 AM
• Welcome, Guest

### News:

Forum rules - please read before posting, it can save you a lot of time.

Pages: [1]

### AuthorTopic: Problem with rotate sprite  (Read 1745 times)

0 Members and 1 Guest are viewing this topic.

#### keybone

• Regular poster
• Karma: 0
• Offline
• Posts: 112
##### 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
• Karma: 41
• Offline
• Gender:
• Posts: 5681
##### 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.

#### keybone

• Regular poster
• Karma: 0
• Offline
• Posts: 112
##### Re: Problem with rotate sprite
« Reply #2 on: July 15, 2011, 09:45:02 AM »

work!!

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
• Posts: 112
##### 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
Pages: [1]

Page created in 0.531 seconds with 23 queries.