Game Development Reference
In-Depth Information
dispatchEvent(new Event(EVENT_COMPLETE));
}
private function profileAddObject():void {
var profilerTempObject:Object = new Object();
profilerTempObject.x=(Math.random() * 399);
profilerTempObject.y=(Math.random() * 399);
profilerTempObject.speed = (Math.random() * 5) + 1;
profilerTempObject.dx=Math.cos(2.0*Math.PI*((Math.random()*360)-90)/360.0);
profilerTempObject.dy = Math.sin(2.0 * Math.PI * ((Math.random()*360) - 90)
/ 360.0);
profilerObjectArray.push(profilerTempObject);
}
private function profileUpdate():void {
for each (profilerTempObject in profilerObjectArray) {
profilerTempObject.x += profilerTempObject.dx * profilerTempObject.speed;
profilerTempObject.y += profilerTempObject.dy * profilerTempObject.speed;
if (profilerTempObject.x > profilerCanvas.width) {
profilerTempObject.x = 0;
}else if (profilerTempObject.x < 0) {
profilerTempObject.x = profilerCanvas.width;
}
if (profilerTempObject.y > profilerCanvas.height) {
profilerTempObject.y = 0;
}else if (profilerTempObject.y < 0) {
profilerTempObject.y = profilerCanvas.height;
}
}
}
private function profileRender():void {
profilerCanvas.lock();
profilerRenderPoint.x = 0;
profilerRenderPoint.y = 0;
profilerCanvas.copyPixels(profilerBackground, profilerBackground.rect,
profilerRenderPoint);
for each (profilerTempObject in profilerObjectArray) {
profilerRenderPoint.x = profilerTempObject.x;
profilerRenderPoint.y = profilerTempObject.y;
profilerCanvas.copyPixels(profilerObject, profilerObject.rect,
profilerRenderPoint);
}
Search WWH ::




Custom Search