Events related to inventory system not working

Just started using Construct 2? Post your questions here

Post » Sat Apr 26, 2014 7:31 pm

Hello guys,

Once again I have hit a wall; I checked tutorial and previous posts in the forum and tried the solutions but it seems either I am doing something wrong (I bet I am!) or I am trying solutions not tailored for this problem.

I have a level with a button called Inventory; when I click this button it stops the game and the invisible layer items would pop up. Then the player would have the option to buy the upgrades in the inventory.
Image

The inventory itself is just a sprite except for the Buy and Back buttons they are all buttons. Anything else, is just 1 sprite collected in Photoshop.
Image

Now the logic I had done as in below in an Event Sheet called Inventory:
Image

and here is the code for the Back button:
Image

I even tried to reverse the code for the Back button; where I would do the Pick UID first then the mouse click... nothing, nada.

Then in the gameplay Event Sheet (the one used for this layout) I haded included as in below:
Image

I don't know what is wrong, but the game pauses OK, everything works until I try to click on any of the buttons. They don't respond at all.

At first I thought it was because I used a literal implementation of each button's UID, so I deleted the part where it says "Pick by object UID" (thinking that if I click on a certain button, most likely the event triggered knows which button is clicked so the action will take place according to the button clicked). It still didn't work. I tried another method I found here in the forums (I can't remember the details but it used a Foreach loop, but it didn't work either).

Any ideas how one can solve this?

Thank you very much in advance :)
B
19
S
7
Posts: 161
Reputation: 1,751

Post » Sat Apr 26, 2014 9:07 pm

You need to use the 'Button: On clicked' trigger with buttons. Not the Mouse click trigger.

Also when you have something like this:
Image


The first condition will pick the button you clicked. In the sub-event you have only that button picked, so the 'pick by UID' will only pick that same button if the UIDs match, otherwise it can't pick anything. And again in the next sub-event, there can only be one button picked at this point so no need for a loop.

If you have something picked already and you want to pick another instance in a sub-event then you need a 'System: Pick all' condition first.
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,650

Post » Tue Apr 29, 2014 7:58 am

That actually worked, thank you very much! :D
B
19
S
7
Posts: 161
Reputation: 1,751


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 6 guests