-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding an interactive coins sample. Original concept and source contr…
…ibuted by Terry Paton. http://pixelpaton.com/. Signed-off-by: CoreyDotCom <corey.lucier@gmail.com>
- Loading branch information
1 parent
e2f2224
commit 9661492
Showing
8 changed files
with
558 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<actionScriptProperties analytics="false" mainApplicationPath="LotsOfCoins.as" projectUUID="88f91c72-768c-4dd0-9d63-f9695571cf71" version="10"> | ||
<compiler additionalCompilerArguments="-locale en_US -swf-version=13" autoRSLOrdering="true" copyDependentFiles="false" fteInMXComponents="false" generateAccessible="true" htmlExpressInstall="true" htmlGenerate="false" htmlHistoryManagement="true" htmlPlayerVersionCheck="true" includeNetmonSwc="false" outputFolderPath="bin-debug" removeUnusedRSL="true" sourceFolderPath="src" strict="true" targetPlayerVersion="10.2.0" useApolloConfig="false" useDebugRSLSwfs="true" verifyDigests="true" warn="true"> | ||
<compilerSourcePath/> | ||
<libraryPath defaultLinkType="0"> | ||
<libraryPathEntry kind="4" path=""> | ||
<modifiedEntries> | ||
<libraryPathEntry applicationDomain="default" forceLoad="false" index="2" kind="3" linkType="4" path="${PROJECT_FRAMEWORKS}/libs/advancedgrids.swc" useDefaultLinkType="true"> | ||
<crossDomainRsls> | ||
<crossDomainRslEntry autoExtract="true" policyFileUrl="" rslUrl="advancedgrids_4.5.0.0.swf"/> | ||
</crossDomainRsls> | ||
</libraryPathEntry> | ||
<libraryPathEntry applicationDomain="default" forceLoad="false" index="1" kind="3" linkType="4" path="${PROJECT_FRAMEWORKS}/libs/osmf.swc" useDefaultLinkType="true"> | ||
<crossDomainRsls> | ||
<crossDomainRslEntry autoExtract="true" policyFileUrl="" rslUrl="osmf_1.0.0.16316.swf"/> | ||
</crossDomainRsls> | ||
</libraryPathEntry> | ||
<libraryPathEntry applicationDomain="default" forceLoad="false" index="0" kind="3" linkType="4" path="${PROJECT_FRAMEWORKS}/libs/textLayout.swc" useDefaultLinkType="true"> | ||
<crossDomainRsls> | ||
<crossDomainRslEntry autoExtract="true" policyFileUrl="" rslUrl="textLayout_2.0.0.232.swf"/> | ||
</crossDomainRsls> | ||
</libraryPathEntry> | ||
</modifiedEntries> | ||
<excludedEntries> | ||
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/automation_charts.swc" useDefaultLinkType="false"/> | ||
<libraryPathEntry kind="3" linkType="2" path="${PROJECT_FRAMEWORKS}/libs/player/10.2/playerglobal.swc" useDefaultLinkType="false"/> | ||
<libraryPathEntry kind="1" linkType="1" path="${PROJECT_FRAMEWORKS}/locale/{locale}"/> | ||
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/qtp.swc" useDefaultLinkType="false"/> | ||
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/charts.swc" useDefaultLinkType="false"/> | ||
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/automation_air.swc" useDefaultLinkType="false"/> | ||
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/framework.swc" useDefaultLinkType="false"/> | ||
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/mx/mx.swc" useDefaultLinkType="false"/> | ||
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/netmon.swc" useDefaultLinkType="false"/> | ||
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/spark.swc" useDefaultLinkType="false"/> | ||
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/sparkskins.swc" useDefaultLinkType="false"/> | ||
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/rpc.swc" useDefaultLinkType="false"/> | ||
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/datavisualization.swc" useDefaultLinkType="false"/> | ||
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/qtp_air.swc" useDefaultLinkType="false"/> | ||
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/videoPlayer.swc" useDefaultLinkType="false"/> | ||
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/spark_dmv.swc" useDefaultLinkType="false"/> | ||
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/automation.swc" useDefaultLinkType="false"/> | ||
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/automation_dmv.swc" useDefaultLinkType="false"/> | ||
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/automation_flashflexkit.swc" useDefaultLinkType="false"/> | ||
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/automation_agent.swc" useDefaultLinkType="false"/> | ||
</excludedEntries> | ||
</libraryPathEntry> | ||
<libraryPathEntry kind="3" linkType="1" path="/M2D/bin-debug/M2D.swc" useDefaultLinkType="false"/> | ||
<libraryPathEntry kind="3" linkType="1" path="${MOLEHILL_PLAYERGLOBAL}" useDefaultLinkType="false"/> | ||
</libraryPath> | ||
<sourceAttachmentPath/> | ||
</compiler> | ||
<applications> | ||
<application path="LotsOfCoins.as"/> | ||
</applications> | ||
<modules/> | ||
<buildCSSFiles/> | ||
<flashCatalyst validateFlashCatalystCompatibility="false"/> | ||
</actionScriptProperties> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>InteractiveRenderTest</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>com.adobe.flexbuilder.project.flexbuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>com.adobe.flexbuilder.project.actionscriptnature</nature> | ||
</natures> | ||
</projectDescription> |
3 changes: 3 additions & 0 deletions
3
samples/InteractiveRenderTest/.settings/org.eclipse.core.resources.prefs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#Tue Nov 30 16:33:57 PST 2010 | ||
eclipse.preferences.version=1 | ||
encoding/<project>=utf-8 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
package { | ||
import M2D.animation.CellAnimation; | ||
import M2D.sprites.Actor; | ||
|
||
public class CoinClip { | ||
public function CoinClip(_actor:Actor) { | ||
actorRef=_actor | ||
super(); | ||
} | ||
|
||
public function set x(_x:Number):void { | ||
actorRef.x=_x | ||
} | ||
|
||
public function set y(_y:Number):void { | ||
actorRef.y=_y | ||
} | ||
|
||
public function get x():Number { | ||
return actorRef.x | ||
} | ||
|
||
public function get y():Number { | ||
return actorRef.y | ||
} | ||
|
||
public function setAlpha(_alpha:Number):void { | ||
actorRef.alpha=_alpha | ||
} | ||
|
||
public function rotate(_rotate:Number):void { | ||
actorRef.rotation+=_rotate | ||
newAngle=actorRef.rotation | ||
} | ||
|
||
public function move(_x:Number, _y:Number):void { | ||
actorRef.x+=_x | ||
actorRef.y+=_y | ||
} | ||
private var radians:Number | ||
private var newAngle:Number | ||
private var angleDiff:Number | ||
|
||
public function manage():void { | ||
// apply velocity | ||
if (Math.abs(velocityx) > 0.1) { | ||
velocityx*=.9 | ||
actorRef.x+=velocityx | ||
if (Math.abs(velocityx) < .1) { | ||
velocityx=0 | ||
} | ||
} | ||
if (Math.abs(velocityy) > 0.1) { | ||
velocityy*=.9 | ||
actorRef.y+=velocityy | ||
if (Math.abs(velocityy) < .1) { | ||
velocityy=0 | ||
} | ||
} | ||
// adjust the rotation of the actor | ||
if (Math.abs(velocityx) > 0 || Math.abs(velocityy) > 0) { | ||
radians=Math.atan2(velocityy, velocityx) | ||
newAngle=radians * 180 / Math.PI | ||
} else { | ||
newAngle=0 | ||
} | ||
angleDiff=newAngle - actorRef.rotation | ||
if (Math.abs(angleDiff) > 0.1) { | ||
actorRef.rotation+=angleDiff * .1 | ||
if (actorRef.rotation > 360) { | ||
actorRef.rotation-=360 | ||
} | ||
if (actorRef.rotation < 0) { | ||
actorRef.rotation+=360 | ||
} | ||
actorRef.cell++ | ||
if (actorRef.cell > 23) { | ||
actorRef.cell=0 | ||
} | ||
} | ||
|
||
if (actorRef.x > LotsOfCoins.stageWidth + LotsOfCoins.edgeBuffer) { | ||
actorRef.x=-LotsOfCoins.edgeBuffer | ||
} | ||
if (actorRef.x < -LotsOfCoins.edgeBuffer) { | ||
actorRef.x+=LotsOfCoins.stageWidth + LotsOfCoins.edgeBuffer | ||
} | ||
if (actorRef.y > LotsOfCoins.stageHeight + LotsOfCoins.edgeBuffer) { | ||
actorRef.y=-LotsOfCoins.edgeBuffer | ||
} | ||
if (actorRef.y < -LotsOfCoins.edgeBuffer) { | ||
actorRef.y=LotsOfCoins.stageHeight + LotsOfCoins.edgeBuffer | ||
} | ||
} | ||
public var velocityx:Number=0; | ||
public var velocityy:Number=0; | ||
public var actorRef:Actor | ||
public var animationRef:CellAnimation | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
/* | ||
* LotsOfCoins - M2D Sample | ||
* Author: Terry Paton | ||
*/ | ||
package { | ||
import M2D.animation.CellAnimation; | ||
import M2D.sprites.Actor; | ||
import M2D.sprites.Asset; | ||
import M2D.worlds.BatchTexture; | ||
import flash.display.Sprite; | ||
import flash.events.Event; | ||
import flash.text.TextField; | ||
import flash.text.TextFieldAutoSize; | ||
|
||
[SWF(width="800", height="480", frameRate="40", backgroundColor="0xB0E0E5")] | ||
public class LotsOfCoins extends Sprite | ||
{ | ||
private static const totalObjects:int=4000; | ||
public var images:Vector.<CoinClip>; | ||
public var tf2:TextField; | ||
protected var scene:RenderScene; | ||
private var instanceCount:int=0; | ||
private var fallingSpeed:Number=5 | ||
private var frames:int=0; | ||
private var coinAsset:Asset; | ||
public static var edgeBuffer:Number=10; | ||
public static var stageWidth:Number=800; | ||
public static var stageHeight:Number=480; | ||
private var _mouseX:Number; | ||
private var _mouseY:Number; | ||
private var dx:Number; | ||
private var dy:Number; | ||
private var dist:Number; | ||
|
||
[Embed(source="assets/coin.png")] | ||
public var coinPng:Class; | ||
|
||
public function LotsOfCoins() | ||
{ | ||
super(); | ||
scene=new RenderScene(800, 480); | ||
addChild(scene); | ||
createStats(); | ||
|
||
images=new Vector.<CoinClip>(); | ||
var n:int=totalObjects; | ||
while (n--) { | ||
addObject() | ||
} | ||
|
||
addEventListener(Event.ENTER_FRAME, loop); | ||
} | ||
|
||
private function addObject():void | ||
{ | ||
if (instanceCount < totalObjects) | ||
{ | ||
var image:CoinClip = image=scene.addAnimatedSprite(coinPng); | ||
|
||
image.x=Math.random() * stageWidth; | ||
image.y=Math.random() * stageHeight; | ||
image.rotate(Math.random() * 360); | ||
|
||
images.push(image); | ||
instanceCount++; | ||
tf2.text = String(instanceCount) + " Objects"; | ||
var animation:CellAnimation=new CellAnimation(scene._clock, 0, 24); | ||
animation.actor=image.actorRef; | ||
image.actorRef.cell=int(Math.random() * 20) | ||
image.animationRef=animation | ||
} | ||
} | ||
|
||
protected function loop(event:Event):void | ||
{ | ||
_mouseX = mouseX; | ||
_mouseY = mouseY; | ||
|
||
var image:CoinClip | ||
var l:uint=images.length; | ||
for (var i:Number=0; i < l; i++) | ||
{ | ||
image=images[i]; | ||
|
||
// find how close item is to the mouse | ||
dx=image.x - _mouseX; | ||
dy=image.y - _mouseY; | ||
dist=Math.floor(Math.sqrt(dx * dx + dy * dy)); | ||
|
||
if (dist < 100) | ||
{ | ||
// push the item away | ||
image.velocityx=dx * .1 | ||
image.velocityy=dy * .1 | ||
} | ||
image.manage() | ||
} | ||
} | ||
|
||
private function createStats():void | ||
{ | ||
tf2=new TextField(); | ||
tf2.autoSize=TextFieldAutoSize.LEFT; | ||
tf2.width=300; | ||
tf2.x=80 | ||
tf2.background=true; | ||
tf2.border=true; | ||
addChild(tf2); | ||
tf2.text=String(instanceCount) + " Objects"; | ||
addChild(new Stats()); | ||
} | ||
} | ||
} |
Oops, something went wrong.