Finalising the scope
This is the last tutorial about the scope and will just be showing you how you can improve it…
Ok, so remember when I said is was all about the rotation of the scope – well you may want to reduce it, so on the gun movieclip inside the stage movieclip update it with the following:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | onClipEvent(load){ function updateGun(){ m = {x:_root._xmouse, y:_root._ymouse, sw: Stage.width, sh: Stage.height} } function updatePos(){ _x = (((m.x/m.sw)*m.sw)/4)+_width/2 _y = ((m.y/m.sh)*m.sh)/4 difx = (m.x-(_parent._x+_x)) dify = (m.y-(_parent._y+_y)) radians = Math.atan2(dify, difx)/2 degrees = 360*radians/(2*Math.PI) _rotation = degrees+(135/2) } updateGun() updatePos() } onClipEvent(enterFrame){ updateGun() updatePos() } |
Lines 10 and 12 are all that interest me – see the “/2″, this is the reduction. You could change it to “/3″ if you wanted an even bigger reduction…
Now blurring, you wouldn’t actually be able to see the scope contents clearly so let’s blur them…
So on the frame in the gun movieclip update the code with this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | import flash.display.BitmapData import flash.geom.Matrix import flash.filters.BlurFilter updateScope = function(){ bitmapScope = new BitmapData(Scoper._width*6, Scoper._height*6, false, 0x00000000) scopeReflect = this.createEmptyMovieClip("scopeView", 2) scopeReflect.attachBitmap(bitmapScope, 3) offset = new Matrix() offset.tx = -_root._xmouse+(Scoper._width*3) offset.ty = -_root._ymouse+(Scoper._height*3) bitmapScope.draw(_root.Background,offset) scopeView._x = Scoper._x-(Scoper._width*3) scopeView._y = Scoper._y-(Scoper._height*2.5) scopeView._rotation = -_rotation scopeView.setMask(Scoper) Blur = new BlurFilter(10,10,1) Filters = new Array() Filters.push(Blur) scopeView.filters = Filters Shadow.swapDepths(getNextHighestDepth()) } onEnterFrame = function(){ updateScope() } |
Note line 3 where we import the API and lines 17 – 20 where we implement it!
And you should get:
And because I’m so kind – the sources…
Sniper - CS4/CS5/CS5 Uncompressed Universal (173.6 KiB, 150 hits)




