Wintermute Engine Forum
September 02, 2010, 09:27:09 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Forum rules - please read before posting, it can save you a lot of time.
 
   Home   Help Search Calendar Login Register  
Pages: [1]
  Print  
Author Topic: Sprite moving and entity position  (Read 402 times)
0 Members and 1 Guest are viewing this topic.
Mihulik
Lurker
*
Offline Offline

Posts: 22


View Profile
« on: July 22, 2010, 09:14:14 AM »

Hi,
I'd like to have an entity which is moving over a screen.
So, I made a sprite by SpriteEditor, added an image, set looping on true and set "Move by" on -3/0.
In SceneEditor I connected that sprite with an entity.

In a loop I check a position of that entity.
However, the entity X property is always 0.


I need to check whether the entity X property has some value and if so, I wanna change something.


I'd be glad of any help. Smiley

Thanks!
« Last Edit: July 22, 2010, 09:38:23 AM by Mihulik » Logged
metamorphium
Global Moderator
Addicted to WME forum
*
Offline Offline

Gender: Male
Posts: 1325

Ghost in the Sheet


View Profile WWW
« Reply #1 on: July 22, 2010, 10:37:32 AM »

please post your code
Logged

Mihulik
Lurker
*
Offline Offline

Posts: 22


View Profile
« Reply #2 on: July 22, 2010, 11:44:59 AM »

Code
#include "scripts\base.inc"
 
while(true){
var fog = Scene.GetNode("fog");
 
if(fog.X <= -2142){
fog.X = fog.X + 2142;
}
 
Sleep(20);
}

I attach the script when a scene is initializing:
Code
#include "scripts\base.inc"
 
Game.AttachScript("scenes\Obzorye_Island-Beach\scr\Fog.script");
 
if(Game.PrevScene == "Obzorye_Island-Mountain_path"){
actor.SkipTo(1423, 330);
actor.Direction = DI_DOWN;
actor.Active = true;
}
 
 
Scene.SkipTo(actor);
 
on "SceneShutdown"{
Game.DetachScript("scenes\Obzorye_Island-Beach\scr\Fog.script");
}


And detach it when the scene is shooting down:-)

The sprite is set in this way:
« Last Edit: July 27, 2010, 09:15:00 AM by Jyujinkai » Logged
Mihulik
Lurker
*
Offline Offline

Posts: 22


View Profile
« Reply #3 on: July 24, 2010, 06:48:45 PM »

Nobody knows?
I've been spending hours on trying to figure out what's wrong.

But I haven't found any problem yet:-/
Logged
maze
Occasional poster
**
Offline Offline

Posts: 57


Good news


View Profile
« Reply #4 on: July 25, 2010, 09:00:09 AM »

Howdy Partner

I would use a different approach:
Attach your script in "Scene Edit" to the entity instead of loading it with AttachScript and change the code as following.

Code
#include "scripts\base.inc"
 
while(true){
 
if (this.X <= -2142) this.X = 2142;
Sleep(20);
 
}

This will do the trick and is a lot easier
« Last Edit: July 27, 2010, 09:15:22 AM by Jyujinkai » Logged
Mihulik
Lurker
*
Offline Offline

Posts: 22


View Profile
« Reply #5 on: July 25, 2010, 03:14:58 PM »

Thanks!
I'll try it and let you know whether it'll help me Smiley
Logged
Mihulik
Lurker
*
Offline Offline

Posts: 22


View Profile
« Reply #6 on: July 25, 2010, 08:57:59 PM »

It works well. Even more, your solution is much "cleaner" than my one.
I didn't know if I place an infinite loop into an entity script, it will work. I'm not so much experienced in WME. Wink

So, I thank you again for the working solution and mainly for the new finding. Smiley
« Last Edit: July 25, 2010, 09:12:18 PM by Mihulik » Logged
maze
Occasional poster
**
Offline Offline

Posts: 57


Good news


View Profile
« Reply #7 on: July 27, 2010, 11:44:12 PM »

No Prob.

This reminds me of the time when I was new to WME.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.10 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.389 seconds with 20 queries.