Ce sujet date de quelques années. Certains détails peuvent concerner une ancienne version de Visionaire Studio. Tutoriels actuels
La version gratuite permet jusqu’à 25 scènes par projet. Pour plus de scènes et pour vendre votre jeu, il vous faut une licence. Les lecteurs du forum obtiennent l’Indie Bundle à 15 % de réduction avec le code FORUM15 : 84,15 € au lieu de 99 €, valable jusqu’au 31/12/2026.Black Friday : l’Indie Bundle bénéficie de 30 % de réduction jusqu’au 01/12/2026, 69,30 € au lieu de 99 €. Le code BLACKFRIDAY est déjà appliqué.
Profiter de 15 % de réduction Essayer gratuitementlocal cloud = ActiveAnimations["cloud"]
cloud:to(10000, { AnimationCurrentPosition = {x = -1000, y = cloud.AnimationCurrentPosition.y} }, easeLinearInOut, true, false)Thank you, I got another question. I'd need a way to scale an object based on a variable value, how can I achieve it? Basically it for an health barA'llo,You should create the cloud as an animation as it's much easier to move than objects. Object movement is offset based whereas animations can be moved to absolute positions.There are also multiple methods for moving objects & animations, but the simplest method is the to() tweening function as you can specify the time it takes to get from the starting position to the target position as well as specify easing & make it loop &/or loop forwards then backwards (pendulum) when it gets to the target position.Here's a quick example of how you could have a cloud move from a starting position, to an end position, then loop from the start again...local cloud = ActiveAnimations["cloud"] cloud:to(10000, { AnimationCurrentPosition = {x = -1000, y = cloud.AnimationCurrentPosition.y} }, easeLinearInOut, true, false)In the example above we are moving a cloud from the starting position to -1000 pixels over 10000ms (10 seconds) with linear easing (default easing) & once it reaches the target position it will loop back to the starting position & make its way across the scene again.Other alternatives are to increment the position of the animation via an execute a script action part that you create inside of the animation frame. Another method would be to use a mainLoop event handler & increment/decrement the position via that.Quick note #1: you need to make sure you set the animation to loop infinitely & also the animation should be assigned as the default animation of the scene object you created the animation under.Quick note #2: if you want to get a bit more creative with sliding objects around scenes, then you should look into math.random or the random value action part as it will allow you to create more dynamic content. For example, you could change the target position or the amount of time in which it should take to get from the starting position to the target position.
graphics.addDrawFunc("draw()", 0)
function draw()
graphics.drawBox(200, 200, 300, 40, 0x0000ff, 1)
endgraphics.addDrawFunc("draw()", 1)function draw()
graphics.drawBox(x, y, w, h, color, alpha)
end</div>
if Values["MC_health"].Int == 100
then
graphics.addDrawFunc("draw()", 0)
function draw()
graphics.drawBox(200, 200, 300, 40, 0x0000ff, 1)
else
if Values["MC_health"].Int == 50
then
graphics.addDrawFunc("draw()", 0)
function draw()
graphics.drawBox(200, 200, 150, 40, 0x0000ff, 1)
end end
if Values["MC_health"].Int > 50 then
graphics.addDrawFunc("draw()", 0)
function draw()
graphics.drawBox(200, 200, 300, 40, 0x0000ff, 1)
end
elseif Values["MC_health"].Int > 0 and Values["MC_health"].Int <= 50 then
graphics.addDrawFunc("draw()", 0)
function draw()
graphics.drawBox(200, 200, 150, 40, 0x0000ff, 1)
end
endPerfect it works.captcha code? I don't have one on here. I think there may be one for members with less than x posts as a anti-spam preventative, but sure, I also wish the captcha would bugger off too - 2 step verification as well & anti-cheat in games.No, something more like this...if Values["MC_health"].Int > 50 then graphics.addDrawFunc("draw()", 0) function draw() graphics.drawBox(200, 200, 300, 40, 0x0000ff, 1) end elseif Values["MC_health"].Int > 0 and Values["MC_health"].Int <= 50 then graphics.addDrawFunc("draw()", 0) function draw() graphics.drawBox(200, 200, 150, 40, 0x0000ff, 1) end endbut that's not a very efficient solution. It would be better to use some math to calculate the health bar width based on the value.
I´m not sure about this but wouldn´t this register the draw function again and again? Since the draw function is called every frame this would get very expensive soon![]()
local health
graphics.addDrawFunc("draw()", 0)
function drawHealthBar()
health = (Values["MC_health"].Int / 100) * 300
-- + --
function draw() graphics.drawBox(200, 200, health, 40, 0x0000ff, 1) end
end
registerEventHandler("mainLoop", "drawHealthBar")Ce sujet est fermé, car personne n’a répondu depuis plus d’un an. N’hésitez pas à poser votre question dans un nouveau sujet.
Nouveau sujetDeponia, The Whispered World et plus de 160 autres jeux ont été créés avec Visionaire Studio. La version gratuite suffit jusqu’à 25 scènes. Pour plus de scènes, il existe Visionaire Studio PRO dès 75 €, et pour vendre votre jeu l’Indie Bundle à 99 €.
Jusqu’au 1er décembre : l’Indie Bundle à −30 % avec le code BLACKFRIDAY, 69,30 € au lieu de 99 €.