Fill Array with Sprites

Get help using Construct 2

Post » Tue Jun 07, 2016 8:54 am

@99instances2Go that would be a great option - only the previous footsteps would have to stay on the screen. Ive placed all footsteps on the screen. All except the first one has to be invisible or not enabled. Then you find the first footstep - after that the next one appears nearby. If you move to this next footstep the next one appears - and so on. :). The main thing would be, that the previous footsteps arent deleted. That would solve the task.

Working with differend levels would be a nice extra for this game (basically i would have only one stage with differend footsteps (different types but the core mechanic of all these footsteps should be like i descriped))

Thank you very much
B
9
S
2
Posts: 152
Reputation: 1,051

Post » Tue Jun 07, 2016 12:08 pm

@Congrats2u

My two cents: while learning is better to find a solution first, just to see how it works. Only in second instance try to make it better, but you have first to understand how the "core" goes :)
I'm not a insane, my mother had me tested

I'm an engineer. To save time, just assume I'm never wrong
B
30
S
13
G
4
Posts: 141
Reputation: 4,832

Post » Tue Jun 07, 2016 12:31 pm

@Jeff thats right :) iam trying to figure out the mechanics, but in this case it is a little bit to tricky (with my current construct2 skills - i have to learn much more core mechanics but on the other side talking to pros will make it hopefully easier). I think you guys made a very good support so dont missunderstand my reply´s :). In this case iam working with 99instances solution - but i couldnt figure out the "dont delete the previous footsteps" problem yet. But i will continue :)

Like i said at the beginning - its a cool engine but its tricky to work with this kind of "scripting" ;)

Iam happy about your support
B
9
S
2
Posts: 152
Reputation: 1,051

Post » Tue Jun 07, 2016 4:18 pm

B
94
S
33
G
114
Posts: 5,359
Reputation: 73,779

Post » Wed Jun 08, 2016 8:57 am

@Rojohound you sir, made my day. This solution is great. Thought i would need to create an array to get the straight order. But your solution teached me to think differend :). Thanks for that!

Ive implemented this code into my game and it workes like a charm.

Great!
B
9
S
2
Posts: 152
Reputation: 1,051

Post » Wed Jun 08, 2016 9:43 am

@99Instances2Go In other words it allows you to create many levels using only one layout. You only have to use a few JSON files. Okay sounds good. Not sure how I missed something like that. Thank you.

Thank you for the 2nd example as well. It will help plenty.
B
67
S
37
G
13
Posts: 241
Reputation: 12,760

Post » Thu Jun 09, 2016 9:31 am

@R0J0hound is there a possibility to get the last footstep with your function (even when i put some more footsteps onto the screen from the same kind?).Like i would get, if iam using an array (footstep.length-1).

If the last footstep is reached, i want to trigger an event. But do i have to check how many footsteps are on the screen on my own (IID´s), or is there a function i could use, which controlls how many footsteps of the same kind are on the screen, and which one is the last one?

hopefully you get the point out from my description :D
B
9
S
2
Posts: 152
Reputation: 1,051

Post » Thu Jun 09, 2016 10:41 am

Amount of steps (before you make any new) is the expression steps.count.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Thu Jun 09, 2016 3:53 pm

@99Instances2Go thanks again for your answer! :) Today i recognized following i want to descripe:

I´ve a minimap. This minimap is an extra Layer, on which you can see a small complete version of the ingame map. If you click onto a point on the minimap you come onto the right spot for the ingame map. On the ingame map there are the footsteps placed were talking about the whole time :).

The problem: If i switch between the minimap (remember extra layer) and the ingame map - all footsteps are resetet and invisible (because its settet up in the code ive get from ROJOhound (thanks again for that ;) )). My Problem: Is there a possibility to save the founded footsteps with your solution ROJOhound? Because if iam finding - lets say - 5 foosteps and i switch to the minimap and then back again, i have to code that the footsteps ive found bevore are visible (makes sense because ive found them). But now the question of the questions. How? Ive tried it with a loop but that didnt work, because if i set the iids to invisible it will do it for all footsteps.... and again...iam confused about that fact.

For example: System -> For each footstep1 order by foostep1.IID > 10 ascending -> foostep1 Set Invisible. So why there are all of them invisible? Usually all footsteps bigger than 10 should be invisible, and all foosteps under 10 should be visible right?

Is it possible to do a for loop with this kind of "non-array"?

Thank you for your awesome help!
B
9
S
2
Posts: 152
Reputation: 1,051

Post » Fri Jun 10, 2016 5:59 am

When you say layer I think you mean layout. You could try the presistance behavior on the footsteps perhaps. It lets them keep their state even when you switch layouts.

Also kind of unrelated but
For each Sprite ordered by Sprite.iid ascending
Is identical to
For each Sprite

The expression you use with the "for each ordered" is used to sort the instances before looping over them. To filter out some instances from being picked you need to use another condition. Maybe the pick by comparison condition.
B
94
S
33
G
114
Posts: 5,359
Reputation: 73,779

PreviousNext

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 21 guests