-
moving views and split screen (AS3 games development issue)
Hi guys...I'm relatively new to actionscript
- 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)?
- 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
-
Originally Posted by glider521al
[*]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.
-
-
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|