Wintermute Engine Forum

Wintermute Engine => Technical forum => Topic started by: lfkk77 on December 14, 2010, 09:26:36 PM

Title: Exchange of images in the same scene
Post by: lfkk77 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
Title: Re: Exchange of images in the same scene
Post by: anarchist 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);
}
Title: Re: Exchange of images in the same scene
Post by: Andrej (Blue Arc) 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.

Title: Re: Exchange of images in the same scene
Post by: BuffaloPhil 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. 
Title: Re: Exchange of images in the same scene
Post by: metamorphium 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.

:)
Title: Re: Exchange of images in the same scene
Post by: anarchist 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?
Title: Re: Exchange of images in the same scene
Post by: Azrael on February 05, 2011, 02:57:16 PM
It's SetSprite(), SetImage() is for window objects ;)
Title: Re: Exchange of images in the same scene
Post by: metamorphium 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.