dcsimg
A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: moving views and split screen (AS3 games development issue)

  1. #1
    Junior Member
    Join Date
    Nov 2009
    Posts
    21

    Question moving views and split screen (AS3 games development issue)

    Hi guys...I'm relatively new to actionscript

    1. How do you move the workspace dynamically using AS3 (say in a platform game where the viewable area pans around the player)?
      • One suggestion was to make everything move relative to the player:
        • Is there a way to group all movie clips together, without creating and iterating through an array?


          For example there could be one holder movie clip which all viewable objects (apart from the background image) are attached to. Each of the objects could have x and y coordinates relative to the holder movie clip.
          I don't know how to do this though.
      • Is there a better way (i.e. changing the x and y offset of the workspace dynamically)?



    2. Say if one was to make a multiplayer game where each level is over 4000x4000 px in dimensions.
      How do you split the screen with AS3 so that each player has their own view of the level?


    Thanks in advance for any replies

  2. #2
    Junior Member
    Join Date
    Dec 2009
    Posts
    15
    Quote Originally Posted by glider521al View Post
    [*]Is there a better way (i.e. changing the x and y offset of the workspace dynamically)?
    The way this is traditionally done is by using a transformation matrix as a "camera", and then transforming the workspace by the inverse of this camera matrix. This will allow for translating, scaling (zooming), rotating etc.

    I'm sure that sounds scary if you've never done it before, but the pseudocode would go something like:
    Code:
    var camera:Matrix = new Matrix();
    camera.tx = player.x; camera.ty = player.y;
    var inverse:Matrix = camera.inverse();
    world.transform.matrix =
        world.transform.matrix.multiply(inverse);
    ...or something similar. The multiplication/concatenation order might be wrong, the AS3 Matrix class tends to be a pain in the ass, so the functions calls might not be so straight forward, etc.

    How do you split the screen with AS3 so that each player has their own view of the level?
    I guess you'll have to copy the level to two (or however many) separate bitmaps or something along those lines, as a quick test in AS3 shows that child clips can't have multiple parents. There may be better solutions, but preliminary searches aren't promising.

    At any rate, and this may go without saying, each screen would have its own camera matrix, and each copy of the world would be transformed by the respective inverse.

    Last, and this also probably goes without saying, the camera matrix itself can be part of a larger whole--for instance a Camera class which acts more like a physical object in-game, allowing for spring mechanics, shaking, etc.

  3. #3
    Junior Member
    Join Date
    Nov 2009
    Posts
    21

    Smile

    Wow thanks for the tips freshmaker

    After doing some further research I found that a genius named Bryan Heisey has invented a an opensource virtual camera using actionscript 3.

    It can be found at http://bryanheisey.com/blog/?p=1

    I.e. a movie clip stores a snapshot of its current position as bitmap data which it draws on to the stage.


    __________________________________________________ ______



    After hours of painful trial and error, I've modified the Actionscript 3 version of VCam, to be contained in an external actionscript file and to support split screen mode.


    I'm not sure if I've ironed out all the glitches out yet though, as my trial version has expired and I'm still waiting for delivery of the registered version



    I'll try and have a tutorial up and running in a week or 2...

  4. #4
    Junior Member
    Join Date
    Nov 2009
    Posts
    21
    So sorry for forgetting to post a link.
    I've uploaded a tutorial for achieving split screen in flash on youtube.
    http://www.youtube.com/watch?v=yuhJkEWAbq8

    There will be 2 other parts:
    -Tweening camera views
    -A way to use split screen in games

    (The filming of the other parts may take a while as I'm at uni)

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