Search the Community
Showing results for tags '#throwprops'.
-
Hey everybody, Carl & Jack in particular So heres the cause of my insomnia. Making a basic fish pond game, (like koi pond) in flash. I have got throwprops scolling working beautifully on the background (called "mc"), which sits on the stage. The stage is 800px by 480px, the background mc is 2400 by 480. I have fish swimming about, which swim to where the user last clicked. Long story short, everything is working perfectly, except if the user clicks to the right of stage, (eg: y>800), it won't work, the fish will not swim past 800, even though i can scroll across, they will not follow, But in the dimensions of the stage, they work a treat. Its as if throwprops is sliding the stage to left as well? there is a lot of code for this one, so i'll just show whats relevant, let me know if theres something you want to see, Throwprops on background ("mc"): // TweenPlugin.activate([ThrowPropsPlugin]); //var bounds:Rectangle = new Rectangle(0, 0, 800, 480); ThrowPropsPlugin.track(mc, "x"); mc.addEventListener(MouseEvent.MOUSE_DOWN, bg2down); function bg2down(event:MouseEvent):void { TweenLite.killTweensOf(mc); mc.startDrag(false, new Rectangle(bounds.x, 0, -1600, 0)); mc.stage.addEventListener(MouseEvent.MOUSE_UP, bg2up); } function bg2up(event:MouseEvent):void { mc.stopDrag(); mc.stage.removeEventListener(MouseEvent.MOUSE_UP, bg2up); var xOverlap:Number = Math.max(0, mc.width - bounds.width); ThrowPropsPlugin.to(mc, {ease:Strong.easeOut, throwProps:{x:{max:bounds.left, min:bounds.left - xOverlap, resistance:200}}}, 10, 0.25, 1); } Aquire MouseX, MouseY for fish ("redfish") // private function updatePosition():void { // check if mouse is down if (_isActive) { // update destination _destinationX = stage.mouseX; _destinationY = stage.mouseY; // update velocity _vx += (_destinationX - this.x) / _moveSpeedMax; _vy += (_destinationY - this.y) / _moveSpeedMax; } else { // when mouse is not down, update velocity half of normal speed _vx += (_destinationX - this.x) / _moveSpeedMax * .25; _vy += (_destinationY - this.y) / _moveSpeedMax * .25; } // apply decay (drag) _vx *= _decay; _vy *= _decay; // if close to target, slow down turn speed if (getDistance(_dx, _dy) < 50) { _trueRotation *= .5; } // update position this.x += _vx; this.y += _vy; } Any help/suggestions/advice would be very appreciated, Thanks everybody. Happy programming :]
- 5 replies
-
- #throwprops
- #flash
-
(and 1 more)
Tagged with: