0

I'm using physInjector and therefore cannot move clips containing my objects: The physical engine works incorrectly because of it.

I think about implementing something like a bitmap drawing a selected part of the stage on itself. How can it be done? I've read this Trying to capture stage area using BitmapData, but there the author copies its data from the stage, whereas I need the area outside it.

Besides, aren't there less resource-consuming solutions?

Community
  • 1
  • 1
user2136963
  • 2,526
  • 3
  • 22
  • 41

2 Answers2

1

First, you may want to use a global Sprite to put your clips insde, like :

var a:Sprite = new Sprite();
a.addChild(myClip1);
a.addChild(myClip2);
...

Then, you should be able to move a.

If you don't, and your physic engine rely on Stage to work, you should probably try to fix it, or to understand better how it work so you can move your movieclips.

Redraw a BitmapData every frame will require a lot of CPU ressource, and you won't be able to interact with your clips. That's really not the best way to go.

blue112
  • 52,634
  • 3
  • 45
  • 54
0
x=-(player.mc.x-stage.stageWidth/2);
y=-(player.mc.y-stage.stageHeight/2);
if(canvas)
    removeChild(canvas);

var bd:BitmapData=new BitmapData(stage.stageWidth,stage.stageHeight,false,0xFFFFFF);

bd.draw(stage);
trace(bd);

canvas=new Bitmap(bd);
addChild(canvas);

x=0;
y=0;

At PC it works fine. Don't know whether it is suitable for mobiles.

I also haven't tested the approach suggested by blue112 because in twitter of physinjector developer there are complaints about ANY moving of parent clip (https://twitter.com/reyco1/status/327107695670853632) and it is quite difficult to combine with my existing architecture.

Changing the globalOffsetX and globalOffsetY properties also didn't help

user2136963
  • 2,526
  • 3
  • 22
  • 41