Problem with Repeating Code - UPDATED [may be bug]

Get help using Construct 2

Post » Tue Dec 18, 2012 1:01 am

I have been working to get this particular down light to turn on if the switch is clicked or if the mouse moves over it and to be off in any other situation (switch clicked to the off position *unlit* or mouse not hovering over the downlight).

However what is currently happening is as follows :

1 - Downlight starts off turned on and Light switch is lit up (due to global variable Light_Switch being set to 1 by default)


2 - Downlight turns on when turned off and the mouse moves over the down light but flicks off when the mouse is not over the down light

3 - Light turns off when the switch is clicked and the switch also stops being lit.

PROBLEM : when I click the light switch again... the down light does not come back on.

Only when I then move my cursor over the down light does it turn back on again and stay on. but for some reason it requires the mouse to move over the downlight sprite for it to update and realise that the variable has changed back to 1 and therefore should already be on permanently again.


CODE in QUESTION : below :

Jax2012-12-18 05:24:23
B
6
S
1
Posts: 72
Reputation: 723

Post » Tue Dec 18, 2012 1:11 am

Read the 3rd paragraph before reading this one
                                               V

I know what is happening , when you click with the mouse , you click on the two objects at once ... Try to re-group the two light buttons into 1 unique button with 2 animations !

In the catalogue group , I don't understand your events ... one is set to or block , try to tweak that ...Whiteclaws2012-12-18 01:11:28
B
35
S
16
G
16
Posts: 2,222
Reputation: 16,589

Post » Tue Dec 18, 2012 1:33 am

would it help if I were to upload the capx for you to see?

I'm not sure of exactly how I would go about putting both states of my light switch into a single animation. I know that for my top menu buttons, they are not done this way and they have no problems working.

I'll upload the capx for you, this will likely be the best way to figure out what is going on because to me, I think my code is problem free (a little bloated perhaps but I can't spot any errors I mean technically it should work)

The error is happening in the Catalogue Event Sheet

http://temp-share.com/show/KdPfm0yoh

That is a link to my capx
B
6
S
1
Posts: 72
Reputation: 723

Post » Tue Dec 18, 2012 1:45 am

Can't open the project , damn you , missing plugin message !
Try to set the first event in the catalogue group to not "or" ...
@Whiteclaws , if that doesn't work ...
B
35
S
16
G
16
Posts: 2,222
Reputation: 16,589

Post » Tue Dec 18, 2012 1:52 am

I've just got the http://www.scirra.com/FORUM/behavior-easetween_topic53288_page13.html

plugin and the

http://www.scirra.com/forum/behavior-moveto_topic44845.html

Moveto plugin from this page.
B
6
S
1
Posts: 72
Reputation: 723

Post » Tue Dec 18, 2012 2:02 am

I tried to remove the OR but by getting rid of the or from that statement, it does not function how it needs to operate.
B
6
S
1
Posts: 72
Reputation: 723

Post » Tue Dec 18, 2012 2:16 am

Fix'd it !
Told you it was in the "or"



Cheers !Whiteclaws2012-12-18 02:17:54
B
35
S
16
G
16
Posts: 2,222
Reputation: 16,589

Post » Tue Dec 18, 2012 3:03 am

please do tell me what the logic is behind why inverting this works but the way I had it would not as it makes no sense to me, both should technically work.
B
6
S
1
Posts: 72
Reputation: 723

Post » Tue Dec 18, 2012 3:07 am

Actually I just tried to invert the or like shown in your example but it does not work.


downlight_1 does not start visible like it should

and changing the light switch does not change the state of the down light either :sJax2012-12-18 04:43:06
B
6
S
1
Posts: 72
Reputation: 723

Post » Tue Dec 18, 2012 4:40 am

If anyone is able to help me with this please advise as I really need to try and have it working and as far as I can tell it's quickly becoming more of a bug than it is broken code as I can't see any logical reason why the light switch is not toggling downlight 1 off and on but only works when the layout first starts up.Jax2012-12-18 04:41:35
B
6
S
1
Posts: 72
Reputation: 723

Next

Return to How do I....?

Who is online

Users browsing this forum: claurent9, imothep85 and 27 guests