I don't get it. Why doesn't this work?
I've tried everthing I could think of and I can get the left mouse click on the button to work. Here is my code:
function mouse_event()
{
if (event_type == EVENT_TOUCH)
{ // if the model was touched with the mouse
set(my,BRIGHT|UNLIT);
my.ambient = 20; // make it look bright
my.lightrange = 80; // generate light on a radius of 'x' quants!
}
else if (event_type == EVENT_TOUCH && event_type == EVENT_CLICK)
{ // if the model was clicked with the mouse
my.ambient = 0; // make it look bright
my.lightrange = 0; // generate light on a radius of 'x' quants!
while (my.frame < 20)
{
my.frame += 1 * time_step;
if (my.frame >= 20) {my.frame = 20;}
wait(1);
}
}
else if (event_type == EVENT_RELEASE)
{ // if the mouse was moved away from it
my.ambient = -50; // then restore its initial ambient value (zero)
my.lightrange = 0; // and stop it from generating light around it
while (my.frame > 0)
{
my.frame -= 1 * time_step;
if (my.frame <= 0) {my.frame = 0;}
wait(1);
}
}
}
action nameAction()
{
my.ambient = -75;
my.pan = 50;
//my.roll = 75;
my.y = 35;
// make the model sensitive to mouse touching and releasing
my.emask |= (ENABLE_TOUCH | ENABLE_RELEASE | EVENT_CLICK);
// run function mouse_event when the model is touched or released
my.event = mouse_event;
}
The button is supposed to animate when I left click with the mouse, but it doesn't.
If I place the code...
while (my.frame < 20)
{
my.frame += 1 * time_step;
if (my.frame >= 20) {my.frame = 20;}
wait(1);
}...under EVENT_TOUCH, the button animates. Why doesn't it animate under EVENT_CLICK?
I even tried using: if (mouse_left) which doesn't work either.
Can someone help me with this please?