bpbwan / andengine

Automatically exported from code.google.com/p/andengine
0 stars 0 forks source link

Modifiers cannot be pooled easily, particularly PathModifiers #28

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
  1. Create a PathModifier with a given Path
  2. Try to reset any of the values
3.

What is the expected output? What do you see instead?
  Expected behavior is the ability to reuse a modifier, particularly PathModifiers since movement/paths are such a common aspect of games.  However, you cannot reuse a PathModifier object unless you use exactly the same path with exactly the same duration, which is not useful in many situations.

  For example, you may want to move a character from where he is to where the user taps.  PathModifiers would work very well here except that in order to use a PathModifier for this purpose, one
would have to allocate a new PathModifier every time the user taps the screen.  
This is performance-killing and, realistically, not an option for a 
smooth-running game.

This affects other modifiers as well because crucial fields are private and 
final.

What version of the product are you using? On what operating system?
  AndEngine still doesn't have version numbers!  This is the latest version as of March 2011.

Please provide any additional information below.
  None.

Original issue reported on code.google.com by colinbr...@gmail.com on 10 May 2011 at 7:01

GoogleCodeExporter commented 8 years ago
Yes, I agree, PathModifiers should be able to be created relative to the sprite 
with the PathModifier. In my game, I also have to constantly create new 
PathModifiers. I am not sure how bad my game performance is being affected, 
though.

A workaround would be to use a PhysicsHandler to set a velocity for some time, 
but that's not as accurate.

Original comment by prem.q.n...@gmail.com on 29 Jul 2011 at 7:38

GoogleCodeExporter commented 8 years ago
This is still a serious gotcha--the expected behavior (and best practice) for 
games is to be able to avoid heap allocation in the game loop.  If I have to 
constantly create new Modifiers, the garbage collector is going to be firing 
when I don't want it to.

Original comment by thomasjakway1@gmail.com on 11 Jun 2013 at 11:57