Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 11-29-2008, 02:27 AM   #1
Phosphoer
Registered User
 
Join Date: Nov 2008
Posts: 9
Default question about Classes

Hey guys, I'm fairly new to actionscript, I made a few games in Flash CS3 using AS 2.0, but 3.0 seems to be a whole new deal. I'm more familiar with c++ than I am with actionscript.

Anyways, I'm working with Flash Develop, and I have a question about classes. In my practice project, I have a ball class, and the application class. The application class creates some number of balls, and the ball class directs the balls to crowd around the mouse and bounce off the edges of the screen. My question is how would I add collision with other instances of the ball, or even just other objects that I add in later? ( platforms.. etc) Is there some way to refer to other instances of the ball class from within it's own class?

My code structure looks something like this:
Application class
{
Create Balls
}

Ball Class
{
Constructor
Move Ball
Collide with screen edges
}

Thanks in advance
Phosphoer is offline   Reply With Quote
Old 12-01-2008, 10:17 AM   #2
LeenieGames
Registered User
 
Join Date: Oct 2008
Posts: 22
Default

It might make your life easier if you handled the ball animations from the Application Class rather than from the Ball Class.

The ball objects just need to hold variables that Application can access and change, such as currentSpeed.

Then you just need one enterFrame function in Application that loops through an array of all of your balls and animates them. Something like ballsArray[i].x += ballsArray[i].currentSpeed.

With this method you have access to all of your balls in a central location (Application).

Last edited by LeenieGames; 12-01-2008 at 07:46 PM.
LeenieGames is offline   Reply With Quote
Old 12-02-2008, 02:52 AM   #3
Phosphoer
Registered User
 
Join Date: Nov 2008
Posts: 9
Default

Thanks, that sounds like an excellent plan
Phosphoer is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
simple question about multiple classes muchogrande ActionScript 3.0 5 05-21-2008 09:15 PM
Question Score Weight? Jadeivy ActionScript 2.0 0 06-14-2006 03:26 PM
Classes: Stupid newbie question zoltan ActionScript 2.0 1 06-06-2006 10:56 PM
A question about ActionScript classes... Terpentine ActionScript 2.0 13 11-22-2004 09:18 AM
[AS1] Swapdepth using txt files and dynamic content for game. superbnerb Gaming and Game Development 3 09-22-2004 07:27 PM


All times are GMT. The time now is 12:42 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.