This thread is a few years old. Some details may refer to an earlier version of Visionaire Studio. Current tutorials
function test()
graphics.font = Fonts[6]
local txt = "Zeile1\nZeile2\nZeile3"
local dim = graphics.fontDimension(txt)
print(dim.x,dim.y)
endSorry, ich bin leider ein echter Lua-Dödel. Wie rufe ich die Funkton auf?Ich hab sie so eingebaut -> BildAber ich bekomme immer als Höhe 28 angezeigt (das entspricht meiner Fonthöhe von 25 + 3 Zeilenabstand. Bzw anderen einzeiligen Höhen, wenn andere Fonts angebe)Definiere ich txt = "Zeile1\nZeile2\nZeile3" ist die Anzeige 76 28bei txt = "Zeile1" bekomme ich 68 28Siehst du, was ich falsch mache?Edit: ah ok, aufrufen mit execute script "test(text)" aber gleiches Ergebnis
function test(text)
graphics.font = Fonts[6]
local dim = graphics.fontDimension(text)
print(dim.x,dim.y)
endfunction adaptedTextPosition(text)
-- show texts min 10 pixel inside the window
if text.Owner:getId().tableId == eCharacters then
-- setup the vars (savezone is 10 px around the spoken text)
local txt = text.CurrentText:gsub(";","\n") -- get the current active text and convert the line breaks
local dim = graphics.fontDimension(txt) -- calculate the textbox height/width depending on the text
local char = text.Owner -- get character and
local pos = char.Position -- his/her position
local leb -- left border of the text
local rib -- right border of the text
local char_size -- variable for the character size
local text_safezone -- Sets a distance realtive to the screen width
-- sets the value for the text safezone
text_safezone = game.WindowResolution.x / 50
-- sets char size to the size of the character that is talking
if text.Owner == Characters.Jasper then
char_size = 776
elseif text.Owner == Characters["Jasper (Tisch)"] then
char_size = 320
elseif text.Owner == Characters.Bauarbeiter then
if Characters.Bauarbeiter.Outfits == Characters.Bauarbeiter.Outfits.Standard then
char_size = 854
elseif Characters.Bauarbeiter.Outfits == Characters.Bauarbeiter.Outfits.Sitzend then
char_size = 548
end
elseif text.Owner == Characters.Ferdinand then
char_size = 590
end
-- set textbox position. Dont allow the textbox to be displayed out of the game window
rib = pos.x+(dim.x/2)+text_safezone
leb = pos.x-(dim.x/2)-text_safezone
if leb game.WindowResolution.x then
pos.x = pos.x - (rib - game.WindowResolution.x)
else
end
-- position on y-axis needs adjustments depending on actual size in px
pos.y = pos.y-(char.Size * char_size / 100)-dim.y-5 --set it 20px higher than the character size
if pos.y <= 0 then pos.y=0 end
text.Position = pos -- set text position
return true
end
return false
end
registerHookFunction("setTextPosition", "adaptedTextPosition")
print(graphics.getAnimationSize(game.CurrentCharacter).y) pos.y = pos.y-(char.Size * graphics.getAnimationSize(char).y / 100)-dim.y-20 This thread is closed because nobody has replied for more than a year. Feel free to ask your question in a new thread.
New threadDeponia, The Whispered World and more than 160 other games were made with Visionaire Studio. The free version covers up to 25 scenes. For more scenes there is Visionaire Studio PRO from €75, and to sell your game the Indie Bundle for €99.
Through December 1: all licenses 30% off, for example the Indie Bundle for €69.30 instead of €99. Applied automatically at checkout.