Touch 1 - Move Actor 1 Touch 2 - Move Actor 2

TheBoss_123TheBoss_123 Member Posts: 60
edited November -1 in Working with GS (Mac)
Hey Forum,
Needed a little bit of help. cant seem to get this to work.
If I touch the screen - Actor 1 moves to my finger
If i touch the screen again - Actor 2 moves to my finger
Again - Actor 1 moves to my finger
Again - Actor 2 moves to my finger
ect
ect
Cheers
TheBoss_123

Comments

  • scitunesscitunes Member, Sous Chef Posts: 4,047
    create an integer attribute: game.actorNumber

    have this rule

    when touch is pressed change game.actorNumber to (game.actornumber+1)%2

    Then have a rule when touch is pressed
    -----when game.actornumber=0
    ---------move rules for actor 1
    -----OTHERWISE
    ---------move rules for actor 2
  • TheBoss_123TheBoss_123 Member Posts: 60
    Doesnt work??
    Only works once,
  • TheBoss_123TheBoss_123 Member Posts: 60
    This is my game.
    I have 2 Buttons on the Hud - One red - One blue
    Press the red one and wherever i press next Actor 1 moves to the touch
    Press the blue one and wherever i press next Actor 2 moves to the touch.

    What I have so far.

    Inside Red Button

    When red button is pressed inside
    change att game.touch = 1

    In Actor 1
    Attrib game.touch = 1
    slf.pos.x to mouse.pos.x
    slf.pos.y to mouse.pos.y

    However this does not let me place it but rather places Actor 1 where the red button is, however i want it to be placed where i press the second time. And also the game is scrollable so I need the actors to move porperly even when i have scrolled
    Cheers
    TheBoss_123
  • AppsRacKAppsRacK Member Posts: 346
    yes it will spawn on the icon because you told it too with this code "spawn actor 1 to mouse x and mouse y".

    first - your gameplay seems a bit simple that it doesnt required S&D (spawn & destroy). You just need to place it outside of the scene which is way easier.
    second - dont place the control on the buttons. Just use the buttons to change an attribute and let the actor react to it.
    ex: game.ActorID
    BUTTONS
    if red is pressed
    game.ActorID = 1

    if Blue is pressed
    game.ActorID = 2

    ACTOR1
    if game.ActorID = 1
    move me to happy place
    otherwise
    Hide me

    ACTOR2
    if game.ActorID = 2
    move me also to happy place
    otherwise
    Hide me

    :)
  • TheBoss_123TheBoss_123 Member Posts: 60
    How can i make it move to a second touch NOT the first touch
    so this part
    move me to happy place
    doesnt seem to work...edited previous post to see what i did
  • AppsRacKAppsRacK Member Posts: 346
    well you need to add another rule on the actor besides game.ActorID.
    Actor.
    First make an invisible actor and fill out the whole scene except your hud. Unlock this one and place a rule inside.
    RULE
    if this s pressed
    Change attribute game.MoveAnActor = TRUE
    change attribute game.touchX = mouse.position.X
    change attribute game.touchY = mouse.position.Y

    if release
    Change attribute game.MoveAnActor = FALSE

    ACTOR1
    if game.ActorID = 1 && MoveAnActor = TRUE
    move me to happy place (using touchX & touchY)
    otherwise
    Hide me

    :)
  • TheBoss_123TheBoss_123 Member Posts: 60
    Fixed.
    Created another actor which controls where to place it
Sign In or Register to comment.