Spawning actor

SANDEEP410SANDEEP410 Member Posts: 46
edited July 2012 in Working with GS (Mac)
I want to spawn an actor on 5 fixed x cordinate position.I wnat to check wether an emey exist on not in a bounding rectangle.
If no enemy exist on the rectangle than spawn an actor.Any1 knows how to acheive this

Comments

  • ekelrockekelrock Member Posts: 34
    @SANDEEP410
    I may be able to help, but let me clarify first.

    You want to spawn actors to 5 fixed positions on screen, but before spawning the actors you want to make sure there is not already an enemy in their positions?

    Or you have one actor that will spawn to 1 of the 5 fixed positions. So it will check to see if the first position has an enemy in it, and if it does, it won't spawn the actor there. It will move on to check the next position, and so on, until it finds an open space?
  • SANDEEP410SANDEEP410 Member Posts: 46
    ok i want my enemy to spawn in 5 fixed horizontal position.After they spawn they move downwards.So it should pick a random point from those fixed 5 position.Here it should check wether there is an enemy present in area of small bounding box.
    If no enemy present then spawn an enemy otherwise check again.
    Basically i dont want my enemies to overlap each other
  • SANDEEP410SANDEEP410 Member Posts: 46
    bump
  • ironDanironDan Member Posts: 148
    Use Tables.
    Create a grid in tables using the x and y locations of your board.

    if you had a grid that was 8x8 and each box was 40x40 just make 3 rows in the table
    X(real),Y(real),Used(boolean)

    in row 1 col 1 set value to 20 (center x of the first box)
    in row 1 col 2 set value to 20 (center y of the first box)
    in row 1 col 3 leave value unchecked for False. (if sale box is open if true enemy is there)

    Do that for each box in your grid

    Set a rule in the enemy that changes the table value for that grid column 3 to true
    and in your actors to spawn make a If rule that checks the Table value for that grid if that grid location column is false to spawn of true not to spawn.

    Good luck
    Dan
  • SANDEEP410SANDEEP410 Member Posts: 46
    I ran in to couple of problems
    1st is how can i make actor spawn in fixed random cordinates.
    I mean i want the actor to spawn randomly on this X cordinate(26,80,134,188,242)
    Currently there is only option of giving min and max value option in random function

    Now for the above post
    How do i make a grid in gamesalad.This post seems to be extremely confusing to me
    Can you make a small demo

    Thx
  • SANDEEP410SANDEEP410 Member Posts: 46
    bump
  • SANDEEP410SANDEEP410 Member Posts: 46
    bump
  • mighty_poohmighty_pooh Member Posts: 20
    Sandeep im actually using this guide and you can do it. What you want to do is put all your numbers in a table. Lets say row 1 colom 1 - 5 is your numbers.
    You will put your spawn up like this - tableCellValue( game.TBnem ,1,random(1,5))
    The part about making it not spawn where an object is already i am working on at the minute.
  • SANDEEP410SANDEEP410 Member Posts: 46
    k I managed to acheive the random spawn but how to make it not spawn when an actor is already present.
  • MotherHooseMotherHoose Member Posts: 2,456
    so many ways to get random to work perfectly

    but believe that in your scenario … might be easiest if the enemyActor
    controls it position after the spawn

    Rule: when (All)
    Event: overlaps or collides with rectangle
    Event: overlaps or collides with actor type (select the prototype)
    -changeAttribute: self.Position.X To: tableCellValue(yourTable,row,col)
    again you can use random row or column

    this change of Position.X will happen rapidly … but you could have the alpha change to 0 when overlapped and 1 when not

    example: http://forums.gamesalad.com/discussion/comment/337756

    image MH
  • SANDEEP410SANDEEP410 Member Posts: 46
    K here is what i have done . I have made 2 columns 1st one containing the spawn positions and the 2nd column has the boolean value set to false.
    I have made a small rectangle (invisible) and put in all those spawn position

    Here is what i wana acheive, whenever the rectangle overlaps or colides with enemy i want the table boolean to set it true and when it doesnt overlap it should be back to false.

    However in the change attribute pannel i cant find the option of setting value to true
    Any1 knows how to acheive this.
  • MotherHooseMotherHoose Member Posts: 2,456
    edited August 2012

    in list of behaviors:

    Change Table Value behavior
    (don't ask me why it doesn't say changeTableCellValue ;)

    selectTable … select attribute or type in Row:/Column:
    in Value: type true/false

    image MH
  • SANDEEP410SANDEEP410 Member Posts: 46
    In list of behaviors there is no option of change table value behaviour :((
  • SANDEEP410SANDEEP410 Member Posts: 46
    In list of behaviors there is no option of change table value behaviour :((
  • MotherHooseMotherHoose Member Posts: 2,456
    my Library … Behaviors … Standard:

    Change Table Value

    right below Change Size behavior

    Mac GS

    image MH
  • SANDEEP410SANDEEP410 Member Posts: 46
    I cant figure out how to make this work
    I want actor to spawn if table column value is false.
    That is game will 1st randomly select a number from 1 to 5
    and then coresponding number coulm value is false
    then it should spawn enemy value of that number

    However i am not able to acess my table column values while making the rule

    Any1 knows any other easier way to do this or any work around
  • MotherHooseMotherHoose Member Posts: 2,456
    on enemyActors:
    add attribute … boolean type … name something true/false
    change the colorAlpha to 0

    1st behavior: changeAttribute: self.true/false To: tableCellValue (table?,self.Name,1)
    Rule: when
    Attribute: self.true/false is true
    -Destroy
    Otherwise: changeAttribute: self.Color.Alpha To: 1

    on spawnerActor:
    after the boolean is picked/set in the table
    spawn them all

    image MH
  • SANDEEP410SANDEEP410 Member Posts: 46
    on spawnerActor:
    after the boolean is picked/set in the table
    spawn them all

    Cant understand this
  • MotherHooseMotherHoose Member Posts: 2,456
    @SANDEEP410 … I put a demo in your Inbox

    -MH
  • SANDEEP410SANDEEP410 Member Posts: 46
    It says file cant be opened it requires gamesalad creator version
  • MotherHooseMotherHoose Member Posts: 2,456
    oh okay … am loving the 0.10.0 version … will reset as 0.9.4 for you

    √ your inbox

    image MH
  • SANDEEP410SANDEEP410 Member Posts: 46
    Can you give me the demo in lower version
  • MotherHooseMotherHoose Member Posts: 2,456
    which version?
  • SANDEEP410SANDEEP410 Member Posts: 46
    0.09.94 beta
Sign In or Register to comment.