thanks todd. thats what I have been doing for the most part. I'm
working on figuring out how to move the Camera sprite around on an
angle.

i've got script that makes the airplane point towards the mouse at all
times. but thats the easy part. now i need the Camera sprite to move
at a consistent rate at the same angle the plane is pointing. Just
can't see to figure out what it take to do that.

var minXMove:Number = 0;
var minYMove:Number = 0;
var maxXMove:Number = (levelMap.width - stage.stageWidth) * -1;
var maxYMove:Number = (levelMap.height - stage.stageHeight) * -1;

stage.addEventListener(Event.ENTER_FRAME, pointAtCursor);

function movemap():void {

        
        //move on x-axis
        levelMap.x += speedX;

        if (levelMap.x >= minXMove) {
                levelMap.x = minXMove;
        }
        if (levelMap.x <= maxXMove) {
                levelMap.x = maxXMove;
        }
        
        
        //move on y-axis
        levelMap.y += speedY;

        if (levelMap.y >= minYMove) {
                levelMap.y = minYMove;
        }
        if (levelMap.y <= maxYMove) {
                levelMap.y = maxYMove;
        }
}

function pointAtCursor(e:Event) {
        
        // get relative mouse location
        var dx:Number = mouseX - plane.x;
        var dy:Number = mouseY - plane.y;
        speedX = (dx * -1);
        speedY = (dy * -1);
        
        // determine angle, convert to degrees
        var cursorAngle:Number = Math.atan2(dy,dx);
        var cursorDegrees:Number = 360*(cursorAngle/(2*Math.PI));

        // point at cursor
        plane.rotation = cursorDegrees;
        
        plane.x -= (plane.x-mouseX) / 6;
        plane.y -= (plane.y-mouseY) / 6;
        
        movemap();
        
}

the hard part is getting the speedX and speedY to be numbers that
don't cause the map to fly to fast. Just not sure where to go from
here.




On Sun, Jan 25, 2009 at 2:42 PM, Todd Kerpelman <[email protected]> wrote:
> Well, I'm no plane game expert, but here's probably how I'd approach it...
>
> Within your PlaneGame movie, create a child sprite called Camera.
>
> Make all your interface stuff children of the PlaneGame movie. But make the
> background, your plane, the enemies, etc, all children of this Camera child
> sprite.
>
> Then, when it comes to creating the "background scrolling below you" look,
> don't have your background move at all. Only have the things that would
> actually move in real life (planes and tanks and whatever) move.
>
> Instead, make your Camera sprite scale and/or move itself to track your
> plane (or, even better, a point a couple hundred pixels in front of your
> plane.) That will make it look like the background is moving, but it's
> really staying in place. And it will simplify your planes and tanks and
> bullets, because you can basically just look at each sprite's position and
> velocity, without having to try and somehow compensate for a magical moving
> background.
>
> For development purposes, by the way, I would start your game by not having
> the camera move at all, and just making sure everything works right in a
> tiny little world the size of your screen. Once that's working, then you can
> enlarge the bounds of your world and start moving your camera around.
>
> Good luck!
>
> --T
>
>
>
> On Sun, Jan 25, 2009 at 11:16 AM, Corban Baxter <[email protected]> wrote:
>
>> hey guys! I'm trying to build a simplified version of
>> http://www.miniclip.com/games/skies-of-war/en/. Mostly looking to
>> replicated the movement. But I have no ideas on where to start. I'm
>> having alot of trouble setting the angles correctly to give the
>> background a constant speed but allowing it to change angles. I
>> understand its going to be based on the planes current angle. But
>> that's where I get confused on getting the speeds to not over lap and
>> making it seem like it moving faster. Ok I'm rambling now. but I was
>> hoping someone might be able to help me understand this better and
>> give me some examples I could use to get moving. Any help would be
>> great! thanks!
>>
>> --
>> Corban Baxter
>> http://www.projectx4.com
>> _______________________________________________
>> Flashcoders mailing list
>> [email protected]
>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>



-- 
Corban Baxter
http://www.projectx4.com
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to