Fill Array with Sprites

Get help using Construct 2

Post » Mon Jun 06, 2016 8:18 am

@99Instances2Go - Awesome! Thats exactly what i was looking for! Thank you very much for your example file! Now i have to study out how you did this with construct ;) in my oppinion its a little bit more tricky, than programming it in some ohter editors (like unity) :)

It would be great if i could ask you two, if there some other parts, i dont understand directly - if its okay for you :).

Thanks!
B
8
S
2
Posts: 141
Reputation: 1,002

Post » Mon Jun 06, 2016 9:05 am

@Congrats2u

As 99Instances2Go was saying, keep in mind that these are just examples, not necessarily the best way to do what you have in mind... but it should help you start :)

Edit: You've just answered :P
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 » Mon Jun 06, 2016 11:21 am

@99Instances2Go Iam not sure where i can find the part for enabling the next piece. Its weird - you are using a player on which you included a path...but there is no function to enable the next piece if it reaches the destination of a previous piece. I understand the initalization part youre doing from step 1 to step 8. But its a mirrycle for me how you enable the next pieces. :)

Basically i have the stage (background) i want to move trough my window. I have to include a collider or something onto the window which detects the pieces, if theryre moving through the window center and set the next one active (like youre doing currently but without a player).

@Jeff Iam not sure what do you mean with "You´ve just answered"? Do i have to mark something? :)


Thanks you two for your awesome support!
B
8
S
2
Posts: 141
Reputation: 1,002

Post » Mon Jun 06, 2016 2:26 pm

I am not @ the computer i made it with. As i recall. There is a path layed out in the layout. Your question was, how do i writes those steps down in an array. So far you are with me. After that i destroyed all the footsteps, so they dont occupy memory, and its not needed to do complicated pickactions to find that one footstep.

So, now they ONLY exist in the array. Thats the real meaning of the array. At this point there are no steps in the field (steps.count=0-

Then, when there are no steps in the field (steps.count = 0), its creates a step with the first values of the array, AND it deletes that first value of the array. So the next step in the array becomes the first step, ready for the next move. Now steps.count = 1 (one step in the field), so this condition will not be true as long as that step exists.

When the player arrives on the destination of a step (pathfinding arrived) , that step gets destoyed. Now steps.count is a again zero. Now it starts all over. And it creates a new step according the array.

Thats a perfect and very very easy flow. No variables for a state, no extra checking conditions.

And, dont forget, because i destroyd all steps, and because it works with just one step, no complicated conditions to pick the next step out of to many.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Mon Jun 06, 2016 10:52 pm

There isn't really a need for an array at all. And really events aren't much different from regular code.

https://dl.dropboxusercontent.com/u/542 ... cking.capx
B
92
S
32
G
107
Posts: 5,274
Reputation: 69,959

Post » Mon Jun 06, 2016 11:17 pm

True, but the question was: Fill Array with Sprites. Suppose there is a reason to ask it that way. Dunno.
And to be honest, i hate arrays (well hated), i had to master them one day. And best soon.
I am only here to learn more Construct by solving other peoples puzzles. It prooved to be the best way for me.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Tue Jun 07, 2016 1:11 am

@99Instances2Go It took me a few minutes to realize what was going on. Why map already placed objects on the layout into an array only to destroy them and then recreate them?

The only reason I thought of was, by placing objects in an array you are preventing duplicate objects from being on the screen. Is an array really needed for any reason other than having 1 object on screen instead of 24. Is that the only reason?

Assuming the path is set beforehand and no other objects are needed to be placed in the array.
B
62
S
35
G
13
Posts: 230
Reputation: 12,402

Post » Tue Jun 07, 2016 8:04 am

@ All at first thank you for your thoughts about my problem :). Basically youre right but i would have the previous steps to stay on the screen (currently they will be removed). So i think the array solution would be the best solution for this task.

@Rojohound if i wouldnt need the previous footsteps your solution would may be absolutly right.

@99Instances2Go Is there a possability to let the previous footsteps stysing on the screen, whitout deleting them? That would be nice. The player should see all the previous steps he found durring the game. So he could see the complete path if he reaches the end.

Currently i have placed a transparent gameObject on the screen center, so if youre searching for the parths, they only will appear if you find them "central" with the screen.


Thanks for your input!
B
8
S
2
Posts: 141
Reputation: 1,002

Post » Tue Jun 07, 2016 8:09 am

PS: Using an array to make sure that you have an order, in which you have to activate the next foodstep is a reason too, for using an Array. In my game you can scroll free through the stage, so it would set footsteps active, which shouldnt be active, until you follow the steps in a fix order.

Example: On the screen, there is a footstep placed. You have to find this one. Then the next footstep right behind or in front of it appears - and so on. So placing all footsteps on the stage and make them only visible if you collides with them wouldnt make sence for my intention. Because there would be possible gaps between all footsteps.
B
8
S
2
Posts: 141
Reputation: 1,002

Post » Tue Jun 07, 2016 8:37 am

Unconnected wrote:@99Instances2Go Is an array really needed for any reason other than having 1 object on screen instead of 24. Is that the only reason?


Suppose you want to dynamicaly create levels. In the layout of this capx, no path, not even buttons placed in the layout.

https://drive.google.com/open?id=0B1SSu ... GprNlNNMmM
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

PreviousNext

Return to How do I....?

Who is online

Users browsing this forum: Lordshiva1948, Yahoo [Bot] and 53 guests