How to gradually present a "VICTORY" message ? (or "DEFEAT", etc)

Hello,

when the warrior finishes the level I want to present a VICTORY graphic in the middle of the screen.
It needs to slowly appear, either by :

  1. Opacity (alpha from 0.0 --> 1.0)

  2. Size (from miniscule —> to normal size)

  3. Or preferably both.

I had done [2] before in a smoke effect (the puffs started out small and grew in size while they moved up).
I do not remember exactly how, but I think I changed .scale property (or something like this) via Python.

Number [1] (alpha channel) = I have no idea how to do …

Any ideas ? A rough suggestion will be fine, I can take it from there.

Thanks !

Dimitris

animate the alpha on object color , remember to set object color in the options on you material

Are you familiar with Blender’s keyframe animation system? This would work well for option 2. As for option 1, edderkop’s got the right idea.

Oh, you are right! Yes I know about the animation system. Dumb question, thanks for the reply !

Size (from miniscule —> to normal size)

  • here is the solution for this issue

import bge

cont = bge.logic.getCurrentController()
own = cont.owner

anykey = cont.sensors['anykey01']

scene01 = cont.actuators['scene01']
scene02 = cont.actuators['scene02']

speed = own["speed"]
scale = own["scale"]

if anykey.positive and scale > 0.8:
    own["play"] = False 

if own["play"] == True:
    if scale <= 0.8:
        own["scale"] += speed
else:
    if scale >= 0:
        own["scale"] -= speed
    
own.localScale = (scale, scale, scale)

if scale < 0:
    cont.activate(scene01)
    cont.activate(scene02)

  • here is an example - victory_test01.blend (552 KB) (of course, this file is a free extended help on BGE :cool:)

p.s. move to the green cube :yes:

Thanks, that worked!

I was trying to animate Alpha in Material or Texture, but it does not work for some reason. But your suggestion does work fine.

Nick Mancul,
And the Python code with scaling works too!

Thanks guys!

Properties panel->Object Tab->Display->Object color. You need to tick the “object color” checkbox in your material options for this to work. This also enables you to manipulate the attribute through python.

obj.color = [R, G, B, A]
obj.color.x, obj.color.y, obj.color.z, obj.color.w = red, green, blue, alpha

quickedit: you can also mess around with color values without checking the object color thingie for the material, thing is changes won’t be visible.

Yes you are right, it works in animation (click play button in the timeline window), but not in the game (press P button).
But now that I think about it, it is better this way. It is best to animate the Object, instead of the Material. Because the Material animation
will force all objects using it to behave the same way –> not flexible.

There is a variant with transparency:

import bge

cont = bge.logic.getCurrentController()
own = cont.owner

anykey = cont.sensors['anykey01']

scene01 = cont.actuators['scene01']
scene02 = cont.actuators['scene02']

speed = own["speed"]
colour = own["colour"]

if anykey.positive and colour >= 1.0:
    own["play"] = False 

if own["play"] == True:
    if colour <= 1.0:
        own["colour"] += speed
else:
    if colour >= 0:
        own["colour"] -= speed
    
own.color[3] = colour

if colour < 0:
    cont.activate(scene01)
    cont.activate(scene02)

victory_test02.blend (543 KB) of course, of course, this file is a free extended help on BGE :cool: - with scripts it’s easier to work
I hope this helps you …

Are the issues is solved?

Wow this is awesome. So colour[3] is the alpha channel and you simply assign it values ?
Could not get better than this ! :slight_smile:
Meanwhile I have made the Victory message with animating the Object Color as stated in previous messages.
It is a simple message so no big requirements there (It does not even have a script, only logic blocks)

HOWEVER, this solution has much potential and I will definitely use it for particles flying in the air
(for example when two swords collide, spawn tiny bright cubes that slowly shrink and disappear –> sparks)

Thanks a lot, this has many many uses, will definitely use it.

  • well, no problem, always happy to help.