Loops *solved*

For questions about using Classic.

Post » Fri Jul 09, 2010 6:56 am

Hi Guys I'm back and I'm having a new problem.

In my game to do a basic attack you need to press the control 'Action' which uses the 'Enter' key. In a lot of games of action games, I noticed that pressing the same button can play other animations. For example:

Player 1 presses enter and Animation 1 is carried out in game. The second this animation ends a timer is executed to check whether the player has pressed the key again. If he did, the game will play Animation 2. If Player 1 did NOT press the enter key within the time frame and pressed it after the timer, the game play Animation 1 again and the loop is repeated.

This is often used in action games or Star Wars games(Which is what my game is all about).

How can this be achieved? Someone please help me as I can't believe I'm having trouble just doing basic attack moves
____________________________________________________________________________________
If you can help please post the solution on this thread, upload or link an example. DO NOT REUPLOAD THE .CAP WITH YOUR VERSION as I want to try my best to learn it myself.

Note: The events can be found in the 'Lightsaber' event sheet and the Animation 2 is the Lightsaber2 animation.

Thanks a lot for your time.

EDIT: Problem solved, read reply 4 for solution.
B
2
G
2
Posts: 18
Reputation: 686

Post » Fri Jul 09, 2010 10:40 am

I'm new to this but I'd guess use a private varible

press 'enter' and private variable = 0 do the action and set the private variable to whatever amount of seconds you want for your time span

press 'enter' and private variable >0 do the second action.

just a guess, can't test it at the moment. Maybe someone more experienced will answer :)
B
34
S
4
G
8
Posts: 67
Reputation: 5,857

Post » Fri Jul 09, 2010 12:04 pm

[quote="gazoogle":2dxs7dzv]I'm new to this but I'd guess use a private varible

press 'enter' and private variable = 0 do the action and set the private variable to whatever amount of seconds you want for your time span

press 'enter' and private variable >0 do the second action.

just a guess, can't test it at the moment. Maybe someone more experienced will answer :)[/quote:2dxs7dzv]That is definitely a good idea and is a much simpler solution for this problem. It probably could work, I would need to test it. But there's one problem, how am I gonna define when I press enter a second time and the time span if I did not press it a second time.

EDIT: I tested it, still got nothing, I have no idea how to make the animation run when when I press 'Enter' the 2nd time.
B
2
G
2
Posts: 18
Reputation: 686

Post » Fri Jul 09, 2010 6:02 pm

[url:2nhaxrna]http://dl.dropbox.com/u/5426011/examples/doubleattack.cap[/url:2nhaxrna]
req 0.99.9

or in pseudo code:
[code:2nhaxrna]+ MouseKeyboard: On key Enter pressed
+ Anakin: Animation "Lightsaber1" is playing
-> Anakin: Set 'attackAgain' to 1
+ System: Else
+ Anakin: [negated] Anakin: Animation "Lightsaber2" is playing
-> Anakin: Set animation to "Lightsaber1"
+ Anakin: Animation "Lightsaber2" finished
-> Anakin: Set animation to "Idle"
+ Anakin: Animation "Lightsaber1" finished
+ Anakin: Value 'attackAgain' Equal to 1
-> Anakin: Set animation to "Lightsaber2"
-> Anakin: Set 'attackAgain' to 0
+ System: Else
-> Anakin: Set animation to "Idle"[/code:2nhaxrna]

If that isn't what you were looking for let me know.
B
79
S
24
G
53
Posts: 4,732
Reputation: 40,227

Post » Sat Jul 10, 2010 1:06 am

[quote="R0J0hound":2920jt6o][url:2920jt6o]http://dl.dropbox.com/u/5426011/examples/doubleattack.cap[/url:2920jt6o]
req 0.99.9

or in pseudo code:
[code:2920jt6o]+ MouseKeyboard: On key Enter pressed
+ Anakin: Animation "Lightsaber1" is playing
-> Anakin: Set 'attackAgain' to 1
+ System: Else
+ Anakin: [negated] Anakin: Animation "Lightsaber2" is playing
-> Anakin: Set animation to "Lightsaber1"
+ Anakin: Animation "Lightsaber2" finished
-> Anakin: Set animation to "Idle"
+ Anakin: Animation "Lightsaber1" finished
+ Anakin: Value 'attackAgain' Equal to 1
-> Anakin: Set animation to "Lightsaber2"
-> Anakin: Set 'attackAgain' to 0
+ System: Else
-> Anakin: Set animation to "Idle"[/code:2920jt6o]

If that isn't what you were looking for let me know.[/quote:2920jt6o]This is exactly what I'm looking for! Thanks!
B
2
G
2
Posts: 18
Reputation: 686


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 10 guests