Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (degenerate_762, AbrahamR, AndrewAMD, ozgur), 667 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
click button not working #304823
01/11/10 01:26
01/11/10 01:26
Joined: Nov 2008
Posts: 109
J
JGGamer Offline OP
Member
JGGamer  Offline OP
Member
J

Joined: Nov 2008
Posts: 109
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:

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?

Re: click button not working [Re: JGGamer] #304923
01/11/10 21:37
01/11/10 21:37
Joined: Sep 2009
Posts: 993
Budapest
Aku_Aku Offline
User
Aku_Aku  Offline
User

Joined: Sep 2009
Posts: 993
Budapest
In your code:
Code:
if (event_type == EVENT_TOUCH)
	{
... here we are if EVENT_TOUCH happened
	}
	else


Every thing AFTER the else is related to those events that AREN'T EVENT_TOUCH. So...
The second if right next the else contains such condition that will never occur because implies the event_type == EVENT_TOUCH and that is exluded in this branch.
The skeleton of the if-then-else statememnt.
Code:
if (condittion)
{
codelines for the condition TRUE branch
}
else
{
codelines for the condition FALSE branch
}


Hope this help.

edit reason: bold doesnt work for me inside code tags.

Last edited by Aku_Aku; 01/11/10 21:39.
Re: click button not working [Re: Aku_Aku] #304950
01/12/10 02:55
01/12/10 02:55
Joined: Nov 2008
Posts: 109
J
JGGamer Offline OP
Member
JGGamer  Offline OP
Member
J

Joined: Nov 2008
Posts: 109
Well, you have pointed out a fact, but it hasn't helped me with my problem. Like I said, I tried everything I could think of, including not using 'else', and still it doesn't work.

Re: click button not working [Re: JGGamer] #305047
01/12/10 17:42
01/12/10 17:42
Joined: Sep 2009
Posts: 993
Budapest
Aku_Aku Offline
User
Aku_Aku  Offline
User

Joined: Sep 2009
Posts: 993
Budapest
Did you tried to use this:
Code:
else if (event_type == EVENT_CLICK)


instead if this:
Code:
else if (event_type == EVENT_TOUCH && event_type == EVENT_CLICK)


?

If not, do it...

Re: click button not working [Re: Aku_Aku] #305272
01/13/10 21:39
01/13/10 21:39
Joined: Nov 2008
Posts: 109
J
JGGamer Offline OP
Member
JGGamer  Offline OP
Member
J

Joined: Nov 2008
Posts: 109
I did.

Re: click button not working [Re: JGGamer] #305472
01/14/10 22:25
01/14/10 22:25
Joined: Sep 2009
Posts: 993
Budapest
Aku_Aku Offline
User
Aku_Aku  Offline
User

Joined: Sep 2009
Posts: 993
Budapest
Good

Re: click button not working [Re: Aku_Aku] #305479
01/15/10 00:18
01/15/10 00:18
Joined: Apr 2006
Posts: 737
Ottawa, Canada
O
Ottawa Offline
User
Ottawa  Offline
User
O

Joined: Apr 2006
Posts: 737
Ottawa, Canada
Hi!

Have you thought of using case
Separating the over and touched

if over on
case (1) and so on.

if clicked on
case (1) and so on.


Hope this helps!
Ottawa laugh

Ver 7.86.2 Pro and Lite-C
Re: click button not working [Re: Ottawa] #305650
01/16/10 01:52
01/16/10 01:52
Joined: Nov 2008
Posts: 109
J
JGGamer Offline OP
Member
JGGamer  Offline OP
Member
J

Joined: Nov 2008
Posts: 109
Aku Aku
No, it's nt good, because it didn't work.

Ottawa
I'll try that, thanks.

Re: click button not working [Re: JGGamer] #305676
01/16/10 13:47
01/16/10 13:47
Joined: Sep 2009
Posts: 993
Budapest
Aku_Aku Offline
User
Aku_Aku  Offline
User

Joined: Sep 2009
Posts: 993
Budapest
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_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);
		}
	}
}


I am curious, why doesn't work this code?
Perhaps i can help you, if you write here what happens...
Or both of we can learn something.

Re: click button not working [Re: Aku_Aku] #305756
01/17/10 01:30
01/17/10 01:30
Joined: Nov 2008
Posts: 109
J
JGGamer Offline OP
Member
JGGamer  Offline OP
Member
J

Joined: Nov 2008
Posts: 109
Your curious...??? I'm perplexed, puzzled..., you name it.
I can't write what happens, other than that the button doesn't animate when I click on it with the mouse. Like I said before, if I place the animation under EVENT_TOUCH, the button animates as soon as I move the mouse over it. That's strange to me. Thanks for your effort.

Page 1 of 2 1 2

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1