Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Scaling of entities in ImpactJS

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 450
    Comment on it

    How to use Scale plugin in ImpactJS ?

    In the lib folder create a new folder named Plugins and put the "scale.js" plugin in to this folder.

    Include the plugin to the requires in any entity.

    .requires('Plugins.scale')
    

    Now if we want to resize a button of size (x: 560 and y: 500). Then we have to create a function showButtons and generate the spawnEntity of button. Create a variable and set it's zero index to the desired scale as shown :

    Example :

    showButtons: function()
        {
            ig.game.spawnEntity(Button,5,80,
            {
                size: {x: 560, y: 500},
                animSheet: new ig.AnimationSheet('media/Play_Button.png',560,500),
                pressedUp: function()
                {
                    console.log("Button is resized...");
                }
            });
    
            var _resize= ig.game.getEntitiesByType(Button);
            _resize[0].setScale(0.5,0.5);
        }
    

    OUTPUT : A button of size (x: 280, y: 250) will display on the screen.

    Hope it will work.
    Thankyou !

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: