moveTo()
Move the object to the specified position.
Description
Move the object to the specified position.
Arguments
- x : Number
- The x position that the object will be moved to.
- y : Number
- The y position that the object will be moved to.
Return Value
displayObject. Returns the display object itself.
Examples
Example 1
We create a new core instance and a rectangle that we add to the canvas. Then we add an event handler that moves the rectangle when clicked.
View Example
Code
var canvas = oCanvas.create({
canvas: "#canvas",
background: "#ccc"
});
var rectangle = canvas.display.rectangle({
x: 177,
y: 170,
origin: { x: "center", y: "center" },
width: 200,
height: 100,
fill: "#000"
});
canvas.addChild(rectangle);
rectangle.bind("click tap", function () {
this.moveTo(100, 100);
canvas.redraw();
});
Output