How do I set a sprite invisible

0 favourites
  • 11 posts
From the Asset Store
Get Ready for the New Wave of "Bottom Screen" Games!
  • Trying to set a sprite to invisible but still present ...-> lingo (changing state sprite button)

    script 1

    on mouseUp me

    sprite(1).visible = 1

    sprite(2).visible = 0

    end

    script 2

    on mouseUp me

    sprite(1).visible = 0

    sprite(2).visible = 1

    end

  • -http://jexbe.net63.net/temp/button/button.htm-

    vs

    -http://jexbe.net63.net/temp/button/index.html-

  • not quite sure what the problem is, but does this fix it?

    A sprite is always present until you destroy it, no matter if it is visible or not.

  • As ubivis says invisible isn't disabled. You should destroy it.

    or...

    Edit: My example same as ubivis, just another way to do it. So many ways to achieve same result - lol

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you !

    (gonna see it later my version is still at 1.68 need the beta end XD)

  • Ok did some (fail) tests :

    onclick swap sprites pos X - fail (work once with sprite priority ?!@#?)

    onclick change sprite animation frame - fail (work once ?!@#?)

    onclick destroy/create with check visiblity - fail (on destroy sprite still present)

    onclick set visible/invisible - fail (on invisible sprite still present)

    Can't understand ... or missed a thing.

  • So the reason your first code doesn't work is it runs back to back. So as soon as it switches invisible it reverts right back. You can fix this with an if/else statement.

    Create 2 sprites and set their initial visibility through their properties.

    Create a global visibility variable.

    Create an event on button pressed.

    Then a sub event that compares the global variable to see if the object is visible.

    If it's equal to 0 set the visibility of the sprites and change the global variable.

    Create an else statement and reverse it while changing the variable.

  • Invisible/visible

    You are overlapping the sprite images. So when you click on outsides(non overlapped parts) they work as intended, but if you click on any overlap they will not work. This is what we meant when we said, you can't see it but it is still there. Invisible sprites are clickable.

    You need to mark sprite 7 as invisible either in properties or on start of layout like you did sprite 4.

    But you can't overlap the sprite buttons because you will be pressing both.

    AnimationFrames

    Swapping image frames returns true permently once button pushed. You click sprite3 image - frame is 0 and it turns to 1 and stays there because you click it and it runs through cycle because it is then true that animation frame is = 1 and so forth. so it doesn't move from animation frame 0.

    True is true that is why we used the else because it puts a block that if condition 1 is true then do this else do that.

    Destroying objects And changing positions

    Could be a bug? Can't put my finger on it off hand and limited time.

    You have two example capx from yesterday. Easiest way and it works. If you want invisible - then make 2nd image frame clear.

  • Thanx for all I'm still at the 168 version (steam) so at this time I can't use some capx (170 beta version).

    I've Just notice some strange actions with some events for a specific sprite swap.

  • jexbe,

    You can use beta versions on steam if you want...

    Here is ubivis capx

    [attachment=1:2eljpeo6][/attachment:2eljpeo6]

    And here is mine

    [attachment=0:2eljpeo6][/attachment:2eljpeo6]

  • Try this simple Button demo all you do is click on Red Button and see result

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