Skip to main content
GogetaX
Inspiring
April 5, 2019
Question

localToGlobal creating too much resources?

  • April 5, 2019
  • 0 replies
  • 391 views

Hello everyone, i recently started to play with localToGlobal command to get accurate position of my MovieClips at the stage, but i see this command creates new Point every time in loop..

stage.addEventListener(Event.ENTER_FRAME, UpdateCarPhysics);

var VelY: Number = 0.0;

var Grav: Number = 0.05;

var Pos:Point = BackWheel.localToGlobal(new Point());

function UpdateCarPhysics(e:Event): void {

//Check if Wheel is hited the ground

Pos = BackWheel.localToGlobal(new Point()); << this command create new point every time in loop, is there any other way to avoid memory loses on that? if it actually losing memory..

if (Ground.hitTestPoint(Pos.x,Pos.y, true)) {

VelY = 0;

} else {

VelY = VelY + Grav;

BackWheel.y += VelY;

}

}

This topic has been closed for replies.