Welcome, Guest
Want to take part in these discussions? Sign in if you have an account, or apply for one below
-
- CommentAuthorpriest
- CommentTimeFeb 27th 2010
I'd like to add sound files to particles as they're created, and then use collisions to trigger the sounds. Ideally I'd like to be able to set sound properties on the fly so that, for example, amplitude would be a function of mass and velocity, and stereo placement would be analogous to x-value on the stage.
Can someone point me in the right direction to get started? Should I extend the Particle class to add a sound property? Would I also need to change the Emitter and ParticleFactory classes, etc.?
I'm an OOP noob. I have ActionScript books on hand to help with the basics, but I would greatly appreciate as much detail and patience as you can muster. Open-source examples of similar efforts would be helpful too.
Thank you! -
- CommentAuthorpriest
- CommentTimeFeb 28th 2010
Update: I managed to figure out a way to do much of this — surely not the proper way (I just modified the Particle class and a couple of others) — but the urgency has passed since I have a basic working model ready to show. So I'll bother a local friend who understands OOP better than I; no need for anyone here to go to heroic measures to bring me up to speed.
I may pop back in with some more refined questions shortly. If I produce something worth sharing I'll post a link. Can't thank you enough for sharing this wonderful framework. -
- CommentAuthorpriest
- CommentTimeMar 2nd 2010 edited
I would like to be able to set the amplitude of a sound triggered on collision by the masses and velocities of the two objects. I'm running into some problems:- I can get both their masses, but I can only access velX and velY for otherObject, not for the particle referenced by the particlesCollision object. If I try to access particle.velX as follows
public function collisionHandler( e:ParticleEvent ) {
trace("particle velX = " + e.particle.velX);
}
I get the following error message: 1119: Access of possibly undefined property velX through a reference with static type org.flintparticles.common.particles:Particle.
Substitute e.otherObject.velX above and it displays a credible velocity value. What am I missing? Also, when two particles collide, how does Flint determine which is the particle and which is the otherObject? - Is it possible to configure a bounding box so that a collision is registered when a particle strikes it?
-
- CommentAuthorRichard
- CommentTimeMar 16th 2010 edited
The normal way to add further properties to a particle is to add them to the particle's dictionary object. That way you don't have to extend or modify the Particle class at all.particle.dictionary["sound"] = ...
The particle property of the ParticleEvent is of type Particle - the base class for 2D and 3D particles. To use it's velX property you will need to cast it to a Particle2Dpublic function collisionHandler( e:ParticleEvent ) {
trace("particle velX = " + Particle2D( e.particle ).velX);
}
Unfortunately the bounding box class doesn't dispatch an event when the collision occurs. It's a good suggestion and I'll add it as a feature shortly. meanwhile, you could edit the class yourself to dispatch an event when a collision occurs. -
- CommentAuthorRichard
- CommentTimeMar 17th 2010
I've now added that event to the bounding box collisions. It's in the source code in SVN already and will be in the next release. -
- CommentAuthorpriest
- CommentTimeMay 7th 2010
I can't thank you enough for your responsiveness. And I'm quite excited to learn that I made a good suggestion!
I've had to drop my project for a while, but am resuming now, so I will try your .dictionary method.
1 to 6 of 6
