Messing with the Joystick Demo

DankStewDankStew Member Posts: 36
edited November -1 in Working with GS (Mac)
Hey there fellow GameSalad users, I have been toying around with Codemonkeys' amazing Joystick Demo template. It's a great help to have something so useful already set up and working so I can dive right in and try to figure out the commands.

Which brings me to my question... is there a way that the joystick controls can be switched so that the moveable actor snaps back to center screen when not in use?

Would this be just setting up a boolean (touch.in.use) with a (move to: 0,0, scene) and have it say whenever the joystick is touched set to false (and true otherwise?).

Essentially I am trying to make it like an aiming system. Thanks!
«1

Comments

  • DankStewDankStew Member Posts: 36
    Whoops, forgot to subscribe to this

    (slaps forehead)
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    The base of each of those joystick sets can be moved anywhere and they should still work.
  • DankStewDankStew Member Posts: 36
    Wow Codemonkey! I have to say thanks for all of the helpful posts and demos you have done, they all really help to learn the program. Looking forward to whats in store for future versions too. Ok, onto the issue:

    Sorry, I think I wasn't clear about what I was trying to do. I meant to keep the actor that moves in the center (the red, blue, green and yellow circle). I want that to be a target that is controlled by the joystick.

    I want that actor (the red, blue, green, and yellow circle) to snap back to center of scene if the joystick isn't currently moving it.

    Thanks again for responding.
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    What you could do is create a boolean game attribute called, "Controlled".
    On the base of the joystick set controlling movement, add the rule
    --Rule: If Event -> Touch -> is Pressed
    ----Change Attribute: game.Controlled = true
    --Otherwise:
    ----Change Attribute: game.Controlled = false

    Then in the beachball actor add the rule:
    Rule: If Attribute game.Controlled is True
    --(use the existing Move behavior)
    Otherwise:
    --Move To: (Coordinates for the center of the screen)
  • quantumsheepquantumsheep Member Posts: 8,188
    What I'd like to know is how to make a control system like that used in Space Invaders: Infinity Gene and Espgaluda2.

    Essentially, the first place you touch on the screen becomes the centre of the joystick, and player movement is calculated in relation to that initial spot.

    Take your finger off the screen and put it somewhere else and *that* then becomes the joystick centre... etc etc

    There's a free version of Infinity Gene in case I'm not explaining myself well enough. You can find it here: http://itunes.apple.com/us/app/space-invaders-infinity-gene/id347875436?mt=8

    It'd be really useful to know how to do this! I've tried a few experiments with it, but no luck. Mainly because I don't fully 'get' how the current joystick demo works. I just copy and paste ;)

    Cheers in advance!

    QS :D

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • DankStewDankStew Member Posts: 36
    Nice! That is perfect. Thanks CodeMonkey!

    @ QS: I can barely even copy and paste it sometimes! :)
  • quantumsheepquantumsheep Member Posts: 8,188
    DankStew said:
    @ QS: I can barely even copy and paste it sometimes! :)

    ahaha! I know what you mean!

    So, anyone have any ideas on the 'finger as origin' joystick method I'm after? A lot of games use it now, and it helps keep the screen clear...

    Cheers,

    QS :D

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    @QS, open up the base actor and add a rule that when mouse button down,
    Change Attribute its position to the mouse position and then change attribute on the game attributes that rely on its position.
  • quantumsheepquantumsheep Member Posts: 8,188
    I'll give that a try! Thanks so much CM!

    /is excited!!!

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • quantumsheepquantumsheep Member Posts: 8,188
    /is less excited

    Ok, the beginning bit (changing attribute to mouse position) is fine. I'd actually thought of that myself would you believe in my experiments!

    It's the second bit. I'm not sure which attributes I should be changing, and to what, exactly...

    Any further input at all?

    /stores up some excitement just in case

    Cheers!

    QS :D

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • quantumsheepquantumsheep Member Posts: 8,188
    I had a good go at this last night, changing this and that and trying to make it work but alas to no avail.

    Has anyone else got this working at all? (where you touch the screen as joystick origin thingy). It would be invaluable for those of us doing top-down shooters.

    Those who've played one of the games I'm working on have all commented that the joystick sometimes obscures their view of the action, and if I'm honest, I have to agree with them (though you do get used to it).

    This would certainly help alleviate the issue though.

    Any help would be appreciated!

    Cheers,

    QS :D

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    Please redownload the Joystick project. There are 2 new actors which are slightly modified from the base and green circle actors. They are used in the new scene. I hope you are only using it for one movable joystick because that is all it works for right now without me needing to think about multiple moving joysticks.
  • quantumsheepquantumsheep Member Posts: 8,188
    CodeMonkey, thank you for taking the time to put this into a new joystick demo. I think it's fast becoming the 'de-facto' method of control for scrolling shooters - especially top down ones with auto fire ;) so it's great that the whole community can take advantage of it!

    And nope, I just need one joystick for now! (can you implement four in future? j/k).

    I'm at work with another 4.5 agonising hours till I get home. Looking forward to trying it out.

    Again, thank you. This kind of stuff is way beyond my simple sheep brain and is way helpful, giving our games a bit more polish I reckon!

    Cheers!

    QS :D

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • CapCap Member Posts: 225
    Wow.The new moving control is totally awesome!
    I probably want to include this, if I ever find time to start coding a game. Is there a tutorial for this moving control somewhere, so I can recode and fully understand it? If not, maybe someone is willing to write one..?! Would love to see that. :-P
  • quantumsheepquantumsheep Member Posts: 8,188
    Cap said:
    Wow.The new moving control is totally awesome!

    Are you *trying* to torture me????

    /Watches clock

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • CapCap Member Posts: 225
    "Are you *trying* to torture me????"

    Sorry. I actually wanted to say: it's so f***ing amazing, it totally blew me away!1!11
    Hope that helps. ;-)
  • quantumsheepquantumsheep Member Posts: 8,188
    Cap said:
    "Are you *trying* to torture me????"

    Sorry. I actually wanted to say: it's so f***ing amazing, it totally blew me away!1!11
    Hope that helps. ;-)

    /cries

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • JamesZeppelinJamesZeppelin Member Posts: 1,927
    Last i checked you could only move it anywhere so long as the camera origin is set to "0"

    is that still a factor?
  • quantumsheepquantumsheep Member Posts: 8,188
    Just wanted to say 'thanks' to CodeMonkey for the addition to the joystick demo.

    It works pretty well. There's a slight 'jump' that the player actor does when you take your finger off and put it back on. I'm wondering if you could put in a rule that says 'don't move the actor if finger is released' or something...

    Still, thanks! It certainly helps! And my dad could actually play the game, where before he just got confused.

    Bless 'im!

    QS :D

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • DankStewDankStew Member Posts: 36
    Ah yes, much thanks to CodeMonkey for the help... and the update to the joystick demo as well! I just checked it out and I like the addition.

    Great work, and thanks again!
  • THRSTNTHRSTN Member Posts: 178
    Ok old thread but just as useful today as 8 months ago.I'm trying to wrap my head around the joystick demo and i had a question, how would i use the single control with rotate stick to make the player turn but when the player lets go of the joystick the image stays facing the direction turned and doesn't snap back to the original/default image/direction?
    AND
    adding images to the direction (left,right,diagonal left or right up or down etc)?

    Thanks
  • QbAnYtOQbAnYtO Member Posts: 523
    So u can download the demo and start ur game from there right? I'm trying to figure to which actor to add the rules to since I can't open the demo on my old ass gamesalad 0.8.7
  • THRSTNTHRSTN Member Posts: 178
    QbAnYtO said:
    So u can download the demo and start ur game from there right? I'm trying to figure to which actor to add the rules to since I can't open the demo on my old ass gamesalad 0.8.7

    kinda
    i love the controls and i want to use that style in my next game but i want to have the player stay facing the direction they where moving.kind of a gauntlet style.
  • QbAnYtOQbAnYtO Member Posts: 523
    oh i see. i need those controls for my game.
  • MarkOnTheIronMarkOnTheIron Member Posts: 1,447
    image

    http://img690.imageshack.us/i/screenshot20110114at112.png

    Insert this code in your controlled actor. You should already have the Constrain rotation behavior you just need to add the rest.
  • THRSTNTHRSTN Member Posts: 178
    thanks mark, im not sure if its just me but that didnt seem to work and i do have those attributes as im trying this on the template.im just gonna walk away for an hour or two and come back and try figuring it out.Codemonkey if you see this post id appreciate the help too

    thanks
  • QbAnYtOQbAnYtO Member Posts: 523
    Yea. I'm really sorry for requesting this but can u or someone make a step by step? That would be so awesome. :)
  • THRSTNTHRSTN Member Posts: 178
    well walking away didnt help and an hour later frustration sets in but im confident with a good night sleep (and this bump) ill figure it out soon.
  • MarkOnTheIronMarkOnTheIron Member Posts: 1,447
    I'll try to do a step by step tutorial.

    1. You have to start with CodeMonkey's joystick demo.

    2. The scene we are looking for is Game1Control (but this can be applied to any).

    3. Find the "Move Me 1 Control" actor and double-click it to open it. among the rule you will find a Constrain attribute on rotation:
    image

    4. Create a rule around it that say When attribute "game.Stick1Grabbed" = true:
    image

    5. Open the otherwise tab and add two Change attributes. The first is Change attribute "self.Rotation" to "game.Angle". The second is Change attribute "self.Motion.AngularVelocity" to "0".
    image

    It works for me.
  • THRSTNTHRSTN Member Posts: 178
    Thanks for the step by step mark I'll be trying that out when I get home (can't wait) I have a sprite sheet Im working with (basic left right up down diagonal. ) where would I be placing those images?
    Thanks again for your help.

    Thrstn
Sign In or Register to comment.