Reloading a Weapon

crapscraps Member Posts: 353
edited November -1 in Working with GS (Mac)
I have finally worked out a working "swipe" function to throw an object.
After the actor is thrown how do I get another actor to appear and ready to go?
I would also like to limit the number of actors to be thrown.

Any help?

Comments

  • osucowboy18osucowboy18 Member Posts: 1,307
    Hey Craps,

    The only way I can think of doing this is by having a boolean game attribute, (game.ReadyToReloadActor) for example, and setting up a rule within the actor that will be thrown stating that whenever the "swipe" function occurs, change game.ReadyToReloadActor to "true". Next you will need to set up another rule somewhere else in the same scene stating that if game.ReadyToReloadActor is true, then spawn the appropriate actor at the appropriate X and Y position relative to the scene. After the actor has been spawned to the correct position, change game.ReadyToReloadActor back to false so the actor can be reloaded multiple times.

    As far as limiting the number of actors to be thrown, this can be done by adding an integer game attribute (game.NumberThrown), and adding to the second rule mentioned above stating that if game.numberThrown is less than X, where X is the number of throws allowed, then, as mentioned in the second rule listed, spawn the appropriate actor to the appropriate X and Y position.

    Hope this helps...and let me know if you have any more questions.
  • crapscraps Member Posts: 353
    Thanks for such a detailed explanation - I will give it a try.
  • osucowboy18osucowboy18 Member Posts: 1,307
    No problem. By the way, I have tried to implement a "Swipe" function to some of my iPhone apps before, but never got it completely figured out. How were you able to create your swipe function?
  • crapscraps Member Posts: 353
    I used the "The Class Clown Throw Down" demo.
    I was a real pain to change around. I never was able to rebuild the function by myself.
    Instead I adapted my app to it.

    I really did not understand a lot of how it worked but was able to change enough to make it work for me by playing with many of the variables and rules.

    Still have not figured out how to keep the object being thrown from being pulled off the bottom of the screen.
  • crapscraps Member Posts: 353
    craps said:
    I used the "The Class Clown Throw Down" demo.
    I was a real pain to change around. I never was able to rebuild the function by myself.
    Instead I adapted my app to it.

    I really did not understand a lot of how it worked but was able to change enough to make it work for me by playing with many of the variables and rules.

    Still have not figured out how to keep the object being thrown from being pulled off the bottom of the screen.

    I would be nice to have a simple complete demo or tutorial of this build.
  • crapscraps Member Posts: 353
    osucowboy18

    Thanks the reload worked great. But it only reloads once. Will I have to make a rule with +1 somehow like making a life bar so it will reload multiple times?
  • osucowboy18osucowboy18 Member Posts: 1,307
    You need to make a rule that sets the boolean game attribute, game.ReadyToReloadActor, back to its original state, which should be false. This rule should not be placed within the throwable actor, but somewhere else in the same scene. By doing this, you should be able to reload the throwable actor more than once. Hope this helps.
  • crapscraps Member Posts: 353
    I placed the attribute (back to false) right after the "spawn actor" behavior (not in the actor to be thrown)
    It sort of works - if you click/touch the actor to be thrown it will continually spawn another actor - over and over again. But, if you thrown the actor it will only spawn one actor.

    Then made a rule that when the mouse/touch was clicked change attribute back to false - this did not work.
  • osucowboy18osucowboy18 Member Posts: 1,307
    Sorry to hear that :( Since that rule is not working properly, delete it, as well as the other rule somewhere else in the scene that changes game.ReadyToReloadActor to false, and try this rule. In the actor that will be thrown, create a rule stating that whenever that actor is swiped, spawn the same actor at the appropriate X and Y position relative to the scene. In order to make it look like the actor is actually "reloaded", you may want to consider putting the spawn actor behavior into a timer. The end result of this would be that if the actor has been swiped, after X seconds, where X is the number of seconds before the actor is reloaded, spawn the actor at the appropriate X and Y position. Note that the timer behavior is not critical to the reload behavior you are trying to achieve, however, it does add somewhat of an effect. Unfortunately, since I don't have a working swipe function to test these rules out with, I am not sure if they will work. Let me know if you have any more questions.
  • crapscraps Member Posts: 353
    Thanks again - I went back to the first attempt and got it to spawn actor after actor. Trying to get the "limit shots" I made a

    game attribute (integer 4)-numberThrown.

    Rule - swipe/ mouse down
    Attribute-numberThrown<4

    then
    Spawn actor

    But of course it continues to spawn.
  • osucowboy18osucowboy18 Member Posts: 1,307
    The reason your actor continues to spawn is because you never update game.numberThrown. To do this, put the following change attribute behavior after the spawn actor behavior in the rule you mentioned in your last post.

    Change Attribute game.numberThrown to game.numberThrown + 1

    Give this a try and let me know how it works.
Sign In or Register to comment.