Noob Question

This forum is currently in read-only mode.
  • Hello. First post (obviously). I've been using GameMaker for some time and am now learning Construct because I like the flexibility with things such as particles, image distortion, etc. I also have some background in Python already, so it seemed like a logical extension. However, I've run into a rather simple problem. In the event editor I cannot seem to find any 'On Left Click' events. My goal in my test game is to destroy an object when I left click it. Fairly simple.. only I just can't seem to find where the event is at all.

    Thanks.

    EDIT: Nevermind, I solved this while randomly clicking around.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • [quote:35enhwic]EDIT: Nevermind, I solved this while randomly clicking around.

    I hope you solved it by discovering that you could add the Mouse & Keyboard object, and using it's On Mouse Button Clicked condition.

    If not, that's how you do it

  • [quote:1qee0mpu]EDIT: Nevermind, I solved this while randomly clicking around.

    I hope you solved it by discovering that you could add the Mouse & Keyboard object, and using it's On Mouse Button Clicked condition.

    If not, that's how you do it

    Yes, I did. But! But! I have another question. How can I stop the click from 'piercing' objects. In my game I am randomly spawning asteroids and if I click while one is ontop of the other it destroys both, whereas I'd prefer these to require separate clicks.

  • I only found one solution

    don't worry, most things in construct are easier to do than any other game making package

    this is just one of those things

    but anyway, the solution is here:

    click me!

    look at the cap first, before reading, or this will seem even more confusing

    make a global variable to track whether any asteroid has been destroyed by the current click

    you can make a global variable by making an action to Set a global variable (under system) or a condition to check a global variables value (also under system), when it asks you which variable you want, just click "add new"

    then "on left mouse button clicked"

    set the global value to zero. Zero will mean "no", because this is a new click, and no asteroids have been destroyed yet

    then a subevent, "for each object ordered"

    • this will do all your actions, once per object, and put the objects in the order you tell it

    make it FOR EACH "asteroid" ordered by asteroid.zindex - descending -

    this makes it so the object with the highest z index (in front of other objects) goes first

    then another subevent "is global variable" zero

    so if your global variable still equals zero, it will run the actions

    the actions will be to destroy the Asteroid, and then set the global variable to 1, so when the loop goes to the next asteroid, it won't won't get past the "is global variable" zero condition, and it won't get destroyed

  • Thanks. I'm still going over the logic. It is certainly a... bizarre solution... perhaps an idea for future updates, haha.

  • always> set pv 'z' to z index.

    add a "pick object with the highest (or lowest, i forget if the z index works by going higher or lower) variable" to the click condition. and it will destroy the object which is ontop.

  • oh yeah that works, too

    here's an example of that solution

    click me!

    that probably makes more sense to a normal person, too

    btw, I also forgot which one is topmost (highest or lowest)

  • A simpler solution that might work:

    + Mouse clicked

    + Asteroid is overlapping some object

    + Pick a random asteroid

    -> Destroy asteroid

    This way if you click and two asteroids are overlapping, it picks a random one and runs the actions on just that.

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