Jump to content

moveTo - move to origin vs position ?


Recommended Posts


when i move my "rect" after creating, he stay at is current position.

in fact he moves according his local position defined in CUBE.geom(200,400,80,30,blue)

how do you do to move it without be affected with this origin position ?


var container = new PIXI.Container();

var renderer = PIXI.autoDetectRenderer(320, 480,{backgroundColor : 0x1099bb});


requestAnimationFrame( animate );

var blue= 0x00c3ff
var red = 0xFF0040

var CUBE={}

CUBE.geom = function(posx,posy,w,h,color) {

CUBE.geom.prototype = Object.create(PIXI.Graphics.prototype);
CUBE.geom.prototype.constructor = CUBE.geom;

var square=new CUBE.geom(10,10,10,10,red)

var rect=new CUBE.geom(200,400,80,30,blue)



	function animate() {

		requestAnimationFrame( animate );


Link to comment
Share on other sites

That'+s not how graphics object works. Graphics object defines a set of points and primitives inside it, you can clear it and fill it with new primitives. At the same time, any PIXI object can have its own position that will affect its coords and coords of all his children. moveTo() is method for drawing, I dont know why do you want to use it for moving the object.

It will be better if you just draw graphics relative to their local coordinates, and then change their position:

var square=new CUBE.geom(0,0,10,10,red)
var rect=new CUBE.geom(0,0,80,30,blue)

rect.position.set(200, 400);
square.position.set(10, 10);




Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...