Please login or register.

Login with username, password and session length
Advanced search  

News:

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

Author Topic: Exchange of images in the same scene  (Read 7524 times)

0 Members and 1 Guest are viewing this topic.

lfkk77

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 2
    • View Profile
Exchange of images in the same scene
« on: December 14, 2010, 09:26:36 PM »

hi, Hello everybody, I am a beginner,I want a picture game, which is similar to comic books.   ???
I think in the same scene - after clicking on the door - shows a new background image - again, click on the picture window - displays the next new background image.
Please tell me what to do? Thank you very much!   ::rock
Logged
Hi, Hello everybody, I am happy to WME family!

anarchist

  • Regular poster
  • ***
  • Karma: 5
  • Offline Offline
  • Gender: Male
  • Posts: 212
    • View Profile
Re: Exchange of images in the same scene
« Reply #1 on: February 01, 2011, 03:58:44 PM »

Lets say your door is named door1. You can script it as:

on "LeftClick"
{
    door1.SetImage("path_to_image);
}
Logged

Andrej (Blue Arc)

  • Occasional poster
  • **
  • Karma: 1
  • Offline Offline
  • Gender: Male
  • Posts: 73
    • View Profile
Re: Exchange of images in the same scene
« Reply #2 on: February 01, 2011, 04:36:03 PM »

The next way is to change scene. You can decide between changing a whole scene or only you can set the new background image as a background image of the same scene.

When you are using the code by anarchist, your background image is changed immidiately. But you can do the same by using Game.ChangeScene() method. Just set the FadeIn and FadeOut parameters to false.

I prefer to use one background for one scene. This is only my opinion.

Logged

BuffaloPhil

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 15
    • View Profile
    • Dirigo Games
Re: Exchange of images in the same scene
« Reply #3 on: February 01, 2011, 09:40:32 PM »

A third way is to add both images in scene editor as sprite entities.  Enable the first (the image that is active initially) and leave the second unchecked and disabled.  Make sure the second (invisible) image is arranged above the first.

Name the first image "first_display" and the second, disabled image "second_display". 

Use the following code in the first_display code text:

on "LeftClick" {
  var Entdisplay = Scene.GetNode("second_display");
  Entdisplay.Active = true;
}

-Wintermute rocks. 
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: Exchange of images in the same scene
« Reply #4 on: February 01, 2011, 11:26:36 PM »

If I got the request right, he wants to have interactive parts of the scene changing as well. So let's recap:

1. if you want to change the background image regardless of where you click, anarchists' way would be the way to go (although his code is wrong).
2. If you want to change the whole setting (eg. you click on the door, the door is displayed as a closeup and different interactive parts should be triggered) Andrej has the solution with change scene.
3. If you want to have stuff neatly grouped per rooms, you can use layers which would contain the background and the region entities alike so you'd simply handle the Layer visibility
4. Lastly if you want just a simple image change with pre-cooked entities, BuffaloPhil has the right solution for you.

:)
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

anarchist

  • Regular poster
  • ***
  • Karma: 5
  • Offline Offline
  • Gender: Male
  • Posts: 212
    • View Profile
Re: Exchange of images in the same scene
« Reply #5 on: February 05, 2011, 02:33:53 PM »

1. if you want to change the background image regardless of where you click, anarchists' way would be the way to go (although his code is wrong).
??? Where did I go wrong?
Logged

Azrael

  • Regular poster
  • ***
  • Karma: 9
  • Offline Offline
  • Gender: Male
  • Posts: 155
    • View Profile
    • Mad Orange
Re: Exchange of images in the same scene
« Reply #6 on: February 05, 2011, 02:57:16 PM »

It's SetSprite(), SetImage() is for window objects ;)
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: Exchange of images in the same scene
« Reply #7 on: February 05, 2011, 11:36:39 PM »

1. if you want to change the background image regardless of where you click, anarchists' way would be the way to go (although his code is wrong).
??? Where did I go wrong?


correct code would have been:

Code: WME Script
  1.  
  2. on "LeftClick"
  3. {
  4.     var door1 = Scene.GetNode("door1");
  5.     door1.SetSprite("path_to_image");
  6. }
  7.  
  8.  

or alternatively if the handler was on the sprite entity itself:

Code: WME Script
  1.  
  2. on "LeftClick"
  3. {
  4.     this.SetSprite("path_to_image");
  5. }
  6.  
  7.  

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

Page created in 0.044 seconds with 20 queries.