Вопрос

We can create a rectangle at (0,0) and height and width of 40 with mySprite.graphics.drawRect(0,0,40,40);. However, suppose it is necessary to create a rectangle that fills exactly half the screen (this is for mobile devices, so screen size will vary). How can we accomplish this?

Это было полезно?

Решение

You first need to get the size of the screen, you can use this :

var w = stage.stageWidth;
var h = stage.stageHeight;

Then you can simply draw your rect using theses variables

mySprite.graphics.drawRect(0, 0, w / 2, h / 2);
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top