@@ -171,58 +171,68 @@ public void stopAllSounds() {
171
171
}
172
172
173
173
/**
174
- * Sets the tint for the current costume with rgb.
174
+ * Sets the tint for the sprite with rgb.
175
175
*
176
176
* @see ScratchImage#setTint(float, float, float)
177
177
*/
178
178
public void setTint (int r , int g , int b ) {
179
179
if (costumes .size () == 0 ) return ;
180
180
181
- this .costumes .get (this .currentCostume ).setTint (r , g , b );
181
+ for (ScratchImage costume : this .costumes ) {
182
+ costume .setTint (r ,g ,b );
183
+ }
182
184
}
183
185
184
186
/**
185
- * Sets the tint for the current costume with a hue.
187
+ * Sets the tint for the sprite with a hue.
186
188
*
187
189
* @see ScratchImage#setTint(float)
188
190
*/
189
191
public void setTint (float h ) {
190
192
if (costumes .size () == 0 ) return ;
191
193
192
- this .costumes .get (this .currentCostume ).setTint (h );
194
+ for (ScratchImage costume : this .costumes ) {
195
+ costume .setTint (h );
196
+ }
193
197
}
194
198
195
199
/**
196
- * Changes the tint for the current costume .
200
+ * Changes the tint for the sprite .
197
201
*
198
202
* @see ScratchImage#changeTint(float)
199
203
*/
200
204
public void changeTint (float step ) {
201
205
if (costumes .size () == 0 ) return ;
202
206
203
- this .costumes .get (this .currentCostume ).changeTint (step );
207
+ for (ScratchImage costume : this .costumes ) {
208
+ costume .changeTint (step );
209
+ }
204
210
}
205
211
206
212
/**
207
- * Sets the transparency of the current costume .
213
+ * Sets the transparency of the sprite .
208
214
*
209
215
* @see ScratchImage#setTransparency(float)
210
216
*/
211
217
public void setTransparency (float transparency ) {
212
218
if (costumes .size () == 0 ) return ;
213
219
214
- this .costumes .get (this .currentCostume ).setTransparency (transparency );
220
+ for (ScratchImage costume : this .costumes ) {
221
+ costume .setTransparency (transparency );
222
+ }
215
223
}
216
224
217
225
/**
218
- * Changes the transparency for the current costume .
226
+ * Changes the transparency for the sprite .
219
227
*
220
228
* @see ScratchImage#changeTransparency(float)
221
229
*/
222
230
public void changeTransparency (float step ) {
223
231
if (costumes .size () == 0 ) return ;
224
232
225
- this .costumes .get (this .currentCostume ).changeTransparency (step );
233
+ for (ScratchImage costume : this .costumes ) {
234
+ costume .changeTransparency (step );
235
+ }
226
236
}
227
237
228
238
/**
@@ -427,6 +437,26 @@ public void changeY(float y) {
427
437
this .y += y ;
428
438
}
429
439
440
+ /**
441
+ * Return the width of the current costume or the pen size, when no costume is available.
442
+ * @return the width of the sprite
443
+ */
444
+ public int getWidth () {
445
+ if (costumes .size () == 0 ) return (int ) this .getPen ().getSize ();
446
+
447
+ return this .costumes .get (this .currentCostume ).getImage ().width ;
448
+ }
449
+
450
+ /**
451
+ * Return the height of the current costume or the pen size, when no costume is available.
452
+ * @return the height of the sprite
453
+ */
454
+ public int getHeight () {
455
+ if (costumes .size () == 0 ) return (int ) this .getPen ().getSize ();
456
+
457
+ return this .costumes .get (this .currentCostume ).getImage ().height ;
458
+ }
459
+
430
460
/**
431
461
* Return the default timer
432
462
* @return the default timer
0 commit comments