Choose with exceptions/Dependent Events

Get help using Construct 2

Post » Tue Oct 01, 2013 8:26 pm

Thank you again for your examples! I will be more careful when I speak of sprites, instances and frames in the future :D

I wanted to know if I was on the right track. I think it's a problem with picking the instances and adding them to the array.

In the first example it will generate random frames but they repeat still have duplicates.



first

in the second I tried adding UIDs to the array but wasn't sure how to pick them.

blockuids.capx
B
10
S
2
Posts: 80
Reputation: 995

Post » Tue Oct 01, 2013 10:17 pm

I'm sorry, your capx' were done with r145, which is too buggy regarding audio for me to use. If you don't want to recreate them with r144.2 or r139, I propose to wait until a more reliable version is out. tulamide2013-10-01 22:17:57
Image
B
24
S
8
G
10
Posts: 1,821
Reputation: 8,279

Post » Tue Oct 01, 2013 11:54 pm

Haha, that's ironic. I upgraded to 145 to access your random destroy example.

Here is an r139 version. I wanted to know if I was on the right track. I think the problem is with picking the newly created instances. I wasn't sure how to handle it, nor am I certain about the order of operations going on there.

instancepickconfusion.capx
B
10
S
2
Posts: 80
Reputation: 995

Post » Wed Oct 02, 2013 1:01 am

Here is the corrected version. The mean thing is: it's done with r144.2 (I don't want to reinstall different versions while I'm developing a project)

There were a lot of issues, too many to explain them all. Most of them were already addressed in my last example. You might want to have a closer look at it and this new one. For example, you added an array to your project but the initial size was kept at (10,1,1). With already 10 cells filled with the value 0 you will never get any other frame than 0 ;)

Try to look very closely at the projects. All there is exists for a good reason

Oh, and last: If all you want is having 3 instances that have different animation frames that change on some event, you don't need to destroy and recreate the instances. Just shuffling the frames would be sufficient then.

instancepickingNOconfusion.capx
Image
B
24
S
8
G
10
Posts: 1,821
Reputation: 8,279

Post » Wed Oct 02, 2013 9:09 pm

Thank you again, I continue to play with it but I feel like you might be babying me at this point.

So one more question, what needs to be done to pick a random instance of the three new instances?



Do I need to have their UID as part of the array when they are created and pick randomly from one of them? Setting up an XY array where x is the frame and y is the UID? much like the random destroy but with a two dimensional array

Is it a parameters issue? Where I need to return values in order to pick from those three?


and about the destroy bit, they will be given bullet later and go off screen, creating 3 more. Though I guess they could just be moved back and bullet across infinity after changing frames and picking a new "answer" blockCentra2013-10-02 21:14:31
B
10
S
2
Posts: 80
Reputation: 995

Post » Thu Oct 03, 2013 12:34 am

You don't need anything to pick a random instance, just that exact event you are using.
The problem here is that C2 seems to work the same way CC worked. That means if you create an instance it is only accessible in the same event, where it is created. Any other events can only access it one tick later. The instance is created at the end of the current tick, so when you tell C2 to choose a random instance, there are no instances to choose from.

If you give it at least one tick time, it works. For example, make the random pick event a subevent just like this:

+ (empty) -> System Wait 0.1 seconds
++ Pick a random ...

how long you have to wait is dependant on the framerate. With 60 fps one tick needs about 17 ms. If it also is a stable framerate, then waiting 0.02 seconds would be enough.

You could also store the current tickcount to a variable in the function, and then outside the function check if tickcount = variable + 1, and if so pick a random instance.
Image
B
24
S
8
G
10
Posts: 1,821
Reputation: 8,279

Post » Thu Oct 03, 2013 1:18 am

Awesome! The first suggestion made it go crazy but the second one worked. Thank you so much, I would have never guessed that without inside knowledge. Also I checked out your music loops and wanted to say nice work :)
B
10
S
2
Posts: 80
Reputation: 995

Previous

Return to How do I....?

Who is online

Users browsing this forum: uzumiapps and 31 guests