因此,我逐渐痛苦地从加工到闪电,希望能向更多的受众发展游戏。 很久以来,我在闪电中得到了一份工作申请,这只是让用户点击,制造随后向摩擦.块。 我也做了同样的处理,只是比较速度。 然而,当我管理闪电版本并增加大约15-20个区块时,基底降至5-10个。 在处理版本中,我可以增加约60个,没有明显放缓。 交易是什么?
3. 与每种版本的来源的联系:
http://ge.tt/6vrRdBe”rel=“nofollow” 闪电版本
http://ge.tt/4TwQdBg”rel=“nofollow”> 处理版本
这里是每个人的源泉,如果你是荒唐的,那么,他们就能够通过在法典中lower击来提供帮助,并告诉他们:
闪电版本:
段 次 页 次
import flash.events.Event;
import flash.display.MovieClip;
stage.addEventListener( Event.ENTER_FRAME, onenter );
stage.addEventListener( MouseEvent.MOUSE_DOWN, onclick );
var main = this;
var lastFrame:Number;
var Blocks:Array = new Array();
function onenter( e:Event ):void
{
var time:Number = getTimer();
for( var i = 0; i < Blocks.length; i++ )
{
Blocks[ i ].run();
}
FrameRate.text = String( Blocks.length ) + "
" + String( 1000 / ( time - lastFrame ) );
lastFrame = time;
}
function onclick( e:MouseEvent ):void
{
var block1 = new Block( Blocks, main, mouseX, mouseY );
}
路障。
package {
import flash.display.MovieClip;
import flash.geom.Vector3D;
public class Block extends MovieClip {
var velocity:Vector3D = new Vector3D( 0, 0 );
var position:Vector3D = new Vector3D( x, y );
var acceleration:Vector3D = new Vector3D( 0, 0 );
public function Block( Blocks:Array, This, x:Number, y:Number ) {
Blocks.push( this );
This.addChild( this );
position.x = x;
position.y = y;
}
public function run()
{
x = position.x;
y = position.y;
//position.incrementBy( velocity );
position.x += velocity.x;
position.y += velocity.y;
acceleration.x = stage.mouseX - position.x;
acceleration.y = stage.mouseY - position.y;
acceleration.normalize();
//velocity.incrementBy( acceleration );
velocity.x += acceleration.x;
velocity.y += acceleration.y;
velocity.x *= 0.95;
velocity.y *= 0.95;
this.graphics.beginFill( 0 );
this.graphics.moveTo( -10, -10 );
this.graphics.lineTo( 10, -10 );
this.graphics.lineTo( 10, 10 );
this.graphics.lineTo( -10, 10 );
this.graphics.lineTo( -10, -10 );
this.graphics.endFill();
}
}
}
处理版本:
sketch_mar02b.pde
Block[] blocks = new Block[ 0 ];
void setup()
{
frameRate( 60 );
size( 550, 400 );
textFont( createFont( "Verdana", 20 ) );
}
void draw()
{
background( 255 );
for( int i = 0; i < blocks.length; i++ )
{
blocks[ i ].run();
}
text( blocks.length + "
" + frameRate, 0, 20 );
}
void mousePressed()
{
new Block( mouseX, mouseY );
}
页: 1
class Block
{
PVector position = new PVector( 0, 0 );
PVector velocity = new PVector( 0, 0 );
PVector acceleration = new PVector( 0, 0 );
Block( float x, float y )
{
position.set( x, y, 0 );
blocks = ( Block[] ) append( blocks, this );
}
void run()
{
position.add( velocity );
acceleration.set( mouseX - position.x, mouseY - position.y, 0 );
acceleration.normalize();
velocity.add( acceleration );
velocity.mult( 0.95 );
pushMatrix();
translate( position.x, position.y );
fill( 0 );
rect( -10, -10, 20, 20 );
popMatrix();
}
}
感谢帮助!