pixijs / pixi-projection

MIT License
190 stars 34 forks source link

Quad Container #72

Open johnryb opened 4 years ago

johnryb commented 4 years ago

I'm trying to control every corners of a container2d but having trouble doing that.

Pseudocode: container.proj.mapQuad(new Rect(0, 0, 100, 100), [new Point(-40, -50), new Point(40, -50), new Point(50, 50), new Point(50, 50)]);

I'm trying to make it look like a trapezoid.

This is working when I use Sprite2s.

Pseudocode: this.sprite.proj.mapBilinearSprite(this.sprite, this.anchoredPoints);

BTW, I'm using PIXI v4.0.

ivanpopelyshev commented 4 years ago

It should work. It works in https://pixijs.io/examples-v4/#/plugin-projection/quad-homo.js

Means you are doing something wrong in parts that I do not see, for example if that sprite is inside container and has position=(300,300)

ivanpopelyshev commented 4 years ago

Oh, wait, its Sprite2s... according to https://pixijs.io/examples-v4/#/plugin-projection/quad-bi.js you have to write container.proj.mapBilinearSprite(sprite, quad); where container is Container2s and sprite is Sprite2s its child , or its the same element.

Did you even try to debug it or you are one of those RMMV guys who just want to make features for their game/plugin fast? Because if latter, you have me respect )

johnryb commented 4 years ago

Oh, wait, its Sprite2s... according to https://pixijs.io/examples-v4/#/plugin-projection/quad-bi.js you have to write container.proj.mapBilinearSprite(sprite, quad); where container is Container2s and sprite is Sprite2s its child , or its the same element.

Sorry, I got you confused. My problem was not in Sprite2s but in container2d. My container has some sprites inside of it and I wanted to control each corners of the said container just like what I did on Sprite2s.

Note: I am using mapQuad method from container2d because it looks like the mapBilinearSprite from sprite2s. I might be using it incorrectly.

ivanpopelyshev commented 4 years ago

Yes, your code should work. Make sure all sprites are sprite2d

johnryb commented 4 years ago

Thanks for the clarification. I was using normal container inside container2d which is the problem.

PS. I am a silent reader of all your replies. You've been a great help Ivan since I started coding using PIXI.

ivanpopelyshev commented 4 years ago

Thank you!

Yes, all containers here are big hacks, they have special transform that holds matrix 3x3 or 4x4 instead of usual pixi 3x2. In container2s case its even worse.

Placing regular container inside them works for small objects, but it loses the perspective part.