A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: Helicopter Game: mouse-guided?

  1. #1

    Helicopter Game: mouse-guided?

    I'm building a helicopter game:
    www.blindslim.com/copter

    Right now, the arrow keys and the spacebar control the helicopter.

    I WANT the mouse to control it:
    mouse button: altitude (fly, or don't)
    And moving the mouse forward moves the copter forward, etc.

    It seems like there would be an easy way to convert my current code to make this change.

    I'm close with getting the mouse button to work. But my question pertains more to the directional guidance.

    HOW can I do this? Tracking mouse coords? Anybody got a quick idea on this thing?

    + + + + + + + + + + + + + +
    shut up, I know I'm right!

  2. #2
    Ninja Rider Jhonte's Avatar
    Join Date
    Sep 2004
    Location
    Uppsala,Sweden
    Posts
    253
    Just make the helicopter "fly" to the position of the mouse then.

    Feels like that if you construct it so that if you move your mouse forward, the helicopter will fly forword you get a strange feeling that the helicopter will fly very strange.

    To get it smooth, just let the helicopter move towards the pointer.

    You have the mouse x and y coordinates in:
    _root._xmouse and
    _root._ymouse


    Nice enviroment in the game!
    Show me the way to the next whiskeybar ...

  3. #3
    Junior Member
    Join Date
    Dec 2004
    Posts
    15
    hi could you tell me how to get the mouse button to move a movie clip
    i like youre helicopter game is th helicopter 3d what program did you make the helicopter with
    thanks bob

  4. #4
    Junior Member
    Join Date
    May 2007
    Posts
    11
    would someone be able to give a more detailed script of how to use the mose button to controll vertical axis of helicopter

  5. #5
    Banned
    Join Date
    Mar 2007
    Location
    Albania , prishtina
    Posts
    274
    I dont know if this is what you wanted ... but , try this code :

    Code:
    onEnterFrame = function(){
    	if (_ymouse > _root.Copter._y){
    		_root.Copter._y += 5;
    	}
    	if (_ymouse < _root.Copter._y){
    		_root.Copter._y -= 5;
    	}
    	if (_xmouse > _root.Copter._x){
    		_root.Copter._x += 5;
    	}
    	if (_xmouse < _root.Copter._x){
    		_root.Copter._x -= 5;
    	}
    }
    I hope this is what you wanted ... and instead of spacebar you can use onPress ...

    Thanks...

  6. #6
    Ninja Rider Jhonte's Avatar
    Join Date
    Sep 2004
    Location
    Uppsala,Sweden
    Posts
    253

    example

    something like this if you have a mc that is called "h".

    Code:
    h.onEnterFrame = function() {
    	this._x++;
    	this._y++;
    };
    _root.onMouseDown = function() {
    	_root.h.onEnterFrame = function() {
    		this._x++;
    		this._y -= 1;
    	};
    };
    _root.onMouseUp = function() {
    	_root.h.onEnterFrame = function() {
    		this._x++;
    		this._y++;
    	};
    };

    But you want of course the background to move instead of the helicopter..

    good luck!
    Show me the way to the next whiskeybar ...

  7. #7
    Senior Member Speed85's Avatar
    Join Date
    Apr 2007
    Posts
    292
    By vertical do you mean y axis or the z axis?

    In either case see if this helps:
    Last edited by Speed85; 08-13-2007 at 02:46 PM.

  8. #8
    When in doubt ask Eager Beaver's Avatar
    Join Date
    Feb 2007
    Location
    Planet Earth
    Posts
    911
    Please watch the attached movie.
    Last edited by Eager Beaver; 08-19-2007 at 02:23 PM.
    <signature removed by admin>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center