Mercurial > hg > ristipolku
comparison game/IDMWidget.java @ 177:9f04e8ab180a
Make widget positions relative to parent. Implementation might be incorrect,
though.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 16 Mar 2017 10:45:13 +0200 |
parents | 55ea5821c802 |
children | fa9f29387cff |
comparison
equal
deleted
inserted
replaced
176:9d3ff9605555 | 177:9f04e8ab180a |
---|---|
85 this.setScale(new IDMPoint(x, y)); | 85 this.setScale(new IDMPoint(x, y)); |
86 } | 86 } |
87 | 87 |
88 public int getScaledX() | 88 public int getScaledX() |
89 { | 89 { |
90 return (int) (pos.x * scale.x); | 90 return (int) (pos.x * scale.x) + (parent != null ? parent.getScaledX() : 0); |
91 } | 91 } |
92 | 92 |
93 public int getScaledY() | 93 public int getScaledY() |
94 { | 94 { |
95 return (int) (pos.y * scale.y); | 95 return (int) (pos.y * scale.y) + (parent != null ? parent.getScaledY() : 0); |
96 } | 96 } |
97 | 97 |
98 public int getScaledX(float x) | 98 public int getScaledX(float x) |
99 { | 99 { |
100 return (int) (x * scale.x); | 100 return (int) (x * scale.x) + (parent != null ? parent.getScaledX() : 0); |
101 } | 101 } |
102 | 102 |
103 public int getScaledY(float y) | 103 public int getScaledY(float y) |
104 { | 104 { |
105 return (int) (y * scale.y); | 105 return (int) (y * scale.y) + (parent != null ? parent.getScaledY() : 0); |
106 } | 106 } |
107 | 107 |
108 public int getScaledRelX(float x) | 108 public int getScaledRelX(float x) |
109 { | 109 { |
110 return (int) ((pos.x + x) * scale.x); | 110 return (int) ((pos.x + x) * scale.x) + (parent != null ? parent.getScaledX() : 0); |
111 } | 111 } |
112 | 112 |
113 public int getScaledRelY(float y) | 113 public int getScaledRelY(float y) |
114 { | 114 { |
115 return (int) ((pos.y + y) * scale.y); | 115 return (int) ((pos.y + y) * scale.y) + (parent != null ? parent.getScaledY() : 0); |
116 } | 116 } |
117 | 117 |
118 public int getScaledWidth() | 118 public int getScaledWidth() |
119 { | 119 { |
120 return (int) (size.x * scale.x); | 120 return (int) (size.x * scale.x); |