Room Panning Has anyone done a tutorial/discussed how screen panning works?
a) I've got a 1200x600p background image and want the the room to pan with the character as he moves past say 600 horizontal pixels.
b) The second effect I'm trying to create is a screen pan where the character ISN'T moving. ie. character looks at the sunset, screen pans to centre on view of the sunset in the background image (reminiscent of games like Dig).
I've created a blank cast member and used MoveToPoint(), but need the screen to pan with the character. Other options? Comments?
Cheers,
idzol
bigmac- 05-21-2007
You first scenario (following the character) is an automatic feature of the engine. When you have a bgimage larger than the screen, the engine will automatically pan to follow the character as it gets close to the edge. See documentation on the following fields in the room editor: "sEdge" (scroll edge), "sRange" (scroll range) and "%" (percentace of scroll speed relative to the rate of the character's movement).
As for the second... how's your action script? That would be easy enough to write a dirt-simple action to handle. But no, it's not a built-in feature of the engine.
idzol- 05-21-2007
Write what in actionscript Are you proposing an animation of the background panning to sunset in a new frame, and then play that frame when the char looks at sunset?
My concern with this approach is that if the character is currently in view - on the cliff say - the background would move in the animation but the character would remain stationary.
You think Actionscript moving the whole stage (as a new custom TIMe)?
Cheers,
idzol
PS. also just found the thread on scrolling
forumer.com/viewtopic.php?t=105" target="_blank">http://lassie.10.forumer.com/viewtopic.php?t=105
bigmac- 05-21-2007
Re: Write what in actionscript You think Actionscript moving the whole stage (as a new custom TIMe)?
Exactly. Extremely simple... you'll find that there is a DOM diagram of the Lassie architecture contained within the TIMe dictionary. As I recall, the room-level object is called "room" and is located on root. So, you'd just create a handy little TIMe that goes something like this:
function myCoolTIMe(): Void {
_root.room.onEnterFrame = function() {
//ASSIGN THESE VALUES
var xtarget:Number = 100; //total pixel offset that the room should shift to
var inc:Number = 5; //pixel increment (speed) of pan animation
//DON'T TOUCH THE REST
var dir:Number = (xtarget>this._x) ? 1 : -1;
var dif:Number = Math.abs(this._x-xtarget);
if (dif<=inc) {
this._x = xtarget;
delete this.onEnterFrame;
} else {
this._x+=(inc*dir);
}
}
}
Mind you, I just typed that as text off the top of my head so I can't guarantee that my syntax isn't flawed. However, that's the idea... pretty simple stuff if you have an intermediate understanding of AS.
idzol- 05-21-2007
Thanks Mac! Thanks,
I'll be sure to send through the code if/when I get it working. I like the idea of a flash developer community collaborating on this project. I would really like to see LassieAS become the defacto standard for flash adventure games!
Cheers,
idzol
Forumer™ is Voted #1 Free Forum Hosting provider
Build your own community today with the largest message board hosting company.