Creating Static main menu like in TR1‐3 - Tomb-Raider-Level-Editor/Tutorials GitHub Wiki
Since Tomb Engine 1.2 has released, you are now able to display sprite objects, which also come with infinite possibilities. One of them is being able to make a static main menu screen like in TR1-3.
First of all, you need to create an empty title level (if you have not) just put 1 small room with pitch black ambience room.
Then, you need a image as a sprite in your wad, I chose this image with a 1920x1080 size:
Now you need some lua magic for your title.lua:
-- Title script file
local Title_image = DisplaySprite(TEN.Objects.ObjID.DEFAULT_SPRITES, 34, Vec2(50,50), 0, Vec2(100,100), Color(255,255,255))
LevelFuncs.OnLoad = function() end
LevelFuncs.OnSave = function() end
LevelFuncs.OnEnd = function() end
LevelFuncs.OnStart = function() end
LevelFuncs.OnControlPhase = function(dt)
Title_image:Draw(0, View.AlignMode.CENTER, View.ScaleMode.FILL, Effects.BlendID.ALPHABLEND)
end
The variable contains a display sprite object which passes in the following:
- uses the objID of DEFAULT_SPRITES
- Uses the ID of 34 from DEFAULT_SPRITES
- position of 50, 50 (x,y respectively in percent)
- rotation of 0 (since we don't want to rotate the image really)
- scale of 100, 100 (x,y respectively in percent) to fill the whole screen area
- and default colour of 255,255,255
Now in order to draw the actual image, we need to call the Draw function on the variable (since it contains Display Sprite, we can intuitively call the Draw function) which takes 3 parameters:
- Priority (which is 0 because we don't have other sprites on screen so we make it to be the highest priority)
- alignMode of FILL to fill the entire screen
- blendMode to specify the blending of the image.
The final results:
With this in mind you can also do other fancy stuff:
- creating 3 different sprites, and have them fading in/out to make a slide show
- make an animated image sequence to give it a more "cartoonish" look by inserting each sequence of image in different IDs and triggering them 1-by-1 with a timer
- and etc!
Make sure you compile the title level with the wad that sprite is present.
Happy building and coding 🙂