A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: [F8] Background moves, with mouse guiding.

  1. #1
    Junior Member
    Join Date
    Sep 2008
    Posts
    6

    Question [F8] Background moves, with mouse guiding.

    So the FPS game is going reasonably well, I'm well on the way to having the basic engine done, however after playing quite a few recently, for inspiration and such, I realised that rather than having a moving reticle, the reticle and gun all stay in a stationary position, whilst the background moves.

    I've tried using the VCam to fix this problem, however it's not great, and doens't do what I really want it to do, I've also been told never to use it, as it bugs a lot when used for games... Although if it is neccessary I will obviously use it!

    What I'm really looking to do (in more detail) is have the fun and reticle all stationary. So right in the midle of the screen, then when you move the mouse, rather than the reticle following it all over the screen, the background moves and the reticle and gun stay still.

    If anyone has any ideas how to do it, or even the code I'd really appreciate it!


    George

  2. #2
    President PhobiK's Avatar
    Join Date
    Jan 2005
    Location
    Guatemala
    Posts
    918
    You should play with the _x and _y positions of the background. Take the middle of the screen in both x and y axis and move the background according to the distance of the mouse from the center. I made a very quick example. I just used this code in the background mc:
    Code:
    onClipEvent(enterFrame) {
    	_x = dx + ((dx - _root._xmouse) * mul);
    	_y = dy + ((dy - _root._ymouse) * mul);
    }
    onClipEvent(load) {
    	var dx:Number = Stage.width / 2;
    	var dy:Number = Stage.height / 2;
    	var mul:Number = 2;
    }
    Please tell me if I didn't get the problem
    This is MC. His _parents sent him to stop() by the super market to buy some _root beer if he wanted to gotoAndPlay() with his friends at the park later.

    This is my Blog!... The gaming Process
    Please check out my site: Giddel Creations

  3. #3
    Junior Member
    Join Date
    Sep 2008
    Posts
    6
    Thank you very much for the help it has done exactly what I wanted, I am going to try to adjust it slightly and get the gun and reticle on screen, and go from there thanks a lot!


    George

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