Hello
I’m trying to do one game (I’m an absolute beginner) and I want that using a python script some elements changes his colour, play a sound and finally return to his original colour, I get that the objects changes his colous as I want but I have problems to make that blender get a delay after change the colour, somebody can give me a tip? At this moment I have this code:
import bge
import random
from bge import logic
from bge import constraints
objects = logic.getCurrentScene().objects
global tiradas
global turno
turno = 0
tiradas = []
nivel = 4
i = 0
object_1 = objects["blue"]
object_2 = objects["red"]
object_3 = objects["yellow"]
object_4 = objects["green"]
for i in range(nivel):
val = random.randint(1, 4)
tiradas.append(val);
if val == 1:
object_1.color = (0,0,1,1)
object_1.color = (0,0,0.75,1)
if val == 2:
object_2.color = (1,0,0,1)
object_2.color = (0.75,0,0,1)
if val == 3:
object_3.color = (1,1,0,1)
object_3.color = (0.75,0.75,0,1)
if val == 4:
object_4.color = (0,1,0,1)
object_4.color = (0,0.75,0,1)
I think that is just add some code between for example
object_4.color = (0,1,0,1)
object_4.color = (0,0.75,0,1)
but I didn’t found how to do that. Also if could help me to add the sound I will be very grateful, I think that this can be done using an actuator and I have they linked to the “object_1” etc but I don’t now how can I get the actuator with python, I think that to load the actuator is with this:
actuator = co.getActuator("actuatorname")
# Activate an actuator
GameLogic.addActiveActuator(actuator, True)
but I’m not sure how can I get the controller for an object using the code that I have, maybe with something like:
object_4.getCotroller("controllername")
???.
Thank you.
Regards.