MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / setPosition

Method setPosition

Source/Platformer/PlatformCamera.cpp:30–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28 , _viewSize() { }
29
30void PlatformCamera::setPosition(const Vec2& position) {
31 _camPos = position;
32 Vec2 newPos = position;
33 Vec2 pos = _position;
34 if (_boundary != Rect::zero) {
35 Size viewSize = Size{_viewSize.width / _zoom, _viewSize.height / _zoom};
36 float xOffset = viewSize.width / 2.0f;
37 float yOffset = viewSize.height / 2.0f;
38 newPos = {
39 Math::clamp(position.x, _boundary.getLeft() + xOffset, _boundary.getRight() - xOffset),
40 Math::clamp(position.y, _boundary.getBottom() + yOffset, _boundary.getTop() - yOffset)};
41 pos = {
42 Math::clamp(pos.x, _boundary.getLeft() + xOffset, _boundary.getRight() - xOffset),
43 Math::clamp(pos.y, _boundary.getBottom() + yOffset, _boundary.getTop() - yOffset)};
44 }
45 _position.x = _target.x = newPos.x;
46 _position.y = _target.y = newPos.y;
47 _transformDirty = true;
48 moved(newPos.x - pos.x, newPos.y - pos.y);
49}
50
51void PlatformCamera::setRotation(float var) {
52 _rotation = var;

Callers 6

destroyMethod · 0.45
toNodeMethod · 0.45
onCameraMovedMethod · 0.45
onCameraResetMethod · 0.45
updateMethod · 0.45
runMethod · 0.45

Calls 5

getBottomMethod · 0.80
getTopMethod · 0.80
clampFunction · 0.50
getLeftMethod · 0.45
getRightMethod · 0.45

Tested by

no test coverage detected