How can I make this work (instance variable) ?

Get help using Construct 2

Post » Thu Jul 21, 2016 2:28 pm

Hey. I am trying to change the portals from active to inactive. I am verifying this for "PortalEnterBox2" by pressing the "P" key but it doesn't work. What is happening is this:
If I set the instance variable "portalOn" to false to be the default on start of layout, if I press "P" it changes the state of the portal to active but when I press again "P" nothing happens.
If I set the instance variable "portalOn" to true to be the default on start of layout, if I press "P" nothing happens.
Please, look at the screenshot and tell me what I'm doing wrong. Thanks.

Link here https://www.dropbox.com/s/hua8wwgcdg0j1 ... m.jpg?dl=0
B
36
S
10
G
9
Posts: 212
Reputation: 6,945

Post » Thu Jul 21, 2016 2:32 pm

Don't check a condition then check for the inverse. Use 'Else'. The problem is you set it to one state, then immediately set it to the opposite state. 86/87 turn it off, then 88/89 checks if it is off, and turns it on again.
ImageImageImage
B
71
S
21
G
232
Posts: 3,696
Reputation: 129,868

Post » Thu Jul 21, 2016 3:56 pm

Thank you ! I've done what you told me and it works.
B
36
S
10
G
9
Posts: 212
Reputation: 6,945

Post » Sat Jul 23, 2016 2:13 pm

Hi @blackhornet. I need your help again :) , please.
The problem I have is where "state = 1" . I have several portals. What I am trying to do is when MovableObjects_Fam is overlapping PortalEnterBox_Button (nr=1), PortalEnterBox1 will activate, and it works. But for some reason PortalEnterBox_Button is not changing from frame 1 to 0 or vice versa.
If I have 2 or 3 portals and buttons in the scene only one of the buttons will change his frame.

Screenshot: https://www.dropbox.com/s/2byd7wo9fvhj7 ... 2.jpg?dl=0
B
36
S
10
G
9
Posts: 212
Reputation: 6,945

Post » Sat Jul 23, 2016 2:52 pm

I can't really see the issue from the screen shot. You'd have to post a CAPX.
ImageImageImage
B
71
S
21
G
232
Posts: 3,696
Reputation: 129,868

Post » Sun Jul 24, 2016 1:14 pm

I don't want to share the .capx , it's a big project I am working on for some time now... I will try other ways, thanks.
B
36
S
10
G
9
Posts: 212
Reputation: 6,945

Post » Sun Jul 24, 2016 1:58 pm

@anty21ro

If you want people to help you, extract only the events you show in the screenshots, and make a simple capx file with replaced images. Its easier when we have control over the capx project, instead of guessing whats wrong by looking.

I am also working on a portal game, but I havent started making code, just art assets for now.
B
10
S
3
G
1
Posts: 46
Reputation: 1,261

Post » Sun Jul 24, 2016 7:31 pm

Hei. I've made an example .capx. There are 3 portals. When Player touches the button it should turn from red to green (same for the portal that is related with), but it does only for one of the 3 portals.

https://www.dropbox.com/s/a6qv3uzabgf2t ... .capx?dl=0
B
36
S
10
G
9
Posts: 212
Reputation: 6,945

Post » Sun Jul 24, 2016 10:07 pm

The problem is you only pick the corresponding PortalButton with the overlap condition. The Else defaults to ALL PortalButtons.

www.blackhornettechnologies.com/Constru ... t_BHT.capx

Also, there is no reason to duplicate the code three times. This can be simplified by giving both objects the same ID, which you do already for PortalButton (nr), and then the one can pick the other when necessary.
ImageImageImage
B
71
S
21
G
232
Posts: 3,696
Reputation: 129,868

Post » Mon Jul 25, 2016 7:55 am

Thanks a lot blackhornet.
Does the "Browser Log in console: "NR=" " influences the picking in any way ?
B
36
S
10
G
9
Posts: 212
Reputation: 6,945

Next

Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, cb130felix, Kermad, nyuszi008, yiuyiu6666 and 6 guests