Report
Save
Cancel
Posted July 30, '10 7:29pm UTC
Hello. Here's a script that goes to a frame ofc. I wonder why it doesn't work? The bitmap is not attached, plus the hero moves weird (spinning and stuff like that) What did I do wrong? Any help appreciated. Thanks
<br><br>_root.attachMovie("hero", "hero_on_stage", 10000,{_x:200,_y:20});<br>_root.attachMovie("trail_sprite", "trail_mc", 8000);<br>trailbitmap = new flash.display.BitmapData(500, 350, true,0x000000);<br>_root.createEmptyMovieClip("trail", 1);<br>trail.attachBitmap(trailbitmap, 0);<br>trail_mc._visible = false;<br>yspeed = 0;<br>xspeed = 0;<br>wind = 0.0;<br>power = 0.75;<br>gravity = 0.0;<br>upconstant = 0.75;<br>friction = 0.98;<br>hero_on_stage.onEnterFrame = function() {<br> if (Key.isDown(Key.LEFT)) {<br> xspeed = xspeed-power;<br> }<br> if (Key.isDown(Key.RIGHT)) {<br> xspeed = xspeed+power;<br> }<br> if (Key.isDown(Key.UP)) {<br> yspeed = yspeed-power;<br> }<br> if (Key.isDown(Key.DOWN)) {<br> yspeed = yspeed+power;<br> }<br> xspeed = (xspeed+wind)*friction;<br> yspeed = (yspeed+gravity)*friction;<br> if(sunken == 0){<br> _y = _y+yspeed;<br> _x = _x+xspeed;<br> }<br> else{<br> _y = _y+(yspeed/5);<br> _x = _x+(xspeed/3);<br> }<br> _rotation = _rotation+xspeed;<br> if (_root.wall.hitTest(_x, _y, true)) {<br> xspeed = 0;<br> yspeed = 0;<br> _x = 76;<br> _y = 87;<br> }<br> if (_root.water.hitTest(_x, _y, true)) {<br> sunken = 1;<br> }<br> else{<br> sunken = 0;<br> }<br> this._rotation = this._rotation+xspeed;<br> _root.trail_mc.trail_sprite._x = this._x;<br> _root.trail_mc.trail_sprite._y = this._y;<br> _root.trailbitmap.draw(_root.trail_mc);<br> trail_rectangle = new flash.geom.Rectangle(0, 0, 500, 350);<br> trail_blur = new flash.filters.BlurFilter(2, 2, 3);<br> _root.trailbitmap.applyFilter(_root.trailbitmap, trail_rectangle, new Point(0, 0), trail_blur);<br>}<br>