0

I'm trying to build a circle with dynamic scripting in Javascript. Normally, I've been able to do it pretty easily in C# using Math.cos and Math.sin. I'm using EaselJS/CreateJS as my base library, and came up with this:

function BuildTileCircle()
{
    var countNumberSlots = BlockArray.length;
    var radius = 10;
    for (var i = 0; i < countNumberSlots; i++)
    {
        var angle = i * Math.PI * 2 / countNumberSlots;
        console.log(angle);

        var tempTile = new createjs.Sprite(Tiles, 0);
        WorldContainer.addChild(tempTile);

        tempTile.x = Math.cos(angle) * 100;
        tempTile.y = Math.sin(angle) * radius * 100;
    }   
}

It.. SORT of works. The circle it builds however, is highly skewed and not perfectly round. Am I on the right track?

2
  • naming convention hurt my eyes, took a long time to realize that this isn't C#! Commented Oct 12, 2014 at 10:21
  • I'm used to working in both Javascript and C#, and tend to drift to the conventions I've used most. However, it is Javascript. Commented Oct 12, 2014 at 10:30

1 Answer 1

1

Your x coordinate doesn't depend on the radius. Fix it.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.