Shapeの位置を指定【Phina.js】

Shapeの位置を指定

x, yプロパティで直接数値を指定

var shape = Shape().addChildTo(this);
shape.x = 320;
shape.y = 480;

※背景はライトグレーに変更

setPosition関数を使用

var shape = Shape().addChildTo(this).shape.setPosition(320, 480);

Shapeのコンストラクタで指定

var shape = Shape({
x: 320,
y: 480
}).addChildTo(this)

moveBy関数を使って移動することも可能

shape.setPosition(320, 480).moveBy(100, 200);

Vector2クラスを使って移動量を加算

var v = Vector2(100, 200);
shape.position.add(v);

コメントを残す

あなたのメールアドレスは公開されません。必須項目には印がついています *