How do I visible&invisible an sprit with mouse left

Just started using Construct 2? Post your questions here

Post » Wed Jul 23, 2014 2:22 pm

How do I can visible and invisible an sprit with mouse left click on another sprit?
B
3
Posts: 1
Reputation: 177

Post » Wed Jul 23, 2014 2:40 pm

add a global variable called "visible" and set its value to 0
Event
Mouse -> on object clicked -> anothersprite
System -> compare variable -> visible =0
Action
yoursprite -> set visible -> invisible
system -> set value -> visible=1

Event
Mouse -> on object clicked -> anothersprite
System -> compare variable -> visible =1
Action
yoursprite -> set visible -> visible
system -> set value -> visible=0
B
18
S
2
G
1
Posts: 67
Reputation: 1,339

Post » Wed Jul 23, 2014 4:01 pm

Why make a global variable when you already have a condition that checks for visibility , I like to keep things clean and simple . Try this out for size :
Event
Mouse->on object clicked -> othersprite
subevent ->yoursprite ->is visible .......action->yoursprite->make invisible
subevent ->else
->yoursprite->(inverted)is visible........action->yoursprite ->make visible
Last edited by granpa on Wed Jul 23, 2014 9:31 pm, edited 1 time in total.
What I know would fill a Book , what I don't know would fill a Library
B
37
S
12
G
29
Posts: 331
Reputation: 16,499

Post » Wed Jul 23, 2014 4:16 pm

Image

Not sure if it's best practice, but I did it this way.
B
7
S
1
Posts: 61
Reputation: 588


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 1 guest