Flash AS3 | Pan / Zoom with mouse input

陌路散爱 提交于 2019-12-12 03:24:47

问题


I was looking to see if someone can help me figure out how to create a panning effect over an already playing video in Flash AS3, where the camera is directed by where the mouse is.

For example, this game here http://www.kongregate.com/games/jorjeade/seven-deadly-sins (skip the intro to get to it quickly) has an over world map which pans around by using the mouse. I'm trying to achieve a similar effect for my flash video.

Any help coding this would be awesome! I'm also looking to see if I can get a basic zoom function working alongside this panning, also something that the user can control though the keyboard or similar.

I appreciate any help! Thanks.


回答1:


For my code to work as it is, set your movie clip anchor point to "centered."

myMovieClip.y = stage.stageHeight / 2;  
addEventListener(MouseEvent.MOUSE_MOVE, panFunction);
private function panFunction(me:MouseEvent):void {
    myMovieClip.x = stage.stageWidth/2 - (stage.mouseX - stage.stageWidth/2);
}

This will give a 1 to 1 motion that updates immediately with the mouse. You can throw in some multipliers or easing effect if you want, but hopefully this gets you going the right direction.



来源:https://stackoverflow.com/questions/37239283/flash-as3-pan-zoom-with-mouse-input

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!