How do I check whether an sprite object exists

Get help using Construct 2

Post » Mon Feb 01, 2016 11:32 am

Hello, I wonder ... how do you find out if there is any object without comparisons ?.

Something like "if exists (object_type)".
Returns true if there are objects.

Or put another way, how do I create an event to see if there is an object type ?.
That is, I just need to know whether the object exists or not.

I read the manual and all that is within reach but I do not understand something.
B
28
S
11
G
20
Posts: 728
Reputation: 13,672

Post » Mon Feb 01, 2016 11:54 am

Yo
Mirlas wrote:Hello, I wonder ... how do you find out if there is any object without comparisons ?.

Something like "if exists (object_type)".
Returns true if there are objects.

Or put another way, how do I create an event to see if there is an object type ?.
That is, I just need to know whether the object exists or not.

I read the manual and all that is within reach but I do not understand something.


You can use "is on-screen" to detect it.
B
72
S
13
G
2
Posts: 990
Reputation: 6,971

Post » Mon Feb 01, 2016 12:13 pm

But that tells me if there on the screen, I need to know if there even if not seen on screen.

That is, if there are objects or not, whether they are displayed or not.
B
28
S
11
G
20
Posts: 728
Reputation: 13,672

Post » Mon Feb 01, 2016 1:26 pm

You could check if Object.count is not 0
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Feb 01, 2016 3:06 pm

LittleStain wrote:You could check if Object.count is not 0


Thanks, that was the solution, at the beginning I tried but it did not work well, why not work it?

Image




This works well, but I prefer to use the other mode, but does not work and do not know why!.

Image
B
28
S
11
G
20
Posts: 728
Reputation: 13,672

Post » Mon Feb 01, 2016 3:21 pm

I'm sorry, but I don't see why you'd prefer to set the text every tick, when it only needs to be changed when the number of sprites change..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Feb 01, 2016 3:29 pm

Yeah, well it's just an example, forgetting the text, why this capx is not written "without objects"?

https://dl.dropboxusercontent.com/u/60803633/test3.capx
B
28
S
11
G
20
Posts: 728
Reputation: 13,672

Post » Mon Feb 01, 2016 3:40 pm

Because you are checking if there are no objects, before there are no objects..

And once there are no objects the event doesn't run anymore..

Put the system compare as a topevent and it runs..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Feb 01, 2016 4:01 pm

Ok, solved, thanks as always.
B
28
S
11
G
20
Posts: 728
Reputation: 13,672


Return to How do I....?

Who is online

Users browsing this forum: plinkie and 5 guests