Gamesalad seems to want to press two 'buttons' at once!

sebleseble Member Posts: 4
edited August 2013 in Working with GS (Mac)
Hi all. First time posting here.
As part of an app I am working on, there is a keyboard involved. Now I've put the sounds in for the black keys today and there appears to be a problem. The Black keys as you know sit on top of the white keys of the piano - but for some reason whenever I press a black key on gamesalad it seems to want to play a white key too! I've included a video to reference as it might be quite difficult to explain what I mean otherwise.



Can anyone help?

Comments

  • FallacyStudiosFallacyStudios Member Posts: 970
    Well the problem is that currently in gamesalad there isn't really much of a method to detect them individually (although that is something very complex to do on a touch device anyways). One method I use for similar scenarios is to use a boolean to determine if one is being clicked already, but that won't work for you because it is very likely that a person may press both those keys. At which point it won't function properly.

    So my suggestion would be to have your images down underneath, but don't have the white keys with the Pressed rule. Instead put that rule inside an invisible actor that you put over the white keys, BUT it can only extend up near the black key. If it overlaps on the black key you will just have the same problem. So how you could lay this out would be something like...

    If you have a boolean for each white key determining if it is pressed or not, you would have the invisible actor sitting over the white key On Touch Press change the boolean. Then you simply have the keyboard images respond to the boolean as though it was touched in your video above.

    I hope that makes sense.
  • sebleseble Member Posts: 4

    @FallacyStudios said:
    Well the problem is that currently in gamesalad there isn't really much of a method to detect them individually (although that is something very complex to do on a touch device anyways). One method I use for similar scenarios is to use a boolean to determine if one is being clicked already, but that won't work for you because it is very likely that a person may press both those keys. At which point it won't function properly.

    So my suggestion would be to have your images down underneath, but don't have the white keys with the Pressed rule. Instead put that rule inside an invisible actor that you put over the white keys, BUT it can only extend up near the black key. If it overlaps on the black key you will just have the same problem. So how you could lay this out would be something like...

    If you have a boolean for each white key determining if it is pressed or not, you would have the invisible actor sitting over the white key On Touch Press change the boolean. Then you simply have the keyboard images respond to the boolean as though it was touched in your video above.

    I hope that makes sense.

    Thanks, that makes sense. I can't believe it's taken me almost a year to get back to you. Having fallen ill and then being student means I'm only just resuming this project now! I completely get what you're saying, however when I go to create a rule for this particular invisible image laying over the 'key' it won't allow me to change the image of the other key so it doesn't look like it's being 'pressed' or am I missing something here?

  • ArmellineArmelline Member, PRO Posts: 5,369

    In the Spare Code thread someone - @RThurman if I remember correctly - posted a method for only having the top actor register a touch. It should solve your problem. Sorry I can't direct you to the specific post :(

  • sebleseble Member Posts: 4

    @Armelline said:
    In the Spare Code thread someone - RThurman if I remember correctly - posted a method for only having the top actor register a touch. It should solve your problem. Sorry I can't direct you to the specific post :(

    Thanks, I will have a look now for this!

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880

    @seble‌ -- I think @FallacyStudios‌ meant something like the attached demo.

  • ArmellineArmelline Member, PRO Posts: 5,369

    @RThurman said:
    seble‌ -- I think FallacyStudios‌ meant something like the attached demo.

    I think he'd be better off (though six of one, half of dozen of the other) with your layers demo.

    I don't remember what you called it (if it was you) but it was the method

    Change Attribute game.Layer to game.Layer+1
    Change Attribute self.Layer to game.Layer+1
    If self.Layer > game.Layer then
    etc. etc.

    I use it regularly now and it's extremely handy.

  • sebleseble Member Posts: 4

    @RThurman said:
    seble‌ -- I think FallacyStudios‌ meant something like the attached demo.

    This was exactly what I needed to solve the problem, I hope employing it this way won't cause problems later down the line when things get a bit more complex, but thanks so much everyone, you've really helped me, and the demo helped me understand exactly what i was doing wrong with the attributes. Note to self, attributes are case sensitive!

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598

    Hi @seble Good advice from @Armelline & @RThurman there is yet another solution to your problem - though this is on the assumption that the player of the keys don't usually use/press the thin bits of white directly next to the black keys...

    But I don't think most people do anyhow... so simply add invisible actors over the areas of white at the bottom of each white key, just under the black keys, and transfer the rules from the white key actors to these transparent overlay ones.

    Here is showing the area I'm talking about on one of the white keys:

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

Sign In or Register to comment.