Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added drawing class for slice drawing for IDE emitter angle

  • Loading branch information...
commit ee7ee728cc3fde9e8999e99ca1aa148094dbb044 1 parent 5a4c09c
@andrewfitz authored
View
1  changelog.txt
@@ -11,6 +11,7 @@ Motion Package 1.0 & Partigen 2.0 Final (2009/11/15)
-examples: added new MotionController example and starting at custom keyframe example
-fix: starting a controller at a keyframe will now start at the correct value
-fix: makeEase function
+ -fix: primitiveTweens not calling update() when duration < 0, causing 0-duration tweens to fail
Partigen:
-added: emitter.killParticles()
View
1  com/desuade/motion/tweens/PrimitiveBezierTween.as
@@ -82,6 +82,7 @@ package com.desuade.motion.tweens {
$time -= starttime;
if($time >= duration){
target[property] = value;
+ updateFunc(this);
end();
} else {
var nres:Number;
View
1  com/desuade/motion/tweens/PrimitiveMultiTween.as
@@ -95,6 +95,7 @@ package com.desuade.motion.tweens {
for (var i:int = 0; i < arrayObject.props.length; i++) {
target[arrayObject.props[i]] = arrayObject.values[i];
}
+ updateFunc(this);
end();
} else {
for (var k:int = 0; k < arrayObject.props.length; k++) {
View
1  com/desuade/motion/tweens/PrimitiveTween.as
@@ -95,6 +95,7 @@ package com.desuade.motion.tweens {
$time -= starttime;
if($time >= duration){
target[property] = value;
+ updateFunc(this);
end();
} else {
target[property] = ease($time, startvalue, difvalue, duration);
View
37 com/desuade/partigen/emitters/IDEEmitter.as
@@ -25,7 +25,11 @@ THE SOFTWARE.
package com.desuade.partigen.emitters {
import flash.events.MouseEvent;
+ import flash.display.MovieClip;
import com.desuade.partigen.renderers.*;
+ import com.desuade.motion.events.*;
+ import com.desuade.utils.Drawing;
+ import com.desuade.motion.bases.BaseTicker;
/**
* This is the class used for Partigen Emitter components for the Flash IDE.
@@ -54,10 +58,16 @@ package com.desuade.partigen.emitters {
protected var _renderToParent:Boolean = true;
/**
+ * @private
+ */
+ public var icon:MovieClip;
+
+ /**
* Creates a new IDEEmitter (usually from a component)
*/
public function IDEEmitter() {
super();
+ BaseTicker.addEventListener(MotionEvent.UPDATED, updateAngleSlice);
}
/**
@@ -78,7 +88,7 @@ package com.desuade.partigen.emitters {
/**
* Start the emitter automatically.
*/
- [Inspectable(name = "Will Auto Start", defaultValue = false, variable = "autoStart", type = "Boolean")]
+ [Inspectable(name = "Start Automatically", defaultValue = false, variable = "autoStart", type = "Boolean")]
public function get autoStart():Boolean{
return _autoStart;
}
@@ -100,6 +110,21 @@ package com.desuade.partigen.emitters {
}
/**
+ * If the emitter icon should be shown, marking it's position on the stage.
+ */
+ [Inspectable(name = "Show Icon", defaultValue = true, variable = "showIcon", type = "Boolean")]
+ public function get showIcon():Boolean{
+ return icon.visible;
+ }
+
+ /**
+ * @private
+ */
+ public function set showIcon($value:Boolean):void {
+ icon.visible = $value;
+ }
+
+ /**
* @private
*/
public function set followMouse($value:Boolean):void {
@@ -136,6 +161,16 @@ package com.desuade.partigen.emitters {
x = root.stage.mouseX;
y = root.stage.mouseY;
}
+
+ /**
+ * @private
+ */
+ public function updateAngleSlice($e:Object):void {
+ if(icon.visible){
+ icon.graphics.clear();
+ //Drawing.drawSlice(icon, 0, 0, 100, 200);
+ }
+ }
}
View
78 com/desuade/utils/Drawing.as
@@ -0,0 +1,78 @@
+/*
+This software is distributed under the MIT License.
+
+Copyright (c) 2009 Desuade (http://desuade.com/)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+package com.desuade.utils {
+
+ /**
+ * Class with static methods for drawing
+ *
+ * @langversion ActionScript 3
+ * @playerversion Flash 9.0.0
+ *
+ * @author Andrew Fitzgerald
+ * @since 12.11.2009
+ */
+ public class Drawing {
+
+ /**
+ * @private
+ */
+ private static var degToRad:Number = Math.PI/180;
+
+ /**
+ * This method draws a slice graphic to the target sprite
+ *
+ * @param target The target sprite to write to
+ * @param beginAngle The beginning angle to use to create the slice
+ * @param endAngle The end angle to use
+ * @param radius How big to make the slice
+ * @param color The color of the slice to draw - "#00ff00", 0x909090, etc.
+ * @param x The x offset to draw to - defaults 0
+ * @param y The y offset to draw to - defaults 0
+ */
+ public static function drawSlice($target:Object, $beginAngle:Number, $endAngle:Number, $radius:Number, $color:*, $x:Number = 0, $y:Number = 0):void {
+ if ($endAngle < $beginAngle) $endAngle += 360;
+ var n:Number = (($endAngle-$beginAngle)/45);
+ var theta:Number = -1*(($endAngle-$beginAngle)/n)*degToRad;
+ var cr:Number = $radius/Math.cos(theta/2);
+ var angle:Number = -1*$beginAngle*degToRad;
+ var cangle:Number = angle-theta/2;
+ $target.graphics.moveTo($x, $y);
+ $target.graphics.beginFill(ColorHelper.cleanColorValue($color));
+ $target.graphics.lineTo($x+$radius*Math.cos(angle), $y+$radius*Math.sin(angle));
+ for (var i:int = 0; i < n; i++) {
+ angle += theta;
+ cangle += theta;
+ var endX = $radius*Math.cos (angle);
+ var endY = $radius*Math.sin (angle);
+ var cX = cr*Math.cos (cangle);
+ var cY = cr*Math.sin (cangle);
+ $target.graphics.curveTo($x+cX,$y+cY, $x+endX,$y+endY);
+ }
+ $target.graphics.lineTo($x, $y);
+ }
+
+ }
+
+}
Please sign in to comment.
Something went wrong with that request. Please try again.