|
-
Specific Question
Hi all,
I'm new to the boards so I'd like to firstly say hello : ). I'm a student at Kent University working on a flash game as part of a research project involving children. It incorporates a simple game of throw and catch between three people (1 Human player and 2 AI players). The game is designed to ostracise (completely ignore) the player after a certain number of throws and only throw between the two AI players.
Presently I have designed the animations for the game to be visually appealing to children and the initial steps of the coding. I'm very new to flash and have been traulling through tutorials to try and find the specific answers to my questions but this has to lead to countless attempts to tear my own hair out.
I've approached the coding in two ways:
The first I have created the animations for the throws in each direction and put each one on a new scene. My thinking behind this was I could simply have a
man3.onRelease = function() {
goToAndPlay("Scene 2",2);
}
command and it would play out my animation. However, I do not know how to put a 'then' command in which would make the AI players throw either to the other AI or the player based on a mathematical check that reduces the more it's thrown. There would have to be this check and then another command to send it to "Scene 4" else "Scene 5". I hope this makes sense.
The second option was to have everything on the same page and employ it as a collision detection system. The only problem is I do not know how to make the ball travel from the player to the AI on click and then again I don't know how to design the mathematical check that reduces over time.
There also needs to be a score for how many times the player chooses each person to throw to, a link to an external questionnaire at the end of the game and the option to add in a fourth AI and other different variables.
I realise I've taken out quite a hard task for my first ever foray into flash but I would love to hear any comments or advice you guys have .
Thanks very much
LordDaaave
-
Senior Member
Suppose you set variable at the start of your game:
_root.throws = 0;
Every time ball is moved, increase it by 1:
_root.throws++;
Now you can check it to make changes based on its value:
if(_root. throws < 10){
//code to throw to player
}else{
//code to throw to AI
}
Personally I have grown to hate scenes and avoid them. I would put everything in 1 single frame, have each player and its animation in movie clip and the ball in its own movie clip.
For now lets ignore the animations on players and see how to get the ball moving. Lets say in frame 1 of ball movie clip the ball is in the hands of player 1 and now you want it to move to player 2 position. Give frame 1 a label "m12", now whenever you want to move ball from player1 to player2, you can use:
_root.ball.gotoAndPlay("m12");
Create keyframe in frame 40 of the ball mc, position ball at the hands of player2 and make tween between frames 1-40. This will move the ball graphics.
Same way make tween between frame 41-80 to move ball from player 1 to player 3, label frame 41 as "m13". So that will move the ball to player3. In total you need 6 tweens and 6 labeled keyframes.
-
Excellent. Thanks very much. I'll give it a try and let you know how it goes.
Thanks,
LordDaaave
-
Hi, I tried this but each time I click on the player 2 to start the frame it plays it fine and then plays every other frame after that. How do I get it to stop after frames 1-40.
Thanks very much for your help,
LordDaaave
-
Pumpkin Carving 2008
Code:
if (player2._currentframe == 40) {
player2.stop();
}
The 'Boose':
ASUS Sabertooth P67 TUF
Intel Core i7-2600K Quad-Core Sandy Bridge 3.4GHz Overclocked to 4.2GHz
8GB G.Skill Ripjaws 1600 DDR3
ASUS ENGTX550 TI DC/DI/1GD5 GeForce GTX 550 Ti (Fermi) 1GB 1GDDR5 (Overclocked to 1.1GHz)
New addition: OCZ Vertex 240GB SATA III SSD
WEI Score: 7.6
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|