How do I pick the right object?

0 favourites
  • 7 posts
From the Asset Store
Pick Up Items Sound effects for your game, Take them for a ride right now and you will worry no more.
  • Hi there,

    having some difficulties here...

    In my project a block with a random frame number is created every x seconds.

    When a player clicks one of the blocks, I have to know which block it was, maybe by using IID's?

    However, reading the manual, it says you should not rely on IID's, especially not when sprites are newly created and destroyed.

    I'm wondering which is the right track then...

    Array? Dictionary? IID's after all?

    If the 'problem' is not clear, I can create and post a simple capx to try to make things clear.

    Any help would be appreciated...

    Thanks in advance!

  • Your clicked event automatically picks the clicked block.

    e.g.

    Mouse: On Left button Clicked on Sprite -> Sprite: <do something>

    The 'Sprite: <do something>' is already the correct object for you.

    Or maybe you mean something deeper..

  • Hi Codah,

    thanks for your quick reply.

    Yes, I'm 'afraid' it goes a bit deeper

    I need to know the ID of each block since the blocks have bullet behaviour from left to right.

    The sooner the player clicks on the block, the more points he's awarded.

    Thinking about it, maybe I have to check the ID if the block AFTER the player has clicked it and only then apply actions to it...

    I'll test with this option, but should you have any suggestions, please feel free to post them

  • I still don't understand ... Just have an instance variable on each block, that should be enough to choose between them. But I'm really not sure, maybe you can post a sample capx.

  • I've been trying and testing but can't seem to get it together.

    It seems I'm just missing one step or simple thing...

    Hope you (or anyone else) can help me out...

    What's going on:

    at the top middle of the screen there's a textbox.

    On start of layout this textbox displays a random color (red, black or blue).

    Whenever a block with this color is clicked, it should disappear.

    That's all there is to it, except one way or another my brains are 'blocking'

  • :

    you have to set the Color instance variable matching the current animation frame. And then you test this instance variable against the color to pick.

    Have fun

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Damn moonworX!

    Life can be soooo simple....

    Thanks a whole lot for your fast and excellent help!

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