Get event by its ID

Get help using Construct 2

Post » Sun Mar 18, 2012 12:43 am

How can I get, from a group of events of the same type in a level, an event by its unique ID, so that only that event performs an action, for example, destroy, via the level code without affecting the rest of the
events of the same type?
B
3
Posts: 14
Reputation: 328

Post » Sun Mar 18, 2012 6:16 am

Only objects have a ID as far as I know. I think you could achieve what you want with the system command Set group active.

Put any events that you want to shut down inside a "group" in C2.

Set a system command "Set group active" : Activate - For On
                                        : Deactivate - For Off

Or you can do the same thing with variables but i personally find it easier with Group active.

If this makes no sense, check the manual - its not as hard to understand as you would think.

ImageImage
B
74
S
17
G
6
Posts: 1,039
Reputation: 10,605

Post » Sun Mar 18, 2012 9:18 am

That's a weird question, so I'm interested.
What do you call "events of the same type"
And can you give us a practical game situation where it would be usefull.

Anyway I think GenkiGenga's solution is probably what you are looking for. But just to be sure.
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Wed Mar 21, 2012 5:42 am

Suppose that you want a player to shoot a power. This power has a direction and speed according to where they place the mouse when they click the left button. How can you change the direction and speed of the new power without affecting the direction and speed of the other existing powers of the same type.
B
3
Posts: 14
Reputation: 328

Post » Wed Mar 21, 2012 9:56 am

Ok, i suppose you really mean - how to get and control instances of an object - and not events or something 'advanced' like groups.

link1 - manual - what is an object
link2 - manual (instance variables)
link3 - beginners guide
(link4 - forum post - homing missile)
(link5 - forum post - controlling AI)
If you post your capx maybe somebody will look at your individual problem and could help you. Joe72012-03-21 11:10:51
B
14
S
6
G
5
Posts: 173
Reputation: 4,742

Post » Thu Mar 22, 2012 1:17 am

How can I like, set instance variables to an object I just create via the level code? So that way, I can set him the speed and direction.
B
3
Posts: 14
Reputation: 328

Post » Thu Mar 22, 2012 1:41 am

Just do it in the same event you create the object.
Like this;

Action
    Create player at x,y
    Set instance variable "Health" to 100
    Set instance variable "Weapon" to 3

Doing this, you're only changing the variables of the instance you just created.
I think this is what you're getting at, hope it helps.
B
12
S
2
G
4
Posts: 44
Reputation: 2,389

Post » Thu Mar 22, 2012 10:37 pm

Note that I want to be able to control from the multiple sprites of the same type that are on the same level, to control the one i just created.
For example, I shoot a energy blast by clicking the mouse. The blast will move according to the location of the mouse.
But if I create a Blast sprite, and there's more than one Blast sprite in the level, and after the create action of the Blast sprite I put an action to set an instance variable of the Blast sprite I just created, the instance variable I am changing will be changed not only for the Blast sprite I just created, but for the other Blast sprites as well. How can I be able to avoid changing the existing Blast sprite variables by only changing the instance variables of the Blast sprite I just created?
B
3
Posts: 14
Reputation: 328


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 25 guests