0 Favourites

Get event by its ID

  • 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?

  • 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.

  • 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.

  • 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.

  • Ok, i suppose you really mean - how to get and control instances of an object - and not events or something 'advanced' like groups. <img src="smileys/smiley2.gif" border="0" align="middle">

    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. <img src="smileys/smiley2.gif" border="0" align="middle">

  • 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.

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • 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.

  • 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?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)