Gamua / Starling-Framework

The Cross Platform Game Engine
http://www.starling-framework.org
Other
2.87k stars 826 forks source link

Reuse TouchEvent in the TouchProcessor #830

Closed DerBensch closed 8 years ago

DerBensch commented 8 years ago

The TouchEvent is created every time the mouse moves (on a system with a cursor). Maybe it would be good if the TouchEvent is reused to avoid the creation of objects. I tried that by adding a private property in the TouchProcessor and created a TouchEvent in the constructor. I had to set the shiftKey and ctrlKey every time (to do this I removed the getter of them in the TouchEvent and converted the property to a public variable which is much faster anyways). Also I had to reset the _visitedObjects every time. In the end it all worked :) Is there a reason to create a new TouchEvent? Am I missing something?

PrimaryFeather commented 8 years ago

There's no specific reason they are not pooled, no — at least I can't think of any. You're right, this would be a nice area for an optimization. I'll look into it!

PrimaryFeather commented 8 years ago

I did that with 7bba8f1!