Vishnu V Das Posted October 26, 2020 Share Posted October 26, 2020 The bouncer scene has been uploaded, the explained code is : var config = { type: Phaser.AUTO, width: 800, height: 600, //THE WIDTH AND HEIGHT OF SCENE IS DECLARED scene:{ preload: preload, create: create, update: update }, scale: { autoCenter: Phaser.Scale.CENTER_BOTH //we place it in the middle of the page. }, gravity: { x: 10, //here the gravity of x and y coordinated are declared y: 10, debug: false, }, physics: { default: "arcade", }, }; var game = new Phaser.Game(config); function preload () { this.load.image("background", "assets/background.png"); // preloading the assets required for the scene this.load.image("ball", "assets/newball.png"); }; function create(){ this.add.image(300, 200, "background"); //creating the scene with the pre loaded objects ball1 = this.physics.add.image(100, 0, "ball"); ball1.setScale(0.9); // to change size of the image 1 is original ball1.body.velocity.setTo(200, 200); // velocity direction initial ball1.body.collideWorldBounds = true; //setting up the bounds ball1.body.bounce.set(1); //adding the bounce value }; function update(){ }; SCREENSHOT OF SCENE IS ATTACHED Basket ball.rar Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.