Making Pong Game using FLASH
Adding Subscenes & Working with Action Script 2.0 Code

 

Today you will be looking at ways to make your Pong Game work even better. You will learn about SUBSCENES which are a great way to add an animation inside of an animation. We will use a subscene to make the ball spin. You will also do some editing of the Action Script 2.0 code to make the ball move faster.

CLICK HERE to watch Mr. Durfee's VIDEO on how to make subscenes and how to edit your Action Script 2.0 code.

NEXT --> Now let's make some changes to the code in your Pong game animation and see how this changes how the game plays. For example, you can go into the Action 2.0 code for the ball and change the Full Speed from 20 to, perhaps, 60, tripling the speed. Control Test the animation and see how a faster ball changes your game. Now for something a bit more tricky, Change the paddlez from auto play to manual play by changing the code to add keys to move. Check out the code examples below:

Original Code - paddlez (simple Artificial Inteligence AI for paddle z) New Code - paddlez (adding the Alt and Ctrl keys for manual play)
onClipEvent(load)
{
this._y=5;
this._x=275;
this.paddlespeed=20
}
onClipEvent(enterFrame) //below is a simple AI for pong
{
if(this._x>_root.ball._x+5)
{
this._x-=this.paddlespeed;
}
if(this._x<_root.ball._x-5)
{
this._x+=this.paddlespeed;
}
}
onClipEvent(load)
{
this._y=5;
this._x=275;
this.paddlespeed=40;
}
onClipEvent(enterFrame)
{
if(Key.isDown(Key.CONTROL)&&this._x>30)
{
this._x-=this.paddlespeed; //move paddle paddlespeed pixels left
}
if(Key.isDown(Key.ALT)&&this._x<520)
{
this._x+=this.paddlespeed; //move paddle paddlespeed pixels right
}
}

Content on this page requires a newer version of Adobe Flash Player.

Get Adobe Flash player


Want to analyze Noah's 2 player game CLICK HERE to load Noah's FLASH document file

Return to CMS Home Page