How do I get a text pop up to display the correct text

Just started using Construct 2? Post your questions here

Post » Sun Aug 14, 2016 7:51 pm

Hey all! Lost all my post info again as usual, I'll make this quick! Capx and gif included!

My Metroid style pause-wait-unpause effect for when the player acquires a new item isn't' working correctly. The issue is the way the text is being displaying. If the player collects the items in any order, the text pop up will only display the text info for the first gun. If the player collects the items in order (from A - H), the dialogue pop ups all show the correct information for the appropriate item.

Can anyone help me with this? I previously had this "inventory" set up as an array but I was having the exact issue. I thought this "no-array" system would fix the problem still persists. I'm thinking its an issue with the function?

One more thing, can anyone tell me why some of my items are displaying blank on the inventory slot? Because they shouldn't. There are no blank images in the inv slot animations. That's another issue I'm slowly working through too. Thanks all!

https://www.dropbox.com/s/kgafz6cfh3fuz ... .capx?dl=0
Image
Image
B
30
S
15
G
22
Posts: 183
Reputation: 14,221

Post » Mon Aug 15, 2016 6:17 pm

Besides that it is to much code for only 'that' ....

Your problem are the origins in the animation frames. They are way out of center, actual showing the graphic content out of the viewport.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Mon Aug 15, 2016 9:34 pm

@99Instances2Go Thanks again for your help! Can't believe I let the origins slip like that. That part is fixed. Any idea how to get the text to display according the the pick up acquired now?

Besides that it is to much code for only 'that' ....


Lol! Yeah I know, my code is shameful!

I do have a few reasons for that though. I had the idea of having the inventory slots arranged in a cool way in the UI. I thought it would just be infinitely easier to place them manually. I had an array based system before that semi-worked but had the same problems I was having before 99Instances help. Now the array inventory system is partly working too. I'm debating whether to have "flashier" menu or just a row of 8 or 2 rows of 4 items at the bottom of the menu. Here's the code to my array ( and my imagined HUD for fun).

Image
Image

Regardless of what system I go for, both the no-array and array system are playing the text incorrectly if the player picks up the items in any order.
B
30
S
15
G
22
Posts: 183
Reputation: 14,221

Post » Tue Aug 16, 2016 11:48 am

1/. The function had no idea wich object to perform its action on, because you did not pick one. And 2/. All the other events had the same problem.

You gots to learn how to pick objects, what the SOL (Selected Object List) stands for, and how to filter it with conditions.

https://www.dropbox.com/s/2oofikpuwzezh ... .capx?dl=0

Look at event 5. The 'on collision' auto picks 2 objects. The playerbox & obj_weaponItems where the playerbox collided with. Now the SOL conatains those two objects. Meaning, we still need to add the right obj_slots to the SOL. That is wat the 'pick by comparisation' does.

At this moment the SOL contains the playerbox, the right obj_weaponItems & the right obj_slots. Any action adressed to any of those objects in that event will only adress THOSE objects that are in the SOL. And that is basecaly how c2 works.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Fri Aug 19, 2016 6:15 am

@99Instances2Go Wow! I don't think I would have ever figured this one out by myself! Thanks so much! It's a little more clear to me know. I'll need to experiment some more and actually try these series of events together in some other form to fully grasp the concept but this seems really important. Thanks for simplifying the code for me too! It's difference is crazy.

I have a quick question. I'm sorry if this is a dumb question but why are those sub events empty? I find myself sometimes intuitively knowing I should use blank sub events in certain areas and other times I'll just try every possible combination of events I can think of to get something to work. I feel like I'm stumbling around blindly sometimes creating happy accidents because I'm lucky.
B
30
S
15
G
22
Posts: 183
Reputation: 14,221

Post » Fri Aug 19, 2016 4:00 pm

Events are easy to colapse that way. For me that is easyer to read the code, as easy as i read my morning paper. And it easyer to drag them arround.

But. A little warning. If you read the 'optimalisation' articles in the manual, there are words against using empty sub events this way. I never noticed any difference in performance, so i keep using them. Just able to wrap my mind arround things is for me as importand as performance.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Fri Aug 19, 2016 8:59 pm

I'm looking at your demo and the actual text that appears for each item seems to be defined by this variable:

Code: Select all
obj_weaponItems.dialogue


But I'm not seeing where the instance variables are set. Please help?
B
4
Posts: 1
Reputation: 206

Post » Fri Sep 16, 2016 2:56 am

If you have each pickup item be a different animation or frame of the same object, you can give it an instance variable and fill it with the object's name. Then, set a global variable to that instance variable's value before you call the function.
Eh, Steve!
B
115
S
54
G
13
Posts: 113
Reputation: 16,151

Post » Mon Sep 19, 2016 9:07 am

@goodwin88 What calebbennetts said. I was trying to figure out a way to create a simple inventory without an array and found this capx tutorial on the tutorials page.

https://www.dropbox.com/s/twzg0hlwlnbv5 ... .capx?dl=0

My system is basically inspired by that one. It uses "I" and the instance variable of the sprite to set the the correct animation frame (correct weapon item).
B
30
S
15
G
22
Posts: 183
Reputation: 14,221


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 3 guests