Spawning actor based on mouse/finger position

TouchTiltGamesTouchTiltGames Member Posts: 1,162
edited November -1 in Working with GS (Mac)
I'm wondering what Attribute I'd use to spawn my blocks based on where I touch on the screen? Right now I just have them spawning from a block "container" that when touched spawns some blocks but I want to be able to touch anywhere on the screen.

I tried stretching this container to the full size of the screen and making invisible and stuff like mouse.positionX and Y...but it wasn't working, obviously missing something here.

Oh and my game scrolls up.

Thanks in advance if you can help.

Comments

  • RHRH Member Posts: 1,079
    What i would do is basically what you said;

    Create a transparent actor and stretch it to fill the screen.

    Create a rule on it so that when it is touched: spawn actor: character

    for position X select devices.touch1.X (i think that is what it's called)
    and for Y select devices.touch1.Y

    As for the scrollable part, I would create a new layer and make it non scrollable. Place an actor in the middle of the screen, then constrain two attributes, say game.positionX and game.positionY to the actors X and Y coordinates. Then on the large touchable actor constrain it's X and Y to the game.positionX and game.positionY

    I'm no pro with GS but hopefully that should do the trick.
  • TouchTiltGamesTouchTiltGames Member Posts: 1,162
    RH, Thanks a ton. So for the PositionX and Y..do I enter that on the "Position" of the blocks or create an Attribute..or a change attribute rule?

    cheers.
  • TouchTiltGamesTouchTiltGames Member Posts: 1,162
    I added the devices.touch1.x and y to the spawn actor's position and even tried game.mouse.positionx and y...Using the latter seems to spawn a block but nowhere near where you click.
  • TouchTiltGamesTouchTiltGames Member Posts: 1,162
    "As for the scrollable part, I would create a new layer and make it non scrollable. Place an actor in the middle of the screen, then constrain two attributes, say game.positionX and game.positionY to the actors X and Y coordinates. Then on the large touchable actor constrain it's X and Y to the game.positionX and game.positionY"

    This Actor I place on the screen that I constrain, is this just a dummy/invisible actor?
  • TouchTiltGamesTouchTiltGames Member Posts: 1,162
    Ok I solved the spawning a block based on mouse location just by doing a constrain...but as soon as it starts to scroll up when the camera follows the actor jumping up, the spawning block on mouse position stops working...So I gather which is why you suggested the second part of your instructions
Sign In or Register to comment.