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
  • Hello,

    its my first post - and i have to say iam new here. I have watched some tutorials about how to fill arrays, but iam quite not sure how to solve the task i want to do.

    I want to place "foodsteps" (sprite images) in an straight order onto my screen. The game mechanic should be, that you have to search them, and if you find one, the next one appears on the screen (right behind).

    So you have to follow this foodsteps until you reach the destination place. I Thought to place them into an array and make the opacity of all (exept the first one) to zero. And if you follow the path, each foodstep which comes next will change its opacity to 100.

    I hope you can follow me. If not - let me know.

    So how would i fill my array with my sprites (basically its only one spirte i use several times via copy paste and placing on the screen unitl i got a big path with X instances of this sprite)

    It would be great if someone would have an idea.

    Usually i use Unity or flash to programm games in C#, Js, or ActionScript3. Its my first experience with an "non programming" engine.

    Thanks a lot!

  • Congrats2u

    I don't know if I've correctly understood your question, but I would do in this way:

    1. I would create a "for" loop

    2. In each iteration I would create the sprite in a given position

    3. In each iteration I would put the new UID in the n-th position of the array

    When one of the sprite is discovered, I will search for it's position in the array and uncover the next one, knowing the UID.

    ... but I'm not sure if that is what you need

  • At first - Thanks for your super fast answer. Youre totally right Jeff, that would be the idea.

    Could you explain me how to fill an array with the informations (UID)? because i couldnt find a possability to fill them into the array.?

    The next thing would be: I have to give them all a collider...or a position detection (plus offset in x and y direction) for detection when the next/following object has to appear on screen. But at first i have to bring the array with my sprites to work

    Thanks for your support Jeff - if you could give me an example of the array filling term it would be great!

    Cheers!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Congrats2u

    Sorry, I am at office now, so I cannot prepare a capx example...

    The idea however is:

    1. Create the loop (you can find ton of tutorials on how to use loops )

    2. System -> Create object <Footstep sprite>

    3. Array -> Set at X [loopindex] <Footstep sprite>.UID

    In the late evening/tomorrow I might be able to prepare something if you didn't manage yourself... but try it

    P.S. use the and the user nickname to let them know you've answered

  • Jeff Skyrunner Youre great! Thanks!

    I will try to figure it out.

    Each example would be great but dont stress yourself

    Cheers!

  • Not really happy with storing UID's in an array. That way the objects have to exist. And keep on existing. Not flexible.

    Therefor:

    https://www.dropbox.com/s/68qeajb2ko8c6 ... .capx?dl=0

  • It depends what he needs

  • That is so true Jeff.

  • Jeff 99Instances2Go really Thank you guys! Nice support! I will try it out today!

  • 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

    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!

  • 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

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

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

  • 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

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