Pick Instance

Get help using Construct 2

Post » Tue Jan 15, 2013 11:44 pm

Hey guys & gals,

Running into an issue with instances. Trying to wrap my head around the use of them, and began to try and make use of them within my project to increase the functionality of some of my mechanics.

What I have going on is this:
Player has to collect 5 hearts. On each collision with 1 of 5 hearts the heart becomes invisible and adds a visible heart to the "heart hud" area. This is working great. When I collide with an enemy the last heart collected reappears and the last "hud heart" is supposed to be removed as well. It works for the first 2 hearts, but then gets all crazy when you go beyond 2 or continually engage with an enemy. I have included a link to my .capx file. If anyone could help out and take a look at what I got and let me know if I'm handling this correctly that would be great.

.capx file

Link to actual game play issue : http://www.facecjf.com/EmoGuy23/

Thanks
Chris
Image Image Image
B
60
S
19
G
5
Posts: 325
Reputation: 7,369

Post » Wed Jan 16, 2013 2:00 am

Could you explain more by getting crazy ?
BTW , Checking out your capx right now , and I'm not seeing an issue ?
Also , I'm not liking the way you are picking your instances


Whiteclaws2013-01-16 02:17:46
B
35
S
16
G
16
Posts: 2,222
Reputation: 16,589

Post » Wed Jan 16, 2013 2:31 am

Thank you for a quick response!

I apologize for the wrong choice of words. What I meant by "getting crazy" is that the small hud hearts don't re-appear in the correct order of which they where taken away. (or set invisible)

Is there a better way to pick them? I'm a noob, and try to only ask questions when I truly can't figure it out myself. Which is rare...

When I think about it more, ironically I feel I'm over thinking it. I should just set an instance variable on the player that denotes the collection of the heart on collision, and a variable on the small heart for display in the hud.. If that makes any sense.
Image Image Image
B
60
S
19
G
5
Posts: 325
Reputation: 7,369

Post » Wed Jan 16, 2013 2:44 am

I am a noob too so this may be incorrect. My idea would be to create a graphic of all five hearts together and have an animation (just one frame) of each that would display so animation "Zero" would be all grey hearts, then "One Heart" would be the animation with one heart there and so on.

Then in your events make a simple event to set your heart HUD to the correct animation based on how many hearts (your global heart counting variable, either the large or the small heart, i am not certain) the character currently has.

System compare variable if numberofhearts = 0
- set animation to "Zero"

If this is not what you're looking for the other advice I can offer is create a text object on your HUD layer and every tick set the text to display your variables (say set text to "Hearts: " & yourheartvariable) - this is for easier debugging while testing your game.
B
14
S
6
G
2
Posts: 136
Reputation: 3,210

Post » Wed Jan 16, 2013 2:56 am

Oh I see , Seriously I don't like the way you pick your instances ...
Oh Well , Can't help you right now , I'm too sleepy , I'll give a response tommorow !
B
35
S
16
G
16
Posts: 2,222
Reputation: 16,589

Post » Wed Jan 16, 2013 3:01 am

@Wretchedshark That's a great and simple solution for the hud. Like I've suspected, I've been over thinking this..

Thank you for your advise! I forget about viewing text and see what variables are being triggered.

Image Image Image
B
60
S
19
G
5
Posts: 325
Reputation: 7,369

Post » Wed Jan 16, 2013 3:03 am

Thanks @Whiteclaws! I'm looking more into picking. I think I know what you are talking about. goodnight
Image Image Image
B
60
S
19
G
5
Posts: 325
Reputation: 7,369

Post » Wed Jan 16, 2013 3:09 am

I've made this example for a similar question a few days ago.

You need to adapt to your own capx but that's a possible implementation.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,795

Post » Wed Jan 16, 2013 3:58 am

@Kyatric Thank you

I do not understand
AmmoDisplay : Pick instance with UID int(dicAmmo.Get("Ammo" & Ammo))

Is that basically calling on the last AmmoDisplay.UID you stored in the dictionary and destroying it?

I only ask cause I want to understand. I did't think to use a dictionary.

Thanks!
Image Image Image
B
60
S
19
G
5
Posts: 325
Reputation: 7,369

Post » Wed Jan 16, 2013 4:05 am

You got it right.

The condition "Pick by UID" does the picking. The actions then does the logic (in that case indeed, destroying the picked instance).

In the game you want to make, instead of destroying you'll rather want to set the sprite invisible (as in your HUD the number of elements will be fixed and always appearing at the same position, so spawn them on start of layout and use the dictionary to keep the UID of each HUD instance you need to change the state during gameplay.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,795

Next

Return to How do I....?

Who is online

Users browsing this forum: randomly and 21 guests