Created
May 10, 2013 11:02
-
-
Save mia-0032/5553750 to your computer and use it in GitHub Desktop.
「あの楽器」のAS版。途中まで作って飽きた。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Innocencer.DisplayEffect | |
{ | |
public class Circle extends EffectBase | |
{ | |
public function Circle(x:Number, y:Number) | |
{ | |
super(x, y); | |
} | |
public override function display():void | |
{ | |
this.graphics.drawCircle(this.pointX, this.pointY, this.r); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Innocencer.DisplayEffect | |
{ | |
import flash.display.CapsStyle; | |
import flash.display.JointStyle; | |
import flash.display.LineScaleMode; | |
import flash.display.Shape; | |
public class EffectBase extends Shape implements IDisplay | |
{ | |
protected var lineWidth:Number = 4.0; | |
protected var pointX:Number; | |
protected var pointY:Number; | |
protected var r:Number = 100; | |
protected var lineAlpha:Number = 1; | |
private const COLOR:Number = 0x00FFCC; | |
public function EffectBase(x:Number, y:Number) | |
{ | |
super(); | |
this.graphics.lineStyle(this.lineWidth, this.COLOR, this.lineAlpha, false, LineScaleMode.NORMAL, CapsStyle.NONE, JointStyle.MITER); | |
this.pointX = x; | |
this.pointY = y; | |
this.display(); | |
} | |
public function display():void | |
{ | |
} | |
public function enlarge():void | |
{ | |
this.lineWidth += 1.0; | |
this.r += 5.0; | |
this.lineAlpha -= 0.03; | |
this.graphics.clear(); | |
this.graphics.lineStyle(this.lineWidth, this.COLOR, this.lineAlpha, false, LineScaleMode.NORMAL, CapsStyle.NONE, JointStyle.MITER); | |
this.display(); | |
} | |
public function isFinished():Boolean | |
{ | |
if(this.lineAlpha < 0){ | |
return true; | |
} | |
return false; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Innocencer.DisplayEffect | |
{ | |
internal interface IDisplay | |
{ | |
function display():void; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package | |
{ | |
import flash.display.Sprite; | |
import flash.events.Event; | |
import flash.events.MouseEvent; | |
import Innocencer.DisplayEffect.*; | |
[SWF(frameRate = "30")] | |
public class Main extends Sprite | |
{ | |
private var effects:Array = new Array(); | |
public function Main() | |
{ | |
stage.color = 0x0; | |
stage.addEventListener(MouseEvent.CLICK, addEffect); | |
stage.addEventListener(Event.ENTER_FRAME, makeEffectLarger); | |
} | |
private function addEffect(event:MouseEvent): void | |
{ | |
var effect:EffectBase; | |
switch(Math.round(Math.random() * 2 + 0.5)){ | |
case 1: | |
effect = new Circle(mouseX, mouseY); | |
break; | |
case 2: | |
effect = new Rect(mouseX, mouseY); | |
break; | |
default: | |
} | |
effects.push(effect); | |
this.addChild(effect); | |
} | |
private function makeEffectLarger(event:Event): void | |
{ | |
this.effects.forEach( | |
function(effect:EffectBase, index:Number, effects:Array): void | |
{ | |
effect.enlarge(); | |
} | |
); | |
this.effects = this.effects.filter( | |
function(effect:EffectBase, index:Number, effects:Array): Boolean | |
{ | |
return !effect.isFinished(); | |
} | |
); | |
trace(this.effects); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Innocencer.DisplayEffect | |
{ | |
public class Rect extends EffectBase | |
{ | |
public function Rect(x:Number, y:Number) | |
{ | |
super(x, y); | |
} | |
public override function display():void | |
{ | |
this.graphics.drawRect(this.pointX - this.r/2, this.pointY - this.r/2, this.r, this.r); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment