Solarus has a few built-in mechanisms, and you can customize things through the Lua API (http://www.solarus-games.org/doc/latest/lua_api.html).
For example, there is no built-in day/night system. But it is easy to create one. In this sample script, we will make a simple dark overlay on the map to make a night visual effect.
More generally, you can use the same code to show any kind of semi-transparent surface on the map, even a PNG image.
For more details, see the documentation of surfaces (http://www.solarus-games.org/doc/latest/lua_api_surface.html).
First, create a surface for your map, for example in map:on_started() in your map script:
function map:on_started()
self.night_overlay = sol.surface.create() -- Create an empty surface of the size of the screen.
self.night_overlay:set_opacity(192) -- Make it semi-transparent (0: transparent, 255: opaque).
self.night_overlay:fill_color({0, 0, 64}) -- Fill it with dark blue to obtain a night effect.
end
The night surface is initialized, we just have to draw it when the map is drawn:
function map:on_draw(destination_surface)
self.night_overlay:draw(destination_surface)
end
And voilĂ !
So this is the basic idea.
If you want more:
- (Easy) To make the opacity change with time, use a timer (http://www.solarus-games.org/doc/latest/lua_api_timer.html).
- (Easy) To show an image from an external file instead, replace sol.surface.create() by sol.surface.create("path/to/file.png").
- (Advanced) To make the image move when the player moves (like the lost woods overlay in ALTTP), there are two optional parameters x and y in map.night_overlay:draw(). How to determine appropriate x and y values is left as an exercise to the reader ;)
- (Advanced) To make the image move automatically (like clouds), create a movement (http://www.solarus-games.org/doc/latest/lua_api_movement.html) on your image.
- (Advanced) You can also combine the previous two remarks.
Is is also possible to have two overlays at the same time.
I have the forest overlay, but i want also the night overlay, mentioned above, on the same time.