チェンジセット 4539
- コミット日時:
- 2011/05/19 02:04:25 (1 年前)
- ファイル:
-
- as3/CannonML/trunk/doc/cannonML.html (更新) (2 diffs)
- as3/CannonML/trunk/doc/cannonML_e.html (更新) (1 diff)
- as3/CannonML/trunk/samples/BulletRunnerSample (追加)
- as3/CannonML/trunk/samples/BulletRunnerSample/BulletRunnerSample.as (追加)
- as3/CannonML/trunk/samples/FirstSample (追加)
- as3/CannonML/trunk/samples/FirstSample/FirstSample.as (追加)
- as3/CannonML/trunk/src/org/si/cml/CMLObject.as (更新) (7 diffs)
- as3/CannonML/trunk/src/org/si/cml/CannonML.as (更新) (2 diffs)
- as3/CannonML/trunk/src/org/si/cml/core/CMLBarrageElem.as (更新) (4 diffs)
- as3/CannonML/trunk/src/org/si/cml/core/CMLFormula.as (更新) (10 diffs)
- as3/CannonML/trunk/src/org/si/cml/core/CMLFormulaElem.as (更新) (1 diff)
- as3/CannonML/trunk/src/org/si/cml/core/CMLFormulaLiteral.as (更新) (1 diff)
- as3/CannonML/trunk/src/org/si/cml/core/CMLFormulaOperator.as (更新) (6 diffs)
- as3/CannonML/trunk/src/org/si/cml/core/CMLState.as (更新) (2 diffs)
- as3/CannonML/trunk/src/org/si/cml/core/interpolation.as (更新) (1 diff)
- as3/CannonML/trunk/src/org/si/cml/extensions/Actor.as (更新) (1 diff)
- as3/CannonML/trunk/src/org/si/cml/extensions/BulletRunner.as (更新) (16 diffs)
- as3/CannonML/trunk/src/org/si/cml/extensions/ScopeLimitObject.as (更新) (1 diff)
- as3/CannonML/trunk/src/org/si/cml/extensions/framework/CMLMovieClip.as (更新) (2 diffs)
- as3/CannonML/trunk/src/org/si/cml/extensions/framework/modules/CMLMovieClipControl.as (更新) (6 diffs)
凡例:
- 変更無し
- 追加
- 削除
- 更新
- コピー
- 移動
as3/CannonML/trunk/doc/cannonML.html
r4456 r4539 181 181 </DIV> 182 182 <DIV class="statement"> 183 $sin, $cos, $tan, $asn, $acs, $atn, $sqr, $int 184 </DIV> 185 <DIV class="outline"> 186 �P�����Z�q�Ő���,�]��,�����t����,�t�]��,�t��������؎̂Ă�Z���܂��D 183 $sin, $cos, $tan, $asn, $acs, $atn, $sqr, $int and $abs 184 </DIV> 185 <DIV class="outline"> 186 �P�����Z�q�Ő���,�]��,�����t����,�t�]��,�t��������؎̂����l��Z���܂��D 187 </DIV> 188 <DIV class="statement"> 189 $i?, $i?? 190 </DIV> 191 <DIV class="outline"> 192 ������������܂��D"$i?(n)"���Ԃ��͈͂��`(n-1)�C"$i??(n)"��-n+1)�`(n-1)�ł�. 187 193 </DIV> 188 194 <DIV class="discription"> … … 347 353 <DIV class="command"> 348 354 <DIV class="statement"> 349 l$r=, l$1=, l$2=, l$3=,... l$9 =<i>[���l]</i>355 l$r=, l$1=, l$2=, l$3=,... l$9 <i>[���l]</i> 350 356 </DIV> 351 357 <DIV class="outline"> as3/CannonML/trunk/doc/cannonML_e.html
r4456 r4539 178 178 </DIV> 179 179 <DIV class="statement"> 180 $sin, $cos, $tan, $asn, $acs, $atn, $sqr, $int 180 $sin, $cos, $tan, $asn, $acs, $atn, $sqr, $int and $abs 181 181 </DIV> 182 182 <DIV class="outline"> 183 183 The sine, cosine, tangent, arcsine, arccosine, arctanenget, square root and floor calculation respectively. 184 </DIV> 185 <DIV class="statement"> 186 $i?, $i?? 187 </DIV> 188 <DIV class="outline"> 189 (random) Return a random integer�DThe ranges are 0<=$i?(n)<n and -n<$i?(n)<n. 184 190 </DIV> 185 191 <DIV class="discription"> as3/CannonML/trunk/src/org/si/cml/CMLObject.as
r4456 r4539 227 227 _globalRank[0] = (r<_globalRankRangeMin) ? _globalRankRangeMin : (r>_globalRankRangeMax) ? _globalRankRangeMax : r; 228 228 } 229 229 230 230 // common properties 231 231 /** Construction ID, this value changes when the object is destroyed. … … 324 324 //------------------------------------------------------------ 325 325 // statics 326 static private var _activeObjects:CMLList = new CMLList();// active object list327 static private var _root:CMLRoot = null;// root object instance328 static private var _funcRand:Function = Math.random;// random function329 static private var _globalRankRangeMin:Number = 0;// the range of globalRank330 static private var _globalRankRangeMax:Number = 1;// the range of globalRank326 static private var _activeObjects:CMLList = new CMLList(); // active object list 327 static private var _root:CMLRoot = null; // root object instance 328 static private var _funcRand:Function = Math.random; // random function 329 static private var _globalRankRangeMin:Number = 0; // the range of globalRank 330 static private var _globalRankRangeMax:Number = 1; // the range of globalRank 331 331 /** @private */ 332 332 static _cml_internal var _globalRank:Array = new Array(10); // array of globalRank … … 409 409 /** Statement "n" calls this when it needs. Override this to define the new CMLObject created by "n" command. 410 410 * @param args The arguments of sequence. 411 * @return The new CMLObject created by "n" command.411 * @return The new CMLObject created by "n" command. You must not activate(call create()) returning CMLObject. 412 412 */ 413 413 public function onNewObject(args:Array) : CMLObject … … 419 419 /** Statement "f" calls this when it needs. Override this to define the new CMLObject created by "f" command. 420 420 * @param args The arguments of sequence. 421 * @return The new CMLObject created by "n" command. 421 * @return The new CMLObject created by "n" command. You must not activate(call create()) returning CMLObject. 422 422 */ 423 423 public function onFireObject(args:Array) : CMLObject … … 449 449 /** <b>Call this function for each frame</b>. This function calls all CMLObject.onUpdate()s. */ 450 450 static public function update() : void 451 { 451 { 452 452 CMLFiber._cml_fiber_internal::_onUpdate(); 453 453 … … 489 489 490 490 491 /** The return value is from CMLObject. _funcRand.491 /** The return value is from CMLObject.funcRand. Call CMLObject.funcRand internally. 492 492 * @return The random number between 0-1. 493 * @see CMLObject# _funcRand493 * @see CMLObject#funcRand 494 494 */ 495 495 static public function rand() : Number { return _funcRand(); } 496 496 497 497 498 /** Set the range of globalRank. */498 /** Set the range of globalRank. The global rank value is limited in this range. */ 499 499 static public function setGlobalRankRange(min:Number, max:Number) : void 500 500 { … … 508 508 // create / destroy 509 509 //------------------------------------------------------------ 510 /** Create new object on the stage.510 /** Create new object on the CML stage. 511 511 * @param x_ X value of this object on a stage or parent(if its a part of parent). 512 512 * @param y_ Y value of this object on a stage or parent(if its a part of parent). as3/CannonML/trunk/src/org/si/cml/CannonML.as
r4456 r4539 1 1 //---------------------------------------------------------------------------------------------------- 2 2 // CannonML 3 // Copyright (c) 201 0keim All rights reserved.3 // Copyright (c) 2011 keim All rights reserved. 4 4 // Distributed under BSD-style license (see license.txt). 5 5 //---------------------------------------------------------------------------------------------------- … … 10 10 class CannonML { 11 11 /** Version information */ 12 static public const VERSION:String = "0.3. 0";12 static public const VERSION:String = "0.3.1"; 13 13 14 14 as3/CannonML/trunk/src/org/si/cml/core/CMLBarrageElem.as
r4456 r4539 155 155 // calculation of sequencial bullet 156 156 //-------------------------------------------------- 157 / / initialize158 p rivatefunction _init(parent:CMLBarrageElem) : void157 /** @private initialize */ 158 public function _init(parent:CMLBarrageElem) : void 159 159 { 160 160 counter = count; … … 163 163 } 164 164 165 / / initialize random166 p rivatefunction _init_random(parent:CMLBarrageElem) : void165 /** @private initialize random */ 166 public function _init_random(parent:CMLBarrageElem) : void 167 167 { 168 168 counter = count; … … 173 173 } 174 174 175 / / update176 p rivatefunction _update() : void175 /** @private update */ 176 public function _update() : void 177 177 { 178 178 angle += angle_step; … … 181 181 } 182 182 183 / / update random184 p rivatefunction _update_random() : void183 /** @private update random */ 184 public function _update_random() : void 185 185 { 186 186 angle = angle_offset + angle_step * CMLObject.rand(); as3/CannonML/trunk/src/org/si/cml/core/CMLFormula.as
r4456 r4539 11 11 12 12 13 14 15 /** @private */ 13 /** @private statemant for formula calculation */ 16 14 internal class CMLFormula extends CMLState 17 15 { … … 47 45 return _operand_rex; 48 46 } 49 50 51 47 48 49 50 52 51 // functions 53 52 //------------------------------------------------------------ … … 72 71 } 73 72 74 protected override function _setCommand(cmd:String) : CMLState 73 74 override protected function _setCommand(cmd:String) : CMLState 75 75 { 76 76 return this; … … 78 78 79 79 80 81 80 82 // function to create formula structure 81 83 //------------------------------------------------------------ … … 99 101 } 100 102 103 101 104 // push operand stac 102 105 internal function pushLiteral(literal:*) : void … … 109 112 } 110 113 114 111 115 // push prefix 112 116 internal function pushPrefix(prefix:*, isSingle:Boolean) : Boolean … … 115 119 } 116 120 121 117 122 // push postfix 118 123 internal function pushPostfix(postfix:*, isSingle:Boolean) : Boolean … … 120 125 return (postfix != undefined) ? _parse_and_push(_postfixRegExp, postfix, isSingle) : true; 121 126 } 127 122 128 123 129 // call from pushPostfix and pushPrefix. … … 133 139 } 134 140 141 135 142 // construct formula structure 136 143 internal function construct() : Boolean … … 147 154 } 148 155 156 157 149 158 150 159 // calculation as3/CannonML/trunk/src/org/si/cml/core/CMLFormulaElem.as
r4456 r4539 9 9 import org.si.cml.CMLFiber; 10 10 11 11 12 /** @private */ 12 13 internal class CMLFormulaElem as3/CannonML/trunk/src/org/si/cml/core/CMLFormulaLiteral.as
r4456 r4539 10 10 import org.si.cml.CMLObject; 11 11 import org.si.cml.namespaces._cml_internal; 12 13 14 12 15 13 as3/CannonML/trunk/src/org/si/cml/core/CMLFormulaOperator.as
r4456 r4539 8 8 package org.si.cml.core { 9 9 import org.si.cml.CMLFiber; 10 10 import org.si.cml.CMLObject; 11 11 12 12 … … 16 16 static private var sin:CMLSinTable = new CMLSinTable(); 17 17 18 static internal var prefix_rex :String = "([-!(]|\\$sin|\\$cos|\\$tan|\\$asn|\\$acs|\\$atn|\\$sqr|\\$i nt)";18 static internal var prefix_rex :String = "([-!(]|\\$sin|\\$cos|\\$tan|\\$asn|\\$acs|\\$atn|\\$sqr|\\$i\\?|\\$i\\?\\?|\\$int|\\$abs)"; 19 19 static internal var postfix_rex:String = "(\\))"; 20 20 … … 25 25 internal var opr1:CMLFormulaElem = null; 26 26 private var func:Function = null; 27 27 28 28 29 function CMLFormulaOperator(opr:String="", isSingle:Boolean=false) … … 43 44 if (opr == "$atn") { func=atn; priorL=10; priorR=11; } else 44 45 if (opr == "$sqr") { func=sqr; priorL=10; priorR=11; } else 45 if (opr == "$int") { func=ind; priorL=10; priorR=11; } 46 if (opr == "$int") { func=ind; priorL=10; priorR=11; } else 47 if (opr == "$abs") { func=abs; priorL=10; priorR=11; } else 48 if (opr == "$i?") { func=ird; priorL=10; priorR=11; } else 49 if (opr == "$i??") { func=srd; priorL=10; priorR=11; } 46 50 } else { 47 51 oprcnt = 2; … … 60 64 } 61 65 66 62 67 internal override function calc(fbr:CMLFiber) : Number 63 68 { 64 69 return func(opr0.calc(fbr), (oprcnt==2) ? (opr1.calc(fbr)) : 0); 65 70 } 71 66 72 67 73 static private function add(r0:Number, r1:Number) : Number { return r0+r1; } … … 80 86 static private function sqr(r0:Number, r1:Number) : Number { return Math.sqrt(r0); } 81 87 static private function ind(r0:Number, r1:Number) : Number { return Number(int(r0)); } 88 static private function abs(r0:Number, r1:Number) : Number { return (r0<0)?(-r0):(r0); } 89 static private function ird(r0:Number, r1:Number) : Number { return Number(int(CMLObject.rand()*r0)); } 90 static private function srd(r0:Number, r1:Number) : Number { return Number(int(CMLObject.rand()*(r0*2+1))-r0); } 82 91 static private function grt(r0:Number, r1:Number) : Number { return (r0>r1)?1:0; } 83 92 static private function geq(r0:Number, r1:Number) : Number { return (r0>=r1)?1:0; } as3/CannonML/trunk/src/org/si/cml/core/CMLState.as
r4456 r4539 123 123 case "[s?": func = _level_start; type = ST_SELECT; if (_args.length==0) throw Error("no arguments in [s?"); break; 124 124 case ":": func = _else_start; type = ST_ELSE; _resetParameters(1); break; 125 case "]": func = _block_end; type = ST_BLOCKEND; break;125 case "]": func = _block_end; type = ST_BLOCKEND; _resetParameters(1); break; 126 126 // interval 127 127 case "i": func = _i; _resetParameters(1); break; … … 260 260 private function _block_end(fbr:CMLFiber) : Boolean { 261 261 if (jump.type == ST_LOOP) { 262 if (++fbr.lcnt[0] != int(jump._args[0])) { 262 var lmax:int = int(_args[0] || jump._args[0]); 263 if (++fbr.lcnt[0] != lmax) { 263 264 fbr._pointer = jump; 264 265 return true; as3/CannonML/trunk/src/org/si/cml/core/interpolation.as
r4456 r4539 5 5 // variables 6 6 //-------------------------------------------------- 7 p rivatevar P:Number = 0;8 p rivatevar Q:Number = 0;9 p rivatevar R:Number = 0;10 p rivatevar S:Number = 0;7 public var P:Number = 0; 8 public var Q:Number = 0; 9 public var R:Number = 0; 10 public var S:Number = 0; 11 11 12 12 as3/CannonML/trunk/src/org/si/cml/extensions/Actor.as
r4456 r4539 38 38 39 39 40 /** Life, you can use this as you like. Set life to 1 when the object is created.*/40 /** Life, you can use this as you like. */ 41 41 public var life:Number = 1; 42 42 /** Size to use in hit test */ as3/CannonML/trunk/src/org/si/cml/extensions/BulletRunner.as
r4456 r4539 9 9 import flash.events.Event; 10 10 import flash.display.Shape; 11 import flash.utils.Dictionary; 11 12 import org.si.cml.*; 12 13 import org.si.cml.core.CMLList; … … 19 20 // variables 20 21 //------------------------------------------------------------ 21 // sequence22 private var _sequence:CMLSequence;23 // root fiber24 private var _fiber:CMLFiber;25 26 22 /** target property name of x */ 27 23 public var xPropertyName:String; … … 31 27 public var anglePropertyName:String; 32 28 33 // callback functions 34 private var _onUpdated:Function = null; 35 private var _onDestroyed:Function = null; 36 private var _onNew:Function = null; 37 private var _onFire:Function = null; 38 private var _onCreatedInternal:Function = null; 39 40 // sequence parameters 41 private var _sequenceParameter:Array; 29 /** callback when the CML object is created on CML stage */ 30 public var atCreate:Function = null; 31 /** callback when the CML object is updated */ 32 public var atUpdate:Function = null; 33 /** callback when the CML object is destroyed on CML stage */ 34 public var atDestroy:Function = null; 35 /** callback when the CML object is required by "n*" commands */ 36 public var atNewObject:Function = null; 37 /** callback when the CML object is required by "f*" commands */ 38 public var atFireObject:Function = null; 42 39 43 40 /** target property name of x */ … … 48 45 static public var defaultAnglePropertyName:String = "rotation"; 49 46 47 // default target 48 static private var _bulletRunnerDefaultTarget:CMLObject = new CMLObject(); 49 50 50 51 51 … … 53 53 // properties 54 54 //------------------------------------------------------------ 55 /** parent object, null thieBulletRunner is created by aplly() or the parent is destructed. */55 /** parent object, returns null when this BulletRunner is created by aplly() or the parent is destructed. */ 56 56 public function get parentActor() : * { 57 57 var brParent:BulletRunner = parent as BulletRunner; … … 59 59 } 60 60 61 /** controling sequence, CMLSequence, CannonML String or BulletML XML is available for setter and only CMLSequence is returned from getter. */ 62 public function get sequence() : * { return _sequence; } 63 public function set sequence(s:*) : void { 64 if (s == null) _sequence = null; 65 else if (s is CMLSequence) _sequence = s; 66 else if (s != null) _sequence = new CMLSequence(s); 67 else _sequence = null; 68 } 69 70 71 /** set callback functions. The key of "update", "destroy", "new" and "fire" are available. The function type is function(br:BulletRunner) : Boolean. */ 72 public function get callbacks() : * { return {"update":_onUpdated, "destroy":_onDestroyed, "new":_onNew, "fire":_onFire}; } 61 62 /** set callback functions. The key of "onCreate", "onUpdate", "onDestroy", "onNew" and "onFire" are available.<br/> 63 * The function format of onCreate, onUpdate and onDestroy are function(br:BulletRunner) : Boolean. <br/> 64 * The function format of onNew and onFire are function(args:Array) : BulletRunner. You have to return your new actor by "n" or "f" command. The sequrence parameters are passed by arguments.<br/> 65 */ 66 public function get callbacks() : * { return {"onCreate":atCreate, "onUpdate":atUpdate, "onDestroy":atDestroy, "onNew":atNewObject, "onFire":atFireObject}; } 73 67 public function set callbacks(functions:*) : void { 74 68 if (functions == null) { 75 _onUpdated = null; 76 _onDestroyed = null; 77 _onNew = null; 78 _onFire = null; 69 atCreate = null; 70 atUpdate = null; 71 atDestroy = null; 72 atNewObject = null; 73 atFireObject = null; 79 74 } else { 80 if ("update" in functions) _onUpdated = functions["update"]; 81 if ("destroy" in functions) _onDestroyed = functions["destroy"]; 82 if ("new" in functions) _onNew = functions["new"]; 83 if ("fire" in functions) _onFire = functions["fire"]; 75 if ("onCreate" in functions) atCreate = functions["onCreate"]; 76 if ("onUpdate" in functions) atUpdate = functions["onUpdate"]; 77 if ("onDestroy" in functions) atDestroy = functions["onDestroy"]; 78 if ("onNew" in functions) atNewObject = functions["onNew"]; 79 if ("onFire" in functions) atFireObject = functions["onFire"]; 84 80 } 85 81 } … … 119 115 120 116 117 /** Is paused ? */ 118 static public function isPaused() : Boolean { return _tickerPaused; } 119 120 121 121 122 122 … … 135 135 /** apply BulletRunner to the object 136 136 * @param actor The object controlled by BulletRunner. 137 * @param sequence Controling sequence, CMLSequence, CannonML String or BulletML XML is available. 138 * @param callbacks set Callback functions by object. The key of "update", "destroy", "new" and "fire" are available. 137 * @param callbacks set Callback functions by object. The key of "onCreate", "onUpdate", "onDestroy", "onNew" and "onFire" are available. 139 138 * @param propertyNames target property name to control. The key of "x", "y" and "angle" are available. 140 139 * @return BulletRunner instance 141 140 */ 142 static public function apply(actor:*, sequence:* = null,callbacks:* = null, propertyNames:* = null) : BulletRunner141 static public function apply(actor:*, callbacks:* = null, propertyNames:* = null) : BulletRunner 143 142 { 144 143 if (!_tickerAvailable) { 145 144 _startTicker(); 146 145 ScopeLimitObject.initialize(); 146 _bulletRunnerDefaultTarget.setAsDefaultTarget(); 147 147 } 148 148 149 var br:BulletRunner = _new(); 150 br.actor = actor; 151 br.sequence = sequence; 152 br.callbacks = callbacks; 153 br.propertyNames = propertyNames; 154 br.create(actor[br.xPropertyName], actor[br.yPropertyName]); 155 if (br._sequence) br._fiber = br.execute(br._sequence); 149 //var br:BulletRunner = _brunnerDict[actor]; 150 var br:BulletRunner = null; 151 if (br == null) br = _new_BulletRunner(actor, callbacks, propertyNames); 152 156 153 return br; 157 154 } 158 155 159 156 157 /** update position that all bullets target to. 158 * @param xpos x number. 159 * @param ypos y number. 160 */ 161 static public function updateTargetPosition(xpos:Number, ypos:Number) : void 162 { 163 _bulletRunnerDefaultTarget.x = xpos; 164 _bulletRunnerDefaultTarget.y = ypos; 165 } 166 167 168 /** pause all bullet runner runnings */ 169 static public function pause() : void 170 { 171 _tickerPaused = true; 172 } 173 174 175 /** resume all bullet runner runnings pause */ 176 static public function resume() : void 177 { 178 _tickerPaused = false; 179 } 180 181 182 /** run sequence. call CMLObject::create and CMLObject::execute inside. 183 * @param seq sequence. CMLSequence instance, String in CannonML or XML in BulletML is available. 184 * @param args The array of arguments to execute sequence. 185 * @param invertFlag The flag to invert execution, same as 'm' command. 186 * @return Instance of fiber that execute the sequence. 187 */ 188 public function runSequence(seq:*, args:Array=null, invertFlag:uint=0) : CMLFiber 189 { 190 var s:CMLSequence = (seq is String || seq is XML) ? (new CMLSequence(seq)) : seq as CMLSequence, 191 fiber:CMLFiber; 192 if (!isActive) create(actor[xPropertyName], actor[yPropertyName]); 193 if (s) fiber = execute(s, args, invertFlag); 194 return fiber; 195 } 196 197 198 160 199 161 200 // handlers … … 164 203 override public function onCreate() : void 165 204 { 166 if ( _onCreatedInternal != null) _onCreatedInternal(this, _sequenceParameter);167 } 168 169 205 if (atCreate != null) atCreate(this); 206 } 207 208 170 209 /** @private */ 171 210 override public function onDestroy() : void 172 211 { 173 if ( _onDestroyed != null) _onDestroyed(this);174 } 175 176 177 /** @private */ 178 override public function onUpdate d() : void212 if (atDestroy != null) atDestroy(this); 213 } 214 215 216 /** @private */ 217 override public function onUpdate() : void 179 218 { 180 219 if (isEscaped) { … … 184 223 actor[yPropertyName] = y; 185 224 if (anglePropertyName != null) actor[anglePropertyName] = angleOnStage; 186 if ( _onUpdated != null) _onUpdated(this);225 if (atUpdate != null) atUpdate(this); 187 226 } 188 227 } … … 192 231 override public function onNewObject(args:Array) : CMLObject 193 232 { 194 return _new(args, _onNew, _onNew, _onFire); 233 if (atNewObject == null) return null; 234 var actor:* = atNewObject(args); 235 return (actor is BulletRunner) ? actor : _new_BulletRunner(actor); 195 236 } 196 237 … … 199 240 override public function onFireObject(args:Array) : CMLObject 200 241 { 201 return _new(args, _onFire, _onNew, _onFire); 202 } 203 204 242 if (atFireObject == null) return null; 243 var actor:* = atFireObject(args); 244 return (actor is BulletRunner) ? actor : _new_BulletRunner(actor); 245 } 246 247 205 248 /** @private */ 206 249 public override function _finalize() : void … … 215 258 // ticker 216 259 //------------------------------------------------------------ 260 // ticker 217 261 static private var _ticker:Shape = null; 218 262 static private var _tickerAvailable:Boolean = false; 263 static private var _tickerPaused:Boolean = false; 219 264 220 265 static private function _startTicker() : void { … … 230 275 231 276 static private function _onTick(e:Event) : void { 232 CMLObject.update();277 if (!_tickerPaused) CMLObject.update(); 233 278 } 234 279 … … 238 283 // factory 239 284 //------------------------------------------------------------ 240 / ** free list */285 // free list 241 286 static private var _freeList:CMLList = new CMLList(); 287 static private var _brunnerDict:Dictionary = new Dictionary(true); 242 288 243 289 244 290 /** create new instance */ 245 static private function _new (params:Array=null, onCreatedInternal:Function=null, onNew:Function=null, onFire:Function=null) : BulletRunner291 static private function _new_BulletRunner(actor:*, callbacks:*=null, propertyNames:*=null) : BulletRunner 246 292 { 247 293 var br:BulletRunner = (_freeList.isEmpty()) ? new BulletRunner() : BulletRunner(_freeList.pop()); 248 br. _onCreatedInternal = onCreatedInternal;249 br. _onNew = onNew;250 br. _onFire = onFire;251 br._sequenceParameter = params;294 br.actor = actor; 295 br.callbacks = callbacks; 296 br.propertyNames = propertyNames; 297 //_brunnerDict[actor] = br; 252 298 return br; 253 299 } … … 255 301 256 302 // delete instance 257 static private function _delete(rnr:BulletRunner) : void 258 { 259 _freeList.push(rnr); 303 static private function _delete(br:BulletRunner) : void 304 { 305 //delete _brunnerDict[br.actor]; 306 _freeList.push(br); 260 307 } 261 308 } as3/CannonML/trunk/src/org/si/cml/extensions/ScopeLimitObject.as
r4456 r4539 133 133 134 134 135 /** Check scope and call destroy(0) when escaped. 136 * @return flag escaped 137 */ 138 public function checkScope() : Boolean 139 { 140 if (isEscaped) { 141 destroy(0); 142 return true; 143 } 144 return false; 145 } 146 147 148 /** Check scope and stay inside of scope. 149 * @return flag limited 150 */ 151 public function limitScope() : Boolean 152 { 153 var ret:Boolean = false; 154 if (x<scopeXmin) { 155 x = scopeXmin; 156 ret = true; 157 } else if (x>scopeXmax) { 158 x = scopeXmax; 159 ret = true; 160 } 161 if (y<scopeYmin) { 162 y = scopeYmin; 163 ret = true; 164 } else if (y>scopeYmax) { 165 y = scopeYmax; 166 ret = true; 167 } 168 return ret; 169 } 170 171 172 135 173 136 174 as3/CannonML/trunk/src/org/si/cml/extensions/framework/CMLMovieClip.as
r4456 r4539 23 23 /** Screen */ 24 24 public var screen:BitmapData = null; 25 /** Pause flag */ 26 public var pause:Boolean = false; 25 27 26 28 private var _addEnterFrameListener:Boolean; // flag to add enter frame event listener … … 120 122 public function update(e:Event=null) : void 121 123 { 122 CMLObject.update();124 if (!pause) CMLObject.update(); 123 125 scene._cmlmovieclip_internal::_onUpdate(); 124 126 } as3/CannonML/trunk/src/org/si/cml/extensions/framework/modules/CMLMovieClipControl.as
r4456 r4539 101 101 { 102 102 initialize(); 103 appendArrowKeys();104 appendNumKeys();105 appendWSAD();106 appendButtons(["Z","N","CONTROL"], ["X","M","SHIFT"], ["C",","], ["V","."]);103 mapArrowKeys(); 104 mapNumKeys(); 105 mapWSAD(); 106 mapButtons(["Z","N","CONTROL"], ["X","M","SHIFT"], ["C",","], ["V","."]); 107 107 instance = this; 108 108 } … … 142 142 */ 143 143 public function map(buttonNumber:int, ...args) : CMLMovieClipControl 144 {145 var codeList:Vector.<int> = _keyCode[buttonNumber];146 if (args.length == 1 && args[0] is Array) args = args[0];147 codeList.length = 0;148 for (var i:int=0; i<args.length; i++) {149 if (args[i] is String) {150 if (args[i] in _keycode_map) {151 codeList.push(_keycode_map[args[i]]);152 } else {153 throw new Error("No keycode for String '" + args[i] + "'");154 }155 } else {156 if (int(args[i]) > 0) codeList.push(int(args[i]));157 }158 }159 return this;160 }161 162 163 /** assign keycode to the BUTTON_NUMBER164 * @param buttonNumber button number to assign165 * @param args keycodes of assigning buttons166 * @return this instance167 */168 public function append(buttonNumber:int, ...args) : CMLMovieClipControl169 144 { 170 145 var codeList:Vector.<int> = _keyCode[buttonNumber]; … … 192 167 * @return this instance 193 168 */ 194 public function appendArrowKeys(button0:Array=null, button1:Array=null, button2:Array=null, button3:Array=null) : CMLMovieClipControl195 { 196 append(KEY_UP, "UP").append(KEY_DOWN, "DOWN").append(KEY_LEFT, "LEFT").append(KEY_RIGHT, "RIGHT");197 return appendButtons(button0, button1, button2, button3);169 public function mapArrowKeys(button0:Array=null, button1:Array=null, button2:Array=null, button3:Array=null) : CMLMovieClipControl 170 { 171 map(KEY_UP, "UP").map(KEY_DOWN, "DOWN").map(KEY_LEFT, "LEFT").map(KEY_RIGHT, "RIGHT"); 172 return mapButtons(button0, button1, button2, button3); 198 173 } 199 174 … … 206 181 * @return this instance 207 182 */ 208 public function appendNumKeys(button0:Array=null, button1:Array=null, button2:Array=null, button3:Array=null) : CMLMovieClipControl209 { 210 append(KEY_UP, "NUM8").append(KEY_DOWN, "NUM2").append(KEY_LEFT, "NUM4").append(KEY_RIGHT, "NUM6");211 return appendButtons(button0, button1, button2, button3);183 public function mapNumKeys(button0:Array=null, button1:Array=null, button2:Array=null, button3:Array=null) : CMLMovieClipControl 184 { 185 map(KEY_UP, "NUM8").map(KEY_DOWN, "NUM2").map(KEY_LEFT, "NUM4").map(KEY_RIGHT, "NUM6"); 186 return mapButtons(button0, button1, button2, button3); 212 187 } 213 188 … … 220 195 * @return this instance 221 196 */ 222 public function appendWSAD(button0:Array=null, button1:Array=null, button2:Array=null, button3:Array=null) : CMLMovieClipControl223 { 224 append(KEY_UP, "W").append(KEY_DOWN, "S").append(KEY_LEFT, "A").append(KEY_RIGHT, "D");225 return appendButtons(button0, button1, button2, button3);197 public function mapWSAD(button0:Array=null, button1:Array=null, button2:Array=null, button3:Array=null) : CMLMovieClipControl 198 { 199 map(KEY_UP, "W").map(KEY_DOWN, "S").map(KEY_LEFT, "A").map(KEY_RIGHT, "D"); 200 return mapButtons(button0, button1, button2, button3); 226 201 } 227 202 … … 234 209 * @return this instance 235 210 */ 236 public function appendButtons(button0:Array=null, button1:Array=null, button2:Array=null, button3:Array=null) : CMLMovieClipControl237 { 238 append(KEY_BUTTON0, button0);239 append(KEY_BUTTON1, button1);240 append(KEY_BUTTON2, button2);241 append(KEY_BUTTON3, button3);211 public function mapButtons(button0:Array=null, button1:Array=null, button2:Array=null, button3:Array=null) : CMLMovieClipControl 212 { 213 map(KEY_BUTTON0, button0); 214 map(KEY_BUTTON1, button1); 215 map(KEY_BUTTON2, button2); 216 map(KEY_BUTTON3, button3); 242 217 return this; 243 218 }

