when key pressed player move but return to inital position?

hi all,
i need script for when key pressed player move but return to inital position?
thanks

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    You'll need to be more specific. Do you want the actor (player) to move to a new position and then immediately move back to the initial position? Or do you want the actor to pause at the new position before returning to the initial position? Do you want the actor to move through the whole cycle (initial location-->new location-->initial location) after you press and release a key or only while you are holding down a key?

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

  • yes for example
    player is at point 1
    when we pressed key and realese it , he move to point 2 and return to point 1

    no i dont want him pause new position
    i want him return immetiatly to initial position
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited February 2014

    Hi @neo_matrix31@hotmail.com

    Try this: two integer attributes, call one PosX and put your actor's starting X position as its value, and PosY, similar but with initial Y position. Also make a boolean called Go.

    Rule: When key S is pressed and Go is false--- or whatever other key you want
    Change attribute Go to true

    Rule: When key S is released and attribute Go is true
    Interpolate self.Position.X to ?? Duration: 2 seconds --- 2 secs as an example
    Interpolate self.Position.Y to ?? Duration: 2 seconds
    Timer: After 2 seconds
    Interpolate self.Position.X to PosX Duration: 2 seconds
    Interpolate self.Position.Y to PosY Duration: 2 seconds

    Timer: After 4 seconds
    Change attribute Go to false

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

  • really i dont understand
    can you make simple example
    thanks
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598

    OK, I will, hopefully a small test will help you to learn. Just give me five mins...

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

  • thanks the problem that i dont understand here

    Rule: When key S is pressed and Go is false (how to make 2 rules conditions ? i use group ) --- or whatever other key you want
    Change attribute Go to true
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited February 2014
    thanks the problem that i dont understand here

    Rule: When key S is pressed and Go is false (how to make 2 rules conditions ? i use group ) --- or whatever other key you want
    Change attribute Go to true
    Are you using windows version? If that's the case, I'm afraid i don't know how you'd put two conditions with "And" together, if that's not the same as like on the Mac... hopefully someone else more knowledgable with Windows GSC will jump in here.

    I've made an example for you but it's for a Mac...don't know if it'll help you... (guys, can Windows users open mac gameSalad files? I should know that , but don't!)

    Anyhow, here it is, hope it helps:

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

  • i have windows version ... and i dont find how to put 2 conditions ...
    and i think this what you try to learn me !!!!
  • YES YES YES MAGIC WONDERFULLL
    I LIKE YOU MANNNNN
    you give me way ... and logic

    the solution was
    rule ... when touch is pressed ... interpole attribute player to his position y
    make timer for 2 seconds and interpolate attribute to his position y
  • hi
    i really really really thanks you for your help
    you make me understand logic of gamesalad
    now
    i try some thing with interpolate and selfposition but always bug

    i show you picture of what iam need
    thanks

    http://www.hostingpics.net/viewer.php?id=742201Nouvelleimagebitmap.jpg

    WHAT DO YOU THINK?, WHAT I HAVE TO DO ?
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited February 2014

    Hi, please find attached a test game file for what you're after. Hopefully this Mac version can be read via the Windows GSC so you can learn what's going on (which is very straightforward).

    Btw, have you gone through the Manual? If not, you'll find it very helpful, especially if you're new to GameSalad. You can download a copy by pressing Help tab found at the top of this web page.

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

  • thanks a lot
    but not work because i have windows version
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited February 2014

    OK, I've found out that most Mac GSC files should now run on a Windows machine running GSC. So download the above file and decompress it.

    Now is it showing as a folder on your machine? If so, open the folder and double-click the .gsproj file...fingers crossed it'll open.

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

  • no it not work
    when i open your file
    i have no actor no behaibviors nothing
    and when i play the scene
    i only see the red touch here button
    and when i click on it nohting happen

    i dont know how to thank you
  • can you just write me here all behaviors ?
    about touch button ... thing 1 and thing 2
    thanks
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited February 2014

    ..and when i play the scene
    i only see the red touch here button..
    Hmm, that's strange, the "Touch Here" button I made is green... !

    OK, before anything else, check to see that you've got the game file set up as iPad Landscape in Project Info. (The screen size might not have picked up properly from Mac into Windows for some reason and is too small, so hiding the other two actors...)

    If that doesn't solve it, then I'll type out the programming here as you suggested.

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

  • hahah its green
    i see it in red ... or maybe i have dalton :D
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598

    I've no idea what "dalton" is... :-? But hey, doesn't matter what colour it is!

    So did you try changing the screen size as I suggested? Either way, here are the straightforward rules (in Mac format, I'm sure you can amend for Windows terminology):

    Note that the following y coordinates are based on the "Thing" actors being 100 x 384 each, and on an iPad landscape scene. Obviously change accordingly to your spec.

    -- make a boolean called Go

    --"Touch here" button:--

    Display Text Touch here

    Rule: When touch is pressed
    Change Attribute Go to true

    Rule: When touch is released
    Change Attribute Go to false

    ---Thing 1 actor---
    Display Text Thing 1

    Rule: When scene.Go is true
    Interpolate self.Position.Y to 576
    Otherwise
    Interpolate self.Position.Y to 730

    ---Thing 2 actor---
    Display Text Thing 1

    Rule: When scene.Go is true
    Interpolate self.Position.Y to 192
    Otherwise
    Interpolate self.Position.Y to 38

    OK, hope we're there now.

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

  • yes thanks a lot
    but about returning initial position !?
    look good to your behaviors !!!
  • when i try to rule change attribute scene go to true or false ... i dont find scene in attribute options !!!
Sign In or Register to comment.