Hello,
Firstly, I apologize if I misplace this thread: I am brand new to these forums, and don’t know my way around yet!
I am a high schooler currently partaking in an internship, and since I am the only person my team with any programming experience whatsoever (I programmed a tiny bit in BASIC around 8 years ago…) I was placed in charge of the software section of our project.
Our project is to make an old-style arcade game complete with the big heavy box w/ buttons. We decided to do a tower defense style game in Flash, where the player presses a button on the box and it selects a tower, and then the player uses a trackball to move the tower where he/she wants it to be, followed by another button that acts as “select”. Since we were given 5 weeks to complete the project (we are on week 4 right now), and I really did not want to dedicate the time to learn flash AND make the game from scratch, I looked up a nice and sweet tutorial on how to make a tower defense game.
I already found and looked up an excellent tutorial on How to Make a Tower Defense Game in Flash, and have followed it and modified it to fit our needs, however there is one thing that is bugging me:
The game created by the tutorial has the player click on the tower icon and then click where to place it, however we want the player to press a button and then click to place it. We figured out how to hook up buttons to a computer (so for example, when you press the button it simulates a “w” being pressed), however I can’t figure out how to change the code so when a “w” is pressed the tower is selected.
Below is the written out code, and if anyone could help me figure out what to change in order to make it so when you press “w” the cursor moves to a specified area and clicks, that would be amazing!!
Thank you in advance,
Jack
Here is the section of the code that runs the event listeners, I am trying to change the Fire Tower part to select the fire tower when the “w” key is pressed:
[COLOR=#000000] setupGame();[/COLOR]
//Initialise the UI event listeners
mcGameUI.btnBuildFireTower.addEventListener(
MouseEvent.CLICK, clickTowerFire);
mcGameUI.btnBuildFireTower.addEventListener(
MouseEvent.ROLL_OVER, showTowerFireHelp);
mcGameUI.btnBuildFireTower.addEventListener(
MouseEvent.ROLL_OUT, clearHelp)
mcGameUI.btnBuildIceTower.addEventListener(
MouseEvent.CLICK, clickTowerIce);
mcGameUI.btnBuildIceTower.addEventListener(
MouseEvent.ROLL_OVER, showTowerIceHelp);
mcGameUI.btnBuildIceTower.addEventListener(
MouseEvent.ROLL_OUT, clearHelp);
mcGameUI.btnBuildLightningTower.addEventListener(
MouseEvent.CLICK, clickTowerLightning);
mcGameUI.btnBuildLightningTower.addEventListener(
MouseEvent.ROLL_OVER, showTowerLightningHelp);
mcGameUI.btnBuildLightningTower.addEventListener(
MouseEvent.ROLL_OUT, clearHelp);
mcGameUI.mouseEnabled = false;
[COLOR=#000000] mcGameStage.addEventListener(Event.ENTER_FRAME,update);[/COLOR]