need help getting actor to move to the mouse click

bootpbootp Member Posts: 5
edited November -1 in Working with GS (Mac)
I need my actor to move towards the mouse automatically so you don't have to keep the mouse pressed. I would like screenshots as I've seen processes talked about but don't understand acne need screenshots or a video. Will be very grateful.

Regards
Niall

Comments

  • calvin9403calvin9403 Member Posts: 3,186
    let me make a demo for you
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    Hi Niall, there's a help file somewhere under the Support button at the top of this Forum > Help. although I can't find it at the moment but it's somewhere there. There's also > Cookbook where you'll find some terrific help videos by tshirtbooth on lots of aspects of GS, if you didn't know they were there.

    Basically if you want your actor to move towards the mouse coordinates other than when the mouse is down, simply change down to up.

    If you can't find the help file, here's one way of doing what you're after:

    Make a boolean attribute called Go

    Put one actor over the complete scene to register the mouse clicks/touches.

    In its Rules:
    When actor receives event: mouse button is down
    Change Attribute game.go To false

    When actor receives event: mouse button is up
    Change Attribute game.go To true

    And then in the following actor's Rules:
    When Attribute game.go is true
    Move To Behaviour: in the X box put game.Touches.Touch1.X and in the Y box put game.Touches.Touch1.Y
    Relative to Scene, speed whatever you want; keep Run to completion unchecked.

    Hope that helps!

    :-)

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • calvin9403calvin9403 Member Posts: 3,186
    you are too fast!
    anyway here it is
    http://gamesalad.com/ontheappstore/23468
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    calvin9403 said:
    you are too fast!
    anyway here it is
    http://gamesalad.com/ontheappstore/23468

    Well done Calvin9403... (But I still beat you; hee!) :-)

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • calvin9403calvin9403 Member Posts: 3,186
    I should have post it not make a demo
  • bootpbootp Member Posts: 5
    Hi thanks for your replies but where duo I have to create the boolean as I can't find anywhere acnd where I can create I can't change any rules in it!
    Regards
  • calvin9403calvin9403 Member Posts: 3,186
    hit the plus sign on the attributes section
    also watch these vids

    http://www.youtube.com/user/GameSaladCookbook#p/

    ______________________________________
    http://www.gamesaladforum.com/
  • bootpbootp Member Posts: 5
    thanks know how do i change go's rules?

    screenshots

    very new like an hour new.
  • calvin9403calvin9403 Member Posts: 3,186
    interpolate will be better than move

    try my demo
  • bootpbootp Member Posts: 5
    doesnt load pal.

    even with plug in

    can you describe how to get the actor to move towards the last click position please
  • bootpbootp Member Posts: 5
    gyroscope said: Hi Niall, there's a help file somewhere under the Support button at the top of this Forum > Help. although I can't find it at the moment but it's somewhere there. There's also > Cookbook where you'll find some terrific help videos by tshirtbooth on lots of aspects of GS, if you didn't know they were there. Basically if you want your actor to move towards the mouse coordinates other than when the mouse is down, simply change down to up. If you can't find the help file, here's one way of doing what you're after: Make a boolean attribute called Go Put one actor over the complete scene to register the mouse clicks/touches. In its Rules: When actor receives event: mouse button is down Change Attribute game.go To false When actor receives event: mouse button is up Change Attribute game.go To true And then in the following actor's Rules: When Attribute game.go is true Move To Behaviour: in the X box put game.Touches.Touch1.X and in the Y box put game.Touches.Touch1.Y Relative to Scene, speed whatever you want; keep Run to completion unchecked. Hope that helps! :-)
    Can you explain about the 2 actors in this because I don't understand.
    I will really appreciate your help.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    Hi bootp, just read that you're new: welcome to GS and the Forum! Here's hoping you make some fine games. Remember though, it's quality, not quantity! ;-)

    I've got the idea that, seeing as you've just started, you haven't even run through any help stuff at all, so OK, I'll run through it for you step by step:

    • Make a boolean attribute called Go

    An attribute is a variable, if you are familiar with any sort of progging. If not, it's a way of giving something a value, then the ability to change that value. There are different types of attributes, you'll find explanations in the help files, etc. The one we want is a boolean. This type of attribute can be considered a switch, or true and false.

    In the Game Inspector, click on the button marked "Attributes". you'll see there are some already there as default.

    Now click the + sign. A dialog will appear to pick a type. Boolean will already be selected. Click Choose. The new attribute will appear at the end of the list. Double-click the words "New Attribute, and rename it Go, press return. (You can name attributes to whatever you want). You'll notice the check box is unchecked; leave it like that. This means that the attribute Go is set to 0 (zero) or false.

    • Put one actor over the complete scene to register the mouse clicks/touches.

    Click on the Game button, add a new actor with the + button.

    Drag the actor onto the stage/screen. Move it to the top left corner of the screen and hold down on the bottom right of the actor and drag it to the bottom right of the screen. Then double-click it. This'll bring you to the actor's editor page where you can put in Rules.

    There are two types of Actors: Prototypes and Instances. You can learn about these from help files/vids, etc.

    Click on the button in the top left corner which is called Edit Prototype. Click on button in top right which is marked Create Rule.

    In the behaviours list on the left, drag the behaviour called Change Attribute to where it says Drag your behaviors here (first one). Click on the 3 little dots, the Attribute Browser will appear, so we can find our attribute we made. Click on Game then in the next column, double-click on Go. Now after where it says "To:' click in the box and type the word false.

    Hold mouse down on the grey bar at the top, where it says Rule, and with alt held down, drag down so that a copy is made. Where it says "down" in this second one, hold it and select "up".

    Now change false in this second one to true.

    Click on the Scenes icon and select Initial Scene. Make another actor, drag it onto the screen. Double click it. In the left column, click the white box next to Color, select a colour.

    Click on Edit Prototype button. Click on Create Rule.
    Hold on "Actor Receives event and select Attribute. Find "Go" again by clicking on the three little dots.
    Drag over a Move To behavior from the list on the left.

    click on the first "e" symbol, this brings you to the Expression Editor. Click on first down arrow, click on Devices, then Touches, then Touch 1, then double click the X. Click green tick symbol.

    Click the second "e" symbol, same as above except at the end pick "Y". You can experiment with the speed later, but for now, make it 100.

    OK, if you run through all that step by step, it'll start to click into place for you. Good luck!

    :-)

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

Sign In or Register to comment.