Show Scene
Change the background

Description

1
'show scene <resource> [with [animations] [classes] [properties]]'
Copied!
The scene action will change the background and clear the screen, removing all characters, images and text currently displayed.
Action ID: Scene
Reversible: Yes
Requires User Interaction: No

Parameters

Name
Type
Description
resource
string
The resource to use as the background for the scene. This resource may be one of the following:
  • Scene ID: The ID of a scene asset previously defined.
  • CSS Property: Any valid non-spaced value for the background CSS property.
animations
string
Optional. A list of comma separated animation names with which the scene will be shown.
classes
string
Optional. A list of comma separated CSS class names that will be added to the background element. You can create custom classes on your CSS and add them to your background dynamically using this list.
properties
string
Optional. A list of comma separated properties with their respective value.

Properties

The following is a comprehensive list of the properties available for you to modify certain behaviors of the scene action.
Property Name
Type
Description
duration
string
The duration for the animations used. The value for this property must be a non-spaced valid value for the animation-duration CSS property.

Using an image as the background

The most common case of
If you want to use an image for the background, remember you first have to declare your image assets and place all your files under the assets/scenes/ directory.
Script
Scenes Assets
1
monogatari.script ({
2
'Start': [
3
'show scene mountain'
4
'end'
5
]
6
});
Copied!
1
monogatari.assets ('scenes', {
2
'mountain': 'mountain.png',
3
'sea': 'sea.png'
4
});
Copied!

Using CSS properties as the background

If you'll use CSS to set a custom background, you can use any valid non-spaced value for the background-image or background-color CSS properties. Using CSS is perfect for when you want your background to be a solid color. Here are some valid statements:
1
monogatari.script ({
2
'Start': [
3
'show scene #fff'
4
'show scene rgb(0, 0, 0)'
5
'show scene url("assets/scenes/mountain.png")'
6
'end'
7
]
8
});
Copied!

Using Animations

Monogatari comes with some built-in animations ready for you to use, you can see the list of animations and visualize them here. Using animations is as simple as indicating their name!
Script
Scenes Assets
1
monogatari.script ({
2
'Start': [
3
'show scene sea with fadeIn'
4
'end'
5
]
6
});
Copied!
1
monogatari.assets ('scenes', {
2
'mountain': 'mountain.png',
3
'sea': 'sea.png'
4
});
Copied!

Modifying an animation duration

The following will set the background to a solid color using a CSS value and modify the duration of the fadeIn animation to 20 seconds.
1
monogatari.script ({
2
'Start': [
3
'show scene #424242 with fadeIn duration 20s'
4
'end'
5
]
6
});
Copied!

Creating a custom animation

You can also use CSS to create your own animations, you'll have to apply them to a CSS class and then use the scene statement as follows:
For example, note the following CSS code creating a simple Ken Burn Animation:
Script
Scenes Assets
CSS
1
monogatari.script ({
2
'Start': [
3
'show scene mountain with ken-burn'
4
'end'
5
]
6
});
Copied!
1
monogatari.assets ('scenes', {
2
'mountain': 'mountain.png',
3
'sea': 'sea.png'
4
});
Copied!
1
.ken-burn {
2
animation-name: ken-burns; /* Name of the animation to use */
3
animation-duration: 30s;
4
animation-iteration-count: infinite; /* 1 if it should only move once */
5
animation-timing-function: ease;
6
animation-fill-mode: forwards;
7
animation-delay: 0s;
8
-moz-transition: ease 1s all;
9
-o-transition: ease 1s all;
10
-webkit-transition: ease 1s all;
11
transition: ease 1s all;
12
}
13
14
@keyframes ken-burns {
15
0% {
16
transform: translateX(0);
17
}
18
50% {
19
transform: translateX(-500px);
20
}
21
100% {
22
transform: translateX(0px);
23
}
24
}
Copied!
Last modified 1yr ago