How do I set a sprite invisible

Get help using Construct 2

Post » Tue May 27, 2014 1:03 pm

Message: jexbe is not yet permitted to post plain text URLS (300 rep required). 1 URLS removed. Why?
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
You do not have the required permissions to view the files attached to this post.
B
4
Posts: 10
Reputation: 222

Post » Tue May 27, 2014 1:12 pm

-http://jexbe.net63.net/temp/button/button.htm-
vs
-http://jexbe.net63.net/temp/button/index.html-
B
4
Posts: 10
Reputation: 222

Post » Tue May 27, 2014 1:24 pm

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.
You do not have the required permissions to view the files attached to this post.
B
44
S
10
G
8
Posts: 437
Reputation: 6,468

Post » Tue May 27, 2014 1:50 pm

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
You do not have the required permissions to view the files attached to this post.
You think you can do these things, but you can't, Nemo!
Just keep reading.
Just keep learning.
B
65
S
16
G
9
Posts: 1,429
Reputation: 12,718

Post » Tue May 27, 2014 2:09 pm

Thank you !
(gonna see it later my version is still at 1.68 need the beta end XD)
B
4
Posts: 10
Reputation: 222

Post » Wed May 28, 2014 9:00 am

Ok did some (fail) tests :
onclick swap sprites pos X - fail (work once with sprite priority [email protected]#?)
onclick change sprite animation frame - fail (work once [email protected]#?)
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.
You do not have the required permissions to view the files attached to this post.
B
4
Posts: 10
Reputation: 222

Post » Wed May 28, 2014 10:06 am

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.

Image
Image
B
47
S
17
G
3
Posts: 206
Reputation: 5,061

Post » Wed May 28, 2014 10:22 am

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.
You think you can do these things, but you can't, Nemo!
Just keep reading.
Just keep learning.
B
65
S
16
G
9
Posts: 1,429
Reputation: 12,718

Post » Wed May 28, 2014 8:04 pm

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.
B
4
Posts: 10
Reputation: 222

Post » Thu May 29, 2014 7:07 am

@jexbe,

You can use beta versions on steam if you want...
Here is ubivis capx
ubivis capx.JPG

And here is mine
my version.JPG
You do not have the required permissions to view the files attached to this post.
You think you can do these things, but you can't, Nemo!
Just keep reading.
Just keep learning.
B
65
S
16
G
9
Posts: 1,429
Reputation: 12,718

Next

Return to How do I....?

Who is online

Users browsing this forum: NN81 and 4 guests