Flash AS3 |平移/缩放鼠标输入 [英] Flash AS3 | Pan / Zoom with mouse input
问题描述
我正在查看是否有人可以帮我弄清楚如何在Flash AS3中的已经播放的视频上创建一个平移效果,在这个视频中,相机是由鼠标指向的。
例如,这里的游戏 http://www.kongregate.com/games/jorjeade/seven-deadly-sins (跳过介绍快速到达)有一个世界地图,通过使用鼠标左右摇摆。我正在尝试为我的Flash视频获得类似的效果。
任何帮助编码这将是真棒!我也想看看是否可以得到一个基本的缩放功能,这个平移,也是用户可以通过键盘或类似的控制。
感谢任何帮助!谢谢。
对于我的代码来说,将您的影片剪辑定位点设置为居中。 b
$ b
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);
}
这将给出一个1比1的动作,用鼠标立即更新。如果你愿意的话,你可以投入一些乘数或者缓解效应,但是希望这会让你朝着正确的方向前进。
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.
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.
这篇关于Flash AS3 |平移/缩放鼠标输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!