Fill Array with Sprites

0 favourites
From the Asset Store
An educational game for Fill in the Blanks. An easy to use template for developers to build larger games
  • 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.

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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!

  • 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.

  • 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

  • 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

  • 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

  • Jeff thats right

    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

  • 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!

  • 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.

  • 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

  • Amount of steps (before you make any new) is the expression steps.count.

  • 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!

  • 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.

Jump to:
Active Users
There are 2 visitors browsing this topic (0 users and 2 guests)