mkea's Recent Forum Activity

  • korbaach Ahhh! I'd tried something similar, but was inverting "sprite is onscreen" instead of using "else", which didn't work--now it works! Thank you!

    Related question: if I have two toggle buttons triggering create/destroy for two different sprites, can I keep sprite1 from being created if sprite2 already exists, and vice versa?

    For example:

    sprite1 is created

    sprite2 cannot be created until sprite1 is destroyed

    if sprite2 is then created, sprite1 cannot be re-created until sprite2 is destroyed, etc, etc.

    I haven't quite hit on the right combination to get this working...I can get it to work for one create/destroy round, or for one sprite, but not both sprites for numerous repetitions. Will keep reading and experimenting.

  • I'm doing it for several objects, but each object has its own "toggle" button. Right now what I have is:

    -------------------------------------------------------

    onMouseClick on "buttonsprite"

    system add 1 to variable [local static number]

    subevent:

    system variable > 1

    system set variable to 0

    subevent:

    system variable = 0

    objectsprite destroy

    subevent:

    system variable = 1

    system create objectsprite

    ------------------------------------------------------

    It seems to be working, though I feel like there out to be a more streamlined solution...?

  • Thank you for the suggestions! I'm not sure how to use modulo yet; I'll have to read up on that more. With your advice and this tutorial () I managed to get things working the way I wanted. Thanks again!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I'm new to C2, so I apologize if this question has a very simple, obvious answer I should have found in my searching and tutorial-reading!

    I'm trying to make a create/destroy button which will create an object if there is no objectsprite on the screen and destroy the object if the objectsprite is onscreen.

    Basically a show/hide button; click once and the object appears, click again and it disappears, click a third time and it appears again, etc.

    Here's what I've tried:

    To create the object:

    ------------------------------------------

    On mouse click on buttonsprite

    AND

    buttonsprite variable1=0 (which is default value)

    System create objectsprite

    buttonsprite add 1 to variable1

    -----------------------------------------------

    To destroy the object:

    ------------------------------------------------

    On mouse click on buttonsprite

    AND

    buttonsprite variable1=1 (which shows it's been clicked once, so the objectsprite has been created)

    objectsprite destroy

    buttonsprite set variable1 to 0 (ready to create object again on next mouse click)

    -----------------------------------------------------

    In my head this logic should work, but onscreen...nothing happens. Is the button click instantly setting the variable to 1, thus also triggering the destroy event with that initial button click?

    I have searched for a solution to this but either I haven't found it or am too dense to realize the answer is staring in my face. Any suggestions or links to relevant tutorials would be greatly appreciated! Thanks!

mkea's avatar

mkea

Member since 5 Apr, 2015

None one is following mkea yet!

Trophy Case

  • 9-Year Club
  • Email Verified

Progress

10/44
How to earn trophies