Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // For simple tower defense game.
- import twd; // Use the class file twd.as
- var twdgame = new twd();
- var wp_x;
- var wp_y;
- _root.onLoad
- {
- // Add the actual playing field for the game.
- myBoard = _root.attachMovie("twd_board_a", "twd_board_a", 100, {_x:0, _y:0});
- // Add the life box UI component to the board.
- _root.attachMovie("mo_txt_lifebox", "mo_txt_lifebox", 120, {_x:700, _y:550});
- // Add a test "tower" to the board.
- _root.attachMovie("twd_tw_basic", "twd_tw_basic", 500, {_x:170, _y:200});
- loadWpCoords(myBoard); // Load up the critter pathpoints.
- }
- // Fill the Array with the appropriate X,Y waypoint coords.
- // This is for creep pathfinding.
- // Since the boards can be different, so too can these. Should be
- // generated every time. (for now)
- function loadWpCoords(myBoard:MovieClip) {
- var myStr:String;
- var wpNum:Number;
- wpCount = 1;
- // wp_start = first one
- wp_x[0] = myBoard.wp_start._x;
- wp_y[0] = myBoard.wp_start._y;
- // First goes through every object inside board
- for (var mov:String in myBoard){
- if (mov.substring(0, 3) == "wp_"){ // If first 3 letters match proper tag..
- wpNum = int(mov.substring(3,5)); // Grab the actual number.
- wp_x[wpNum] = [mov]._x; // This line is the problem, can't reference
- trace(wp_x[wpNum]);
- //wp_y[wpNum] = mov._y;
- wpCount++;
- }
- }
- // wp_end = last wp, tack on at end
- wp_x[wpCount] = myBoard.wp_end._x;
- wp_y[wpCount] = myBoard.wp_end._y;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement