Jump to content

When sprite.width != sprite.height,can i draw circle in sprite


fengFanYong
 Share

Recommended Posts

i create a sprite,and set it width != height;i create graphics as the sprite children,but if i user graphics.drawCircle draw circle,it will draw Ellipse;

code :

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>text drawCircle</title>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/pixi.js/4.2.2/pixi.min.js"></script>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
    </style>
</head>
<body>

<script>
    var stage = new PIXI.Container;
    var renderer = PIXI.autoDetectRenderer(window.innerWidth, window.innerHeight, {antialias: true});
    document.body.appendChild(renderer.view);
    requestAnimationFrame(update);

    var sp = new PIXI.Sprite();
    sp.position.x = 100;
    sp.position.y = 100;
    sp.width = 200;
    sp.height = 400;

    g = new PIXI.Graphics();
    g.beginFill(0x123123);
    g.drawCircle(.5,.5,.5);
    g.endFill();
    sp.addChild(g);
    stage.addChild(sp);

    function update(){
        renderer.render(stage);
        requestAnimationFrame(update);
    }
</script>
</body>
</html>

can i draw circle use graphics.drawCircle?

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.

Guest
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.

Loading...
 Share

  • Recently Browsing   0 members

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