Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

RenJS

HTML5 Visual Novel creation made easy and free · By lunafromthemoon

AMBIENT command

A topic by goliard created Jul 10, 2019 Views: 249 Replies: 5
Viewing posts 1 to 6

Hello,

I have a problem using the AMBIENT command. I have a scene called "awaken".
This works fine:

awaken:
  - show frame04: WITH FUSION
  - text: When I wake up, if I'm lucky, there'll be nothing to worry about except the snowflakes drifting through the holes in my tent.
  - scene: reflection

But when I insert the AMBIENT command, the program locks up:

  awaken:
    - show frame04: WITH FUSION
    - ambient snow:
      param1: snowflakes
    - text: When I wake up, if I'm lucky, there'll be nothing to worry about except the snowflakes drifting through the holes in my tent.
    - ambient: CLEAR
    - scene: reflection

   (- ambient CLEAR: doesn't work either)

  This seems a very straightforward command. Am I doing something wrong?

  John

Developer

Hello John, there might be a few issues here:

The ambient "snow", did you code it yourself? The one that comes with the Tutorial is called "SNOW" in caps, and doesn't take any params. If you're trying to call this one, you'll need to load the assets in the setup file:

extra:
  spritesheets:
    snowflakes: assets/ambient/snowflakes.png 17 17
    snowflakes_large: assets/ambient/snowflakes_large.png 64 64

And then call it in the story like this:

- ambient SNOW:
- other stuff
- ambient CLEAR:

Remember the name of the ambient should be before the ":", including CLEAR.

Hope it helps!

Luna

That definitely helps! How do I use the different snowflake spritesheets then? The documentation wasn't clear about any of this. I'll try that straight away -- thanks for the quick response!

I have another question. Is it possible to get the snow to appear behind characters and objects, so it is just in front of the background?

Developer

Hello, to change the spritesheets of the snowflakes you just need to change the files in the setup:

extra:
  spritesheets:
    snowflakes: assets/ambient/snowflakes.png 17 17
    snowflakes_large: assets/ambient/snowflakes_large.png 64 64

By changing the file names and frame size to the spritesheets you want, but keeping the keywords "snowflakes" and "snowflakes_large", you can use your own things.

If what you want to do is having more than one kind of "snow", and select it with parameters during the story, that would be something different, and you would need to code your own function (though it shouldn't be too hard if you base it on the current SNOW code).

For your second question, this is more tricky. It has to do with the order in which we add the display objects with Phaser. Since the snow emitters are created in the moment you call the ambient, it's on top of everything, including background, characters, etc. Phaser has groups of display objects, and in RenJS we have different groups to simulate layers, this layers are, from bottom to top:

  1. backgroundSprites
  2. behindCharacterSprites
  3. characterSprites
  4. cgsSprites
  5. GUI

The emitters, right now, are created outside of all this groups, so they are displayed on top of the GUI, if we want them behind the characters, then we have to add them to the group behindCharacterSprites.

In the ambient file, the SNOW, RAIN and SAKURA ambients use a helper function to create the emitters (it's very close to the top of the file, and it's called addEmiter). There, we create an emitter and put it to work. what you need to do is add it to the group, like this (second line):

var emitter = game.add.emitter(game.world.centerX, -32, options.maxParticles);
RenJS.storyManager.behindCharactersSprites.add(emitter);
emitter.width = game.world.width * 1.5;
The ambients RAIN and SAKURA will be shown behind the characters as well, but maybe it's ok for you.

That's fine, thank you so much!