gregkarber 1 Posted May 1, 2015 Report Share Posted May 1, 2015 I cannot for the life of me figure out why this isn't working. I keep going over it, and I know I'm missing something obvious. You can play it here to see what I'm talking about. Please help!var TILE = 64;var game = new Phaser.Game(8*TILE, 8*TILE, Phaser.AUTO, 'game_div');var game_what = {};game_what.main = function() { };game_what.main.prototype = { preload: function() { this.game.load.spritesheet('pengy', 'pengy.png', 16, 16); this.game.load.tilemap('map', 'world.csv', null, Phaser.Tilemap.CSV); this.game.load.image('tiles', 'terrain.png'); this.game.world.setBounds(0*TILE, 0*TILE, 8*TILE, 30*TILE); this.game.stage.backgroundColor = "#FFFFFF"; this.cursor = this.game.input.keyboard.createCursorKeys(); }, create: function() { game.physics.startSystem(Phaser.Physics.ARCADE); this.load_map(); this.pengy = this.game.add.sprite(15*TILE, 20*TILE, 'pengy', 0); this.pengydance = this.pengy.animations.add('dance', [0, 1, 0, 2], 9, true); this.pengy.scale.x = 4; this.pengy.scale.y = 4; this.pengy.smoothed = false; this.pengy.anchor.x = .5; this.pengy.anchor.y = 1; game.physics.enable(this.pengy, Phaser.Physics.ARCADE); this.pengy.body.drag.x = 450; this.pengy.body.gravity.y = 700; this.pengy.body.setSize(8, 11); game.camera.follow(this.pengy); this.text = { font: "53px Helvetica", fill: "#000000" }; //this.istext = game.add.text(4*TILE, 1*TILE, "you win", this.isstyle); }, load_map: function() { this.map = this.game.add.tilemap('map', 16, 16); this.map.addTilesetImage('tiles'); this.map.setCollisionBetween(0, 14); //this.map.setCollisionBetween(0, 3, true); //this.map.setCollisionBetween(8,14), true; this.alayer = this.map.createLayer(0); this.alayer.scale.x = 4; this.alayer.scale.y = 4; this.alayer.smoothed = false; this.alayer.resizeWorld(); this.alayer.debug = true; }, pengyfunc: function() { if (this.pengydance.isPlaying == false) this.pengydance.play(); }, tryjump: function() { if (this.cursor.up.isDown && this.pengy.body.touching.down) {this.pengy.body.velocity.y = -450;} }, lose: function() { this.pengy.kill(); }, done: function() { console.log("done") }, update: function() { this.game.physics.arcade.collide(this.alayer, this.pengy, this.done); if (this.cursor.right.isDown && (this.pengy.body.touching.right == false)) {console.log("right"); this.pengyfunc(); this.pengy.body.velocity.x = 180;} else if (this.cursor.left.isDown && (this.pengy.body.touching.left == false)) {this.pengyfunc(); this.pengy.body.velocity.x = -180;} else this.pengydance.stop(); if (this.cursor.up.isDown) this.tryjump(); }, render: function() { this.game.debug.body(this.pengy); }};game.state.add('main', game_what.main);game.state.start('main'); Quote Link to post Share on other sites
gregkarber 1 Posted May 1, 2015 Author Report Share Posted May 1, 2015 My problem was the use of "scale" on the tilemap layer. I should have used setScale. Quote Link to post Share on other sites
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.