Vcam in AS2, help!
i need making vcam follows character in as2. vcams tried way laggy i'd love other alternatives. seems one, it's in as3, if me out converting as2 or finding alternatives forever in debt! thanks!
here's as3 code
import flash.events.event;
import flash.geom.rectangle;
stage.addeventlistener(event.enter_frame, camerafollowcharacter);
function camerafollowcharacter(event:event){
root.scrollrect = new rectangle(_root.main.x - stage.stagewidth/2, _root.main.y - stage.stageheight/2, stage.stagewidth, stage.stageheight);
}
i sure reason above code laggy because new rectangle object being made each frame. inefficient. if use objects, make more sense create object outside of function , change x/y positions , width/height of rectangle object (i don't see need update width/height if making follow player unless zooms in , out.
as code in as2:
give vcam identifier name clicking movieclip , going it's properties. example 'mcvcam'. once have done this, on each frame set x , y position of vcam player's:
onenterframe = function(){
mcvcam._x = player._x;
//seeing as3 code seems player called 'main', may wish use instead of 'player'.
mcvcam._y = player._y;
};
edit: oh , code goes on main timeline
More discussions in ActionScript 1 and 2
adobe
Comments
Post a Comment