If 5 bullets on screen, destroy the oldest bullet

Just started using Construct 2? Post your questions here

Post » Thu Jan 29, 2015 5:58 pm

Hi guys,

I have no idea how to do this (title).

I also don't understand how I can refer to cloned objects in general (like 1 copy of a bullet, or one instance of an enemy)

I know this will be super simple! Thanks!
B
4
Posts: 22
Reputation: 244

Post » Thu Jan 29, 2015 7:08 pm

Since the oldest bullet would probably have either the lowest zorder or the lowest UID you could sort by either and pick the first object (Pick nth instance action) for example.
B
19
S
6
G
6
Posts: 1,101
Reputation: 5,646

Post » Fri Jan 30, 2015 10:17 am

Somebody wrote:Since the oldest bullet would probably have either the lowest zorder or the lowest UID you could sort by either and pick the first object (Pick nth instance action) for example.


Do you mind giving me an example?

I still don't know how to destroy a specific bullet.

I can use a global variable to count the bullets on screen and destroy if there are more than 4, but this destroys ALL bullets.
B
4
Posts: 22
Reputation: 244

Post » Fri Jan 30, 2015 10:29 am

Alright, adapted a little example for you - we "pick" all the bullets on screen and compare their count - if it's higher than what you need we pick the "oldest" bullet (because we know it's going to be the "lowest" one and destroy it.

Some event ninja will probably come by and offer a more elegant solution, but this works.
You do not have the required permissions to view the files attached to this post.
B
19
S
6
G
6
Posts: 1,101
Reputation: 5,646

Post » Fri Jan 30, 2015 12:12 pm

Thanks very much, that works great.

I didn't know about "PickedCount"

I guess it's time for me to re-read the manual, more carefully this time! Thanks again.
B
4
Posts: 22
Reputation: 244


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 0 guests