gotoAnd lag

Community Beginner ,
Jul 05, 2020 Jul 05, 2020

Copy link to clipboard

Copied

In the game i am making,  Animate/As3/Swf enemies can get hit often, making the hurt animation replay or gotoAndStop at the specific hurt animation type and gotoAndPlay to a random frame between 1-5. The randomization is needed so when a clump of enemies get hit, they don't look the same each time.

 

This however cause tremendous lag and looking it in Scout, the culprit is the gotoAndStop/gotoAndPlay/nextFrame etc. I even removed the random parts and it is still laggy, dropping to 12 fps each time a clump of 10-20 enemies start hurting. Any recommendations? thanks!

Views

77

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 05, 2020 Jul 05, 2020

Copy link to clipboard

Copied

that's fixable but not easily fixable unless you're willing to decrease the number of on stage objects with changing bitmap.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 05, 2020 Jul 05, 2020

Copy link to clipboard

Copied

i am already using bitmap/png for the animations and have no vector shapes in the game at all. even defaulted the quality to 'low' and the lag spikes still happen and again, according to scout, its the gotos.

 

to further explain, I add enemies to the screen and each enemy has nested clips in them and i change the animations like this:

 

enemy.mc.gotoAndStop("The AnimationTypeIwant");

enemy.mc.mc.gotoAndPlay("TheFrameFromTheAnimationTypeISet");

 

scout.jpg

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 08, 2020 Jul 08, 2020

Copy link to clipboard

Copied

LATEST

that's pretty much a worst-case scenario for performance so again, either limit the number of enemies on screen at one time or re-think your approach.

 

the following is an excerpt from (Flash Game Development: In a Social, Mobile and 3D World)

 

 

Optimization Techniques


Unfortunately, I know of no completely satisfactory way to organize this information. In what follows, I discuss memory management first with sub-topics listed in alphabetical order. Then I discuss CPU/GPU management with sub-topics listed in alphabetical order.


That may seem logical but there are, at least, two problems with that organization.


1. I do not believe it is the most helpful way to organize this information.
2. Memory management affects CPU/GPU usage, so everything in the Memory Management section could also be listed in the CPU/GPU section.


Anyway, I am going to also list the information two other ways, from easiest to hardest to implement and from greatest to least benefit.


Both of those later listings are subjective and are dependent on developer experience and capabilities, as well as, the test situation and test environment. I very much doubt there would be a consensus on ordering of these lists. Nevertheless, I think they still are worthwhile.


Easiest to Hardest to Implement
1. Do not use Filters.
2. Always use reverse for-loops and avoid do-loops and avoid while-loops.
3. Explicitly stop Timers to ready them for gc (garbage collection).
4. Use weak event listeners and remove listeners.
5. Strictly type variables whenever possible.
6. Explicitly disable mouse interactivity when mouse interactivity not needed.
7. Replace dispatchEvents with callback functions whenever possible.
8. Stop Sounds to enable Sounds and SoundChannels to be gc'd.
9. Use the most basic DisplayObject needed.
10. Always use cacheAsBitmap and cacheAsBitmapMatrix with air apps (i.e., mobile devices).
11. Reuse Objects whenever possible.
12. Event.ENTER_FRAME loops: Use different listeners and different listener functions applied to as few DisplayObjects as possible.
13. Pool Objects instead of creating and gc'ing Objects.
14. Use partial blitting.
15. Use stage blitting.
16. Use Stage3D.


Greatest to Least Benefit
1. Use stage blitting (if there is enough system memory).
2. Use Stage3D.
3. Use partial blitting.
4. Use cacheAsBitmap and cacheAsBitmapMatrix with mobile devices.
5. Explicitly disable mouse interactivity when mouse interactivity not needed.
6. Do not use Filters.
7. Use the most basic DisplayObject needed.
8. Reuse Objects whenever possible.
9. Event.ENTER_FRAME loops: Use different listeners and different listener functions applied to as few DisplayObjects as possible.
10. Use reverse for-loops and avoid do-loops and while-loops.
11. Pool Objects instead of creating and gc'ing Objects.
12. Strictly type variables whenever possible.
13. Use weak event listeners and remove listeners.
14. Replace dispatchEvents with callback functions whenever possible.
15. Explicitly stop Timers to ready for gc.
16. Stop Sounds to enable Sounds and SoundChannels to be gc'd.

 

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines