I am trying to get some knowledge in html and canvases, and i am stuck with a little problem. My canvas has a circle on top and 2 buttons below it. One button can be clicked whereas the other is an input button. What I have to do is that i should be able to type in the second button and when the first button is clicked, the first button's value should be changed to the value typed in second button. That click should also move the circle in x axis. I did the movement part, can anyone help me out with the input buttons inside the canvas?
Here's the part of my code, here i tried to put buttons outside the canvas, but i need them in the canvas, not as the html buttons though:
<script>
var stage;
function init() {
stage = new createjs.Stage("myCanvas");
var cbgColor = new createjs.Shape();
cbgColor.graphics.beginFill("#000000").drawRect(0,0, stage.canvas.height,stage.canvas.width);
stage.addChild(cbgColor);
var ball = new createjs.Shape();
ball.graphics.beginFill("#ff0000").drawCircle(0,0,50);
ball.x=100;
ball.y=200;
stage.addChild(ball);
createjs.Ticker.addEventListener("tick",tick);
createjs.Tween.get(ball,{loop:false}).to({x:650}, 3000).to({x:100},1);
}
function tick(event){
stage.update();
}
function handleClick(event){
console.log("clicked");
}
</script>
</head>
<body bgcolor="black" onload="init()">
<canvas id="myCanvas" height=300 width=600>
</canvas><br>
<script>
function change()
{
var inp = document.getElementById('ip').value;
document.getElementById('add').value = inp;
console.log("clicked");
document.getElementById('ip').value=null;
}
</script>
<input id="add" value="Go!" type="button" onclick="change();init();" style="background-color:yellow;font-size:30px;width:110px;height:40px;margin-left:250px"><br>
<br><input type="text" id="ip" style="background-color:black;color:white;font-size:30px;width:140px;height:40px;margin-left:230px">