문제

I'm making a small game with Direct2D in C++ and I'm in the point where I need a camera because some levels are bigger than the screen width and height so that the player can see all the level.

So my question is how to implement a camera system in Direct2D?

도움이 되었습니까?

해결책

ID2D1RenderTarget::SetTransform can be used to implement a 2D camera. All drawing operations will first apply the transform, which is a 3x2 matrix and therefore fully capable of representing a camera with translation, rotation, scale, and skew (though you probably shouldn't let your camera skew the scene). As for how to generate the matrix, look at the helper functions in the D2D1::Matrix3x2F class and check out this article on applying transforms.

As for an actual look-at camera, if you want to have look-at coordinate c in the center of a target of size s, you would set the translation to (s / 2) - c.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top