Targetting specific instances of an object

For questions about using Classic.

Post » Sat Jan 03, 2009 5:17 pm

Hi,
I'm currently making a 2D platformer project (aided massively by the wonderful tutorial by Deadeye) and being very new to construct, I don't understand how to solve a problem in my program:

In the game, you collect crystals (in the typically clichd manner), and I have an event wherein collision between the player and Crystal causes crystal to become invisible, and the HUD count of crystals to increase by one.
However, ALL instances of crystal disappear when this event is triggered.

How do I make just the specific instance of crystal disappear/cease to exist, instead of all instances?
B
1
G
4
Posts: 2
Reputation: 1,029

Post » Sat Jan 03, 2009 5:20 pm

Instances of objects are 'picked' automatically by the conditions you have in events, if that makes sense.

If you had a condition saying:

Private variable 'health' of enemy is equal to 100, then any actions would only run on enemies with health of 100.

If you have an event which says:

Hero collides with crystal

Then the only crystal that should be picked is the one involved in the collision. Could you post your .cap file or a screenshot of the event so we can see how it's set up? It's quite possibly an error in the event.
B
3
S
2
G
5
Posts: 1,777
Reputation: 5,529

Post » Sat Jan 03, 2009 5:25 pm

Oh boy is there egg on my face.
On further investigation, I've found that every time I've tested the program, I've been grabbing the first crystal, but on jumping over it, it turns out that the others are invisible BEFORE event.

This is because I have put on them on a different layer.

erm. Sorry, and thanks for your quick reply :)
B
1
G
4
Posts: 2
Reputation: 1,029

Post » Sat Jan 03, 2009 6:56 pm

I have a question regarding targeting instances..

What if the instance you are choosing isn't part of the event.
Say you have 5 balls, you want the second ball to do something everytime.

So your event would be [Always], now how do you do it so that only the second instance of the ball object is affected.
you use Ball in the Always event whereas the event didn't use any condition or event that could pick a specific instance..
B
16
S
10
G
5
Posts: 255
Reputation: 3,934

Post » Sat Jan 03, 2009 11:55 pm

[quote="hero_bash":18c4m1lm]What if the instance you are choosing isn't part of the event.
Say you have 5 balls, you want the second ball to do something everytime.

So your event would be [Always], now how do you do it so that only the second instance of the ball object is affected.
you use Ball in the Always event whereas the event didn't use any condition or event that could pick a specific instance..[/quote:18c4m1lm]

You can't, simple as that. If you want only a specific instance of an object to do something, you have to define how to pick that instance in a condition.

So for your five balls you could number them 1 through 5, then in your condition do "+ballSprite.Value('mynum') is equal to 2" to pick the second one. If your instances can't be picked by built-in criteria like "is overlapping" then you have to make your own way of picking.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest