Count and Create object [BUG?]

Discussion and feedback on Construct 2

Post » Thu Mar 23, 2017 12:03 pm

Hello, is this correct?

I create a bat in "Trigger once".
Then check if there are any bat in "mulcielago.Count > 0" and this gives FALSE as a result.

Is this correct or is it a bug in C2?

Image

In the test file, press space, the text will be printed even if a sprite already exists and sprite.count <= 0 should be false.

https://www.dropbox.com/sh/ehrch6zye1tuq33/AACqlv_6UnWbOaJSLhy8n3Era?dl=0
Last edited by The Mnk on Thu Mar 23, 2017 10:10 pm, edited 3 times in total.
B
29
S
12
G
21
Posts: 789
Reputation: 14,429

Post » Thu Mar 23, 2017 9:48 pm

In debug mode you can check how many instances there are of the bat sprite. Maybe there are -for some reason- 0 instances.
B
28
S
6
G
7
Posts: 678
Reputation: 5,676

Post » Thu Mar 23, 2017 9:59 pm

mumu64 wrote:In debug mode you can check how many instances there are of the bat sprite. Maybe there are -for some reason- 0 instances.


Ok I've tried it, but I do not see any sense of what's happening.
That is, the condition is true although in the debug it says that the object exists.
I do not see sense.

Try the test.
When you press space, the text is printed.
How is it possible?.
That condition should be false because the object was created before, so sprite.count is not <= 0.
B
29
S
12
G
21
Posts: 789
Reputation: 14,429

Post » Thu Mar 23, 2017 10:21 pm

This is correct.
Cant check newly created objects before the next root event (no sub).

https://www.google.be/search?q=scirra+P ... scirra.com
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Thu Mar 23, 2017 10:45 pm

@The Mnk

what 99Instances2Go said is correct - C2 does not update its internal indexes/counts until the next top level event after the create object action.

You can continue to access the object in sub events under the one that created it, and you can pass its UID to a funtion that can pick it by UID.
Another thing you can do is add a wait 0 to give C2 a chance to update before running actions after the wait.
B
95
S
33
G
20
Posts: 438
Reputation: 17,640

Post » Fri Mar 24, 2017 8:59 am

Thanks for the information guys.

AllanR wrote:Another thing you can do is add a wait 0 to give C2 a chance to update before running actions after the wait.


Where should I add the WAIT(0) in the capx file I uploaded before?
B
29
S
12
G
21
Posts: 789
Reputation: 14,429


Return to Construct 2 General

Who is online

Users browsing this forum: Kyatric and 11 guests