Please login or register.

Login with username, password and session length
Advanced search  

News:

This forum provides RSS feed. To query recent posts use this url. More...


Author Topic: Sprite moving and entity position  (Read 6251 times)

0 Members and 1 Guest are viewing this topic.

Mihulik

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 71
    • View Profile
Sprite moving and entity position
« on: July 22, 2010, 08: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. :)

Thanks!
« Last Edit: July 22, 2010, 08:38:23 AM by Mihulik »
Logged

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: Sprite moving and entity position
« Reply #1 on: July 22, 2010, 09:37:32 AM »

please post your code
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

Mihulik

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 71
    • View Profile
Re: Sprite moving and entity position
« Reply #2 on: July 22, 2010, 10:44:59 AM »

Code: WME Script
  1. #include "scripts\base.inc"
  2.  
  3. while(true){
  4. var fog = Scene.GetNode("fog");
  5.  
  6. if(fog.X <= -2142){
  7. fog.X = fog.X + 2142;
  8. }
  9.  
  10. Sleep(20);
  11. }

I attach the script when a scene is initializing:
Code: WME Script
  1. #include "scripts\base.inc"
  2.  
  3. Game.AttachScript("scenes\Obzorye_Island-Beach\scr\Fog.script");
  4.  
  5. if(Game.PrevScene == "Obzorye_Island-Mountain_path"){
  6. actor.SkipTo(1423, 330);
  7. actor.Direction = DI_DOWN;
  8. actor.Active = true;
  9. }
  10.  
  11.  
  12. Scene.SkipTo(actor);
  13.  
  14. on "SceneShutdown"{
  15. Game.DetachScript("scenes\Obzorye_Island-Beach\scr\Fog.script");
  16. }


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

The sprite is set in this way:
« Last Edit: July 27, 2010, 08:15:00 AM by Jyujinkai »
Logged

Mihulik

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 71
    • View Profile
Re: Sprite moving and entity position
« Reply #3 on: July 24, 2010, 05: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
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 59
  • Good news
    • View Profile
Re: Sprite moving and entity position
« Reply #4 on: July 25, 2010, 08: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: WME Script
  1. #include "scripts\base.inc"
  2.  
  3. while(true){
  4.  
  5. if (this.X <= -2142) this.X = 2142;
  6. Sleep(20);
  7.  
  8. }

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

Mihulik

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 71
    • View Profile
Re: Sprite moving and entity position
« Reply #5 on: July 25, 2010, 02:14:58 PM »

Thanks!
I'll try it and let you know whether it'll help me :)
Logged

Mihulik

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 71
    • View Profile
Re: Sprite moving and entity position
« Reply #6 on: July 25, 2010, 07: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. ;)

So, I thank you again for the working solution and mainly for the new finding. :)
« Last Edit: July 25, 2010, 08:12:18 PM by Mihulik »
Logged

maze

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 59
  • Good news
    • View Profile
Re: Sprite moving and entity position
« Reply #7 on: July 27, 2010, 10:44:12 PM »

No Prob.

This reminds me of the time when I was new to WME.
Logged
 

Page created in 0.031 seconds with 25 queries.