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: Scrolling the scene  (Read 7228 times)

0 Members and 1 Guest are viewing this topic.

Ennio

  • Lurker
  • *
  • Karma: 2
  • Offline Offline
  • Posts: 40
    • View Profile
Scrolling the scene
« on: December 16, 2011, 12:57:25 PM »

I am sorry if the problem was faced in other topic, i didn't find anything useful!

I have a 1024x768 scene, it's a "between-levels" map, where the player can choose where to go by clicking places.
The problem is that the background image is 1900 pixel wide, and i have to scroll right and left the map to view all the scene.

This task is automatically done by engine when the actor walk around...but what if actor is not loaded? How can i achieve this?

thank you very much!
Logged

odnorf

  • w00t?
  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 7
  • Offline Offline
  • Gender: Male
  • Posts: 1456
  • Lamp dog!
    • View Profile
Re: Scrolling the scene
« Reply #1 on: December 16, 2011, 01:49:59 PM »

You can check cursor location (Scene.MouseX() and Scene.MouseY()) and manually scroll the scene with Scene.ScrollTo(X,Y).
Logged
fl*p

Ennio

  • Lurker
  • *
  • Karma: 2
  • Offline Offline
  • Posts: 40
    • View Profile
Re: Scrolling the scene
« Reply #2 on: December 16, 2011, 02:16:43 PM »

Wow, i love wme, i've missed that function :D
thank you!
Logged

Ennio

  • Lurker
  • *
  • Karma: 2
  • Offline Offline
  • Posts: 40
    • View Profile
Re: Scrolling the scene
« Reply #3 on: December 27, 2011, 08:44:38 PM »

I wrote code that looks very good for this task, scrolling a wide scene from left to right (and viceversa), when the cursor is positioned at the edges of the screen.

If anybody need, just ask ;)
Logged

piere

  • Supporter
  • Frequent poster
  • *
  • Karma: 4
  • Offline Offline
  • Posts: 301
  • Sorry for any bad english in my posts. Game on !
    • View Profile
Re: Scrolling the scene
« Reply #4 on: December 28, 2011, 12:16:41 AM »

Can someone post a small sample project with this code? Been curious about how to do this for awhile  ::rock
Logged

Ennio

  • Lurker
  • *
  • Karma: 2
  • Offline Offline
  • Posts: 40
    • View Profile
Re: Scrolling the scene
« Reply #5 on: December 28, 2011, 09:54:14 AM »

Sure!
As I said above, in my project i needed a navigable map so the actor, inventory, and other things like these are made inactive in the scene_init script, where i also attach another script, which i called navigation.script and which i detach when player leaves this scene

Here's code for navigation.script (note, the game window is 1024x768, this scene 1900x768)
Code: WME Script
  1. //set MainObject to null because i don't need in my scene the camera follow the actor
  2. //change the scroll speed, default were too slow for me
  3.  
  4. NavigationScroll();
  5.  
  6. function NavigationScroll()
  7. {
  8.         while(true)
  9.         {
  10.                 if (Game.MouseX < 20)
  11.                 {
  12.                         Scene.AutoScroll = true;
  13.                         Game.SetCursor("sprites\system\mapLeftArrow.sprite");
  14.                         Scene.ScrollToAsync(0, 0);
  15.                        
  16.                 }
  17.                
  18.                 else if (Game.MouseX > 1004)
  19.                 {
  20.                         Scene.AutoScroll = true;
  21.                         Game.SetCursor("sprites\system\mapRightArrow.sprite");
  22.                         Scene.ScrollToAsync(1900, 0);
  23.                 }
  24.                
  25.                 //if mouse position is not at the screen edges, stop scrolling and return to standard cursor
  26.                 else if (Game.MouseX > 20 && Game.MouseX < 1004)
  27.                 {
  28.                         Game.SetCursor("sprites\system\standardCursor.sprite");
  29.                         var ex = Scene.MouseX;
  30.                         var eps = Scene.MouseY;
  31.                         Scene.ScrollToAsync("ex","eps");
  32.                         Scene.AutoScroll = false;
  33.                 }
  34.                
  35.                
  36.         Sleep(30);
  37.         }
  38. }
  39.  
Logged

piere

  • Supporter
  • Frequent poster
  • *
  • Karma: 4
  • Offline Offline
  • Posts: 301
  • Sorry for any bad english in my posts. Game on !
    • View Profile
Re: Scrolling the scene
« Reply #6 on: December 28, 2011, 04:46:45 PM »

Good code.. Thanks !!!
Logged

ugo

  • Вредная ворона
  • Regular poster
  • ***
  • Karma: 2
  • Offline Offline
  • Gender: Male
  • Posts: 156
  • Делаю кве
    • View Profile
    • Хранители традиций УниВанга
Re: Scrolling the scene
« Reply #7 on: November 23, 2014, 05:50:24 AM »

Thanks.
Logged
 

Page created in 0.058 seconds with 20 queries.