How to create arrays of blocks or coins?

famekraftsfamekrafts Member, BASIC Posts: 834
edited September 2012 in Working with GS (Mac)
I want to create coins arranged in a particular shapes for example arrows or rockets.

They need to be different prototypes of same actor. So arranging like arrays in normal programming will be the option.

How do I achieve this in GS?

Comments

  • famekraftsfamekrafts Member, BASIC Posts: 834
    Guys any help here, I am finding it very tiring to do it one by one. NO equation or short cut way to make cool designs with the coin spawning?
  • hotMagichotMagic Member, PRO Posts: 266
    The question is, do they have to move?

    If not, the easiest way is to make a table, and basically grid out everything in the table.
    So if it's coins, put C in every cell of the table and "draw" your arrow in the chart.

    Then any time you want to make an arrow, you call a rule that scans the table and puts the coin object in that place.

    Make variables to help you scan the table. So Row=1, Column=1. After you draw each coin, you add to each. This way it scans the table and keeps moving across it.

    if Row, Column of Table =C, the spawn a coin object at (whatever place you wanna put them). Of course you'll want to offset based on the size of the coin and spacing.

    So Spawn it at x coordinates =50xRow and y coordinates =50xcolumn, for example, if the coin is like 40x40 and you want a space of 10 between them.

    Keep in mind if you start at a certain location, you need that offset for all the coins. So like if it's 50, 60, for example, the coins are spawned at x value =50 + 50* Row
  • famekraftsfamekrafts Member, BASIC Posts: 834
    I am dead sleepy and everything you said went over my head. :) Will try to go through this again tomorrow and give it a shot. I have not understood tables yet, maybe its time to learn those as well. Thanks, will bother you if I cannot do it.

  • carlblanchetcarlblanchet Member Posts: 755
    @wickedsunny Tables are very worth learning, and if you can master them, even better!
  • famekraftsfamekrafts Member, BASIC Posts: 834
    @carlblanchet Thanks I am learning it.

    @hotMagic yes the coins are moving, so I believe the tables not going to work?
  • famekraftsfamekrafts Member, BASIC Posts: 834
    Ok friends, I am trying learn the tables. Say example I have 10 rows and 10 columns.

    I want to fill each cell with an animating coin moving to the left.

    Now how do I call an actor in table?

    I need to use random cells to create different patterns, how to give the coordinates for each coin called?

  • famekraftsfamekrafts Member, BASIC Posts: 834
    ok I got the basic idea, but how do I call one whole row/column of a table? for example my one column has different x coordinates and another coulmn has different y co ordinates?

    When spawning an actor in the x cordinate I am calling cell value table but it calls only one row one column.

    How I can call one complete row and use only one column and vice versa?
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    You'll want to use a loop to run through your table rows/columns. Here's an example that doesn't use table cells, but you should be able to adapt it for your use: http://forums.gamesalad.com/discussion/41887/i-can-make-a-loop-in-the-gs.

    Just iterate the cell row or column number and then add a spawn behavior with the x/y locations based on the row/column value.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • famekraftsfamekrafts Member, BASIC Posts: 834
    Do I create a global attribute and insert the loop counter? I never used loop before, so no idea where to apply it?

    currently I have a made an attribute for spawning coins when that is on, I am calling each coin from the table and making them arrange in such a way that they look like a shape or text.

    But calling each cell individually is taking a lot of time and behaviors.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited October 2012
    If you look at the screenshots in the thread I linked to, you would replace the Log Debugging Statement with something like this:

    image

    That way, as the self. (or game.) loop counter attribute increases, the table row number increases and the loop spawns an actor at each table row's x and y values. The y position field just has the same expression but with table column "y" at the end instead of "x".

    EDIT: That should be Relative to scene, not actor.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • famekraftsfamekrafts Member, BASIC Posts: 834
    edited October 2012
    @Tatiang. Thank you.

    Can you help me out here also, just scroll down to the end.

    http://forums.gamesalad.com/discussion/40282/scrolling-background-not-using-scene-wrapping-please-help

    I am badly stuck as the backgrounds are not looping properly anymore because I am pausing the screen which makes the new spawn to overlap the old one. I am using the spawn and destroy behavior for looping backgrounds.

    http://forums.gamesalad.com/discussion/comment/348903/#Comment_348903

    I think the above link interpolate method can work better but the coordinates are not working for ipad 1024 x 768 resolution.




  • mataruamatarua Auckland, New ZealandMember Posts: 854
    Awesome thanks! Exactly what I have been searching for! :bz
Sign In or Register to comment.