How to re-spawn particles randomly in Away3D - actionscript-3

I'm attempting to create a particle effect using Sparticle and Away3d. The effect is a little burst of bubbles that float up to the top of the screen when items are clicked.
I have the effect loaded and working and it looks good, but unfortunately the effect always spawns the bubbles with the same random velocities each time. The velocities seem to be set when the animation first runs and then never changes.
How do I restart the animation with new velocities each time?
I've tried calling stop and start on the animator, and resetTime but I suspect it's just moving the time back to 0 and that's why the animation isn't actually restarting properly.
i.e.
particleGroup.animator.stop();
particleGroup.animator.start();
The reset method doesn't do anything because it expects an animation name, and the animation name set in the sparticle editor doesn't seem to be available.

Related

Babylon.js disable frustum culling for SolidParticleSystem?

I'm attempting some simple data viz of a point cloud. My scene contains nothing but a 40K particle SolidParticleSystem and a small ground plane used for a visual reference when moving the camera. Every time world 0,0,0 goes out of the view frustum (by rotating or moving the camera), the entire SolidParticleSystem ceases to render.
It took me a long time to figure out why my particles kept disappearing for no apparent reason, until by trial and error of moving the camera around I figured out what was going on. The reference plane continues to render as expected.
Is it possible to defeat this behavior?
It is:)
Just call mesh.alwaysSelectAsActiveMesh = true and this way the frustum test will be disabled

Actionscript-3 looping issue--Adobe Animate CC

My employer decided they wanted me to start doing animation with Adobe's new "Animate CC" application. My issue is that I don't know how to loop my animation outside of the Adobe Animate environment. I am new to Adobe Animate CC and ActionScript, unfortunately, so I will probably need a relatively basic answer to understand why my solution isn't working. From what I can tell, my ActionScript code is being ignored by the IDE completely.
In the IDE and in the browser test command, the animation plays beyond frame 100, to the end, and then flashes a frame of white before repeating. I need it to loop without this white frame interrupting the screen, whether that be through a loop or some other means that I'm just not aware of.
For context: my project has about 100 layers of content and I'm unfamiliar with how this program works. I've thoroughly searched the web for tutorials on how to do what I need to do, but I've come up empty handed.
I have an actions layer among my motion tweens and other layers
https://gyazo.com/6e0b8502d98b6c9903bb96ac3a939bae
I've been trying to use gotoAndPlay(0) at frame 100 to start the animation over from the beginning.
https://gyazo.com/704ee7158bae6dfd149b6283cfa33451
Basically, how do I use Action-Script in Adobe Animate CC in order to infinitely loop my animation until closed?
Thanks everyone.
Your flicker may be a result of having an extra blank keyframe on one of your layers.
Assuming that you don't have any additional scripts to stop your animation (e.g. stop()), the Timeline should loop automatically whether your animation is inside a MovieClip or on the main Timeline. You shouldn't have to put any script on your timeline or in a separate AS file to make an animation loop. I would suggest this method.
Additionally, although you have the code specifying that you want it to go the first frame, it will ignore your call because the timeline is still playing and therefore the priority. One way you can combat this is by adding a stop(); function and a delay timer that contains your gotoAndPlay(0) function. This will take focus away from playing the Timeline and will allow you to execute your script. I wouldn't suggest this method because it seems a bit redundant.
However, if you're curious one way that you could approach this is shown below, simply add this script to the frame you want the animation to restart at.
//Stop the Timeline
stop();
//Create a delay timer for 5 miliseconds that is executed once
var timer:Timer = new Timer(5,1);
//Add an event listener that calls once the timer is complete
timer.addEventListener(TimerEvent.TIMER_COMPLETE, timerHandler);
//Start the timer
timer.start();
//Timer handler that is called once the delay timer is complete
function timerHandler(event:TimerEvent){
//Go to and play the first frame
gotoAndPlay(0);
}

Cocos2D-X nodes loading in wrong positions have RemoveAllChildren()

I'm only using one scene object for my entire 2d sidescrolling platformer with two layers: There is a hudLayer for the controller, and the gameLayer for everything in the game.
When I control my character to walk into a door (sprite with a physicsBody that has a callback that takes me to the next level), the next level loads by these instructions:
remove all event listeners
stop all actions for both layers (the gameLayer typically has been doing a Follow action that follows the player, and is limited to the size of the backgroundSpriteNode)
remove all children from the gameLayer
set gameLayer position to Vec2(0,0)
load level 2 (a complete copy of what level 1 should look like... load the background sprite to gameLayer, playerSprite, add event listeners)
add event listeners back to the hudLayer
The only problem is that for whatever reason, the level only partially loads the way it should... For instance, coins appear in the spots they should, but platforms don't seem to. Neither that or the player, or other characters. Not sure really why these objects are specifically not loading in the correct positions, but maybe someone who has experienced this sort of problem before can help?
Most nodes (such as platforms) are appearing below the bottom of the screen when they should be fully shown at the bottom of the screen. Characters are appearing down there too when they should be appearing above the platforms.
P.S. After testing a bit more, I've come to realize that SOMETIMES some of the platforms are loading in the correct positions, but sometimes they aren't. Not sure why. A fix for this may be to load things one at a time with a delay between them. But I'd rather not have to put delays and just figure out what the deal is.
Figured it out: for whatever reason, I needed to add a delay in there. I think for whatever reason, by calling removeAllChildren(), something got messed up with the positions. It was my suspicion since SOME of the time, parts of the next level would load, but only some parts, and only sometimes.
Here's the code I added to run an action on the gameLayer once all children were removed, etc...
runAction(Sequence::createWithTwoActions(DelayTime::create(0.1), CallFunc::create( [&] ( ) {
loadLevel2(this);
})));

Flash Pro: Collision of objects only works correctly when on Frame 1

as you may have noticed just by reading the title it is quite hard to summarize the problem,
which is probably why I couldn't find a solution anywhere.
I am currently working on a flash game using adobe flash pro CC.
I started by creating the first level of my sidescrolling game and got everything to work just as I wanted it to. All my work was on a single frame (frame 1) and on a single layer and it worked fine.
However, when I then went on to move the frame a little further back and added frames in front of it for the menu I encountered a problem.
When I "gotoAndStop" to the frame with my game content on it, everything works except the collision between my character and my objects. My character is now sunk into the "floor object" about have his size, while when i move the frame back to "frame 1" everything works fine again.
I am losing my mind over this. Please help me :(
in flash when you start changing a dynamic property such as x or y, that object will be independent from the keyframe where it originally was ~forever~, even if you go back to the original keyframe. therefore if you start some enterframe and change the playhead afterwards you will get some awkward (but expected) behaviour.
ideally, jump to the game keyframe and just then call whatever methods needed to start the game.

Flex Smooth Drag of Objects

I'm trying to create an object which can be moved in Flex 4.
I tried http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf64595-7fed.html but in this most examples actually leaves the actual object (at pause) until the drag is completed, but I'm looking for something where the update will be done/shown while the drag is still on ... in those lines I've tried: Problems replicating drag-and-drop with mouse events ... but here I dint understand 'what are MouseHelper & EventHelpers'.
Also tried this: Flash AS3 custome Dragging using MOUSE_MOVE event but the movement is not smooth, very jig-jag.
Any suggestions are most welcome.
Regards
here's an example with 5 ways of dragging (four are commented out):
* MouseEvent.MOUSE_MOVE
* Event.ENTER_FRAME
* startDrag(true)
* Timer(10) which sets x = mouseX y = mouseY every 10ms
* Timer(100) which creates a tween to mouseX, mouseY instead of applying values
If i move the mouse fast enough all of those modes (at 30fps) look as if a sprite is chasing mouse cursor, not being dragged, and also the animation is not smooth at all. However the smoothest animation is provided by tweener, but that mode shows a bigger average distance between mouse cursor and the sprite being dragged.
and btw fast dragging e.g. windows explorer also makes it blink because it doesn't have enough time for rendering at every position