Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var game = new Phaser.Game(640, 360, Phaser.CANVAS, "content", { preload: preload, create: create, update: update, render: render});
- var steve;
- function preload() {
- this.load.image('background', 'assets/clouds.jpg');
- this.load.atlasJSONHash('guy', 'assets/steve.png', 'assets/steve.json');
- }
- function create() {
- this.physics.startSystem(Phaser.Physics.ARCADE);
- this.background = this.game.add.tileSprite(0, 0, this.game.world.width, this.game.world.height, 'background');
- // this.background.autoScroll(-10, 0);
- // Steve Sprite
- steve = this.add.sprite(0, 225, 'guy');
- walk = steve.animations.add('walk');
- steve.animations.play('walk', 8, true);
- steve.anchor.setTo(0.5);
- // Add physics to Steve
- this.physics.enable(steve, Phaser.Physics.ARCADE);
- steve.body.collideWorldBounds = true;
- // Tween on Steve
- tween = game.add.tween(steve);
- tween.from({ x: 300 }, 5000, 'Linear', true, 0);
- }
- function update() {
- // steve.x += 2;
- // if (steve.body.right >= this.world.bounds.right) {
- // steve.x = 0;
- // steve.scale.x = -1;
- // steve.x -= 1;
- // }
- }
- function render() {
- game.debug.body(steve);
- game.debug.spriteInfo(steve, 16, 16);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement