• Home
  • Free Tutorials
  • Free Video Tutorials

Adobe Photoshop
Autodesk 3ds Max
CSS
Flash
Help Center Live
iPhone
Joomla
Make Money Online!
Mambo
mIRC
Outlook Express
SEO / SEM
Simple Machine Forum
Target Explorer

Ping Pong - Moving Pads

Category : Flash Views : 21797
Version : 8 Rating : 
2.9/5 (43 votes)
  • Currently 2.91/5
  • 1
  • 2
  • 3
  • 4
  • 5
Type : Text Source File: ping-pong-moving-pads.zip
Result: See the result


<<< PreviousIndex SeriesNext >>>

Previous | 1 | 2 | Next

I didn't move my pad and these are the scores I got:
Free Flash Tutorials, Free Flash Game, Ping Pong Game, Moving Pads

Code Explanation

onClipEvent(enterFrame) { if(Key.isDown(Key.RIGHT)) { point = new Object(); point.x = this._x; point.y = this._y; localToGlobal(point);
This piece of code creates a point object with the properties "x" and "y" equal to the Movie Clip's _x and _y properties.
Then we translate this local (inside the parent Movie Clip) coordinate to a global (stage) coordinate using the function:
localToGlobal(point object);
The function won't return a value but will convert the point object you passed to it.

if(point.x + 10 >= 220) { return; }
If the point object we just created plus the moving speed is greater that what this Movie Clip can move (220px) we return and the next line of code won't run.

this._x += 10; } else if(Key.isDown(Key.LEFT)) { point = new Object(); point.x = this._x; point.y = this._y; localToGlobal(point); if(point.x - 10 <= -20) { return; }
If the global _x coordinate of this Movie Clip (point.x) is smaller than what it can move to the left, return.
this._x -= 10; } }

In the next tutorial we are going to make scores and the game more difficult.


More cool tech articles from other blogs.

Place your ad here
Loading...


Previous | 1 | 2 | Next

<<< PreviousIndex SeriesNext >>>
How to Video Tutorials on software by Helpvids.com

Sponsors





Abbotsford Web Design
singapore website design
Studio | Advertisement | About Webzo | Contact Webzo | Terms of Use | Free Video Tutorials by Helpivds

Copyright © 2007 NR Concepts Ltd. All rights reserved.