1
저는이 코드로 이동하는 원을 직선으로 그리려합니다. 하지만 구문을 넣으려면 잘못되었습니다. 이 코드를 수정하도록 도와주세요.캔버스의 왼쪽에서 오른쪽으로 원을 움직입니다.
<script>
var canvas = document.getElementById("myCanvas");
var context = canvas.getContext("2d");
function draw_circle (circleX, circleY, radius, fill) {
context.fillStyle = "black";
context.fillRect(0, 0, 800, 300);
context.strokeStyle = "red";
context.strokeRect(5, 5, 790, 290);
var speed = 5
context.fillStyle = fill;
context.arc(circleX, circleY, radius, 0, Math.PI*2);
context.fill();
}
setInterval(draw_circle(100,100, 30 , "cyan"), 33);
</script>
그리고 왼쪽에서 오른쪽으로 bouce하는이 http://jsfiddle.net/c4vxb9tx/ 같은 것을 할 (당신이 원하는 경우 답변에 따라가, 당신은 속도 vectorx 대체 할 수있다) – dwana
알았어요! 대답 해 주셔서 감사합니다. :). – Drew
그리고 dwana, 질문이 있습니다. 코드에서 매개 변수를 사용할 수 있습니까? 내 코드에 매개 변수를 추가하는 방법에 대해 자세히 알고 싶습니다. – Drew