jevisan

Members
  • Content count

    17
  • Joined

  • Last visited

  1. Sprite flickering

    hi, thanks for your response. Well since the platforms are in a tilemap layer im not sure how to work with the body of the layer, been running test but with weird results. There's no manual set for the player.y value.
  2. Sprite flickering

    thanks for your response, i've already tried setting Phaser.CANVAS without success. And setting sprite.body.maxVelocity.x does not reduce the flickering, i also tried setting the maxVelocity.y parameter but the flicker remains the same. What i find funny is how tweaking the y velocity and gravity parameters affect the flickering. If you have any other suggestion, it would be really appreciated. edit: would it be because of the x and y positioning of the sprite?
  3. Sprite flickering

    Im having an issue with my game. The player sprite flickers when positioning at certain points in the game. My tile maps are made in tiled editor so no risk of misplacing a tile. The flickering is only vertical and the physical body of the sprite is set a little smaller than the actual sprite which is 32 x 32 while the physical body is 16 x 28. I've also noticed that the flickering varies with the setting of the velocity. As an example, when jumping above a certain platform the sprite flickers when the assigned negative velocity of y and y gravity are assigned certain value, but it doesn't flicker when assigned another value. On the other hand, on another part of the game the whole screen/camera flickers at certain height. Any thoughts?
  4. Sound effects mashed up

    alright, this info is really well documented, thanks for your response. I'll test this out and then post my results.
  5. Sound effects mashed up

    Hi , i'm having a difficulty while trying to play sounds on player input. The character is supposed to move and play a footstep sound while doing so. But the sound is really short and end up restarting the sound every call to update which causes it to sound mashed up. Is there any way i could fix this? The code isn't really that much relevant but still: update: function() { if (this.cursors.left.isDown) { this.player.body.velocity.x = -this.player.speed; this.player.animations.play('walk-left'); this.footstepA.play(); } } Oh and i would also like to reproduce another footstep sound after playing that one. Like so: footstepA, footstepB, footstepA, etc.
  6. Oh yeah, sorry i didn't reply earlier. Yes i indeed found a similar post where changing the collision/input check solved the issue. It would be interesting to study the issue a bit deeper. Although doing that and checking for blocking in bottom gives me the desired result, i can't just make the touching.down() method to work and the debug display still doesnt recognizes the sprite touching the floor of a tile. Just so it remains documented, the fix was changing the collision and input check like so: update: function () { this.processCollisions(); this.processPlayerInput(); }, everything else remained the same. Thanks for your help.
  7. player.body.touching.down not working

    oh hell, this solved my problem as well, i was having a similar problem while using tilemaps. I also couldn't have imagined that the checking input - collision order would be relevant. thank you for posting it It still doesnt solve the issue about touching the ground tho, my debug still displays that the sprite is blocked from the bottom but isnt touching the ground, even when its on a collisionable layer.
  8. hi, i just did verify the collision layer, and everything is as it should be. The debug info says the character is being blocked from the bottom but not the top. as additional info, if i dont call the procedures to set up the map, the player can jump just fine. and as the player spawns above the floor, while hes falling he can jump as well. the moment he touches the ground is when hes locked to the ground. srsly this is really odd. also, the multiplying of the collision layer after the map is over could it be because of the resizeworld() call?
  9. Hi, i'm having a problem with the collisions in my game. I'm using tilemap layers the character can jump as long as it's not touching the ground, but the moment it touches the tiles that are set for check for collision, it just seems unable to move upwards. Can move sideways tho. Everything else is loaded and displayed just fine. BasicGame.Game = function (game) {}; BasicGame.Game.prototype = { create: function () { this.game.physics.startSystem(Phaser.Physics.ARCADE); this.setUpInput(); this.setUpMap(); this.setUpPlayer(); }, update: function () { this.processPlayerInput(); this.processCollisions(); }, /*==========================CREATE ASSOCIATED FUNCTIONS==========================*/ setUpInput: function() { // arrow keys this.cursors = this.input.keyboard.createCursorKeys(); }, setUpPlayer: function() { this.player = this.add.sprite(BasicGame.PLAYER_SPAWN_X, BasicGame.PLAYER_SPAWN_Y, 'player'); this.player.anchor.setTo(0.5, 0.5); this.game.physics.arcade.enable(this.player); this.camera.follow(this.player); this.player.speed = BasicGame.PLAYER_SPEED; this.player.jump_speed = BasicGame.PLAYER_JUMP_SPEED; this.player.body.collideWorldBounds = true; this.player.body.gravity.y = 1000; }, setUpMap: function() { this.map = this.game.add.tilemap('testLevel'); this.map.addTilesetImage('lvl_1_tiles', 'level1_tiles'); // collisionable layer this.collisionLayer = this.map.createLayer('collisionable'); this.map.setCollisionBetween(1, 2000, true, this.collisionLayer); this.collisionLayer.resizeWorld(); }, /*==========================UPDATE ASSOCIATED FUNCTIONS==========================*/ processCollisions: function() { this.game.physics.arcade.collide(this.player, this.collisionLayer); }, processPlayerInput: function() { // reset movement this.player.body.velocity.x = 0; ... // jumping <== it should jump but it doesnt!!! if (this.cursors.up.isDown) { this.player.body.velocity.y = -this.player.jump_speed; this.player.frame = 2; } } }; { "height":10, "infinite":false, "layers":[ { "data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17, 18, 0, 0, 9, 0, 14, 0, 0, 0, 0, 0, 0, 0, 16, 17, 17, 18, 0, 0, 0, 0, 0, 0, 14, 0, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 0, 14, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2], "height":10, "name":"collisionable", "opacity":1, "type":"tilelayer", "visible":true, "width":20, "x":0, "y":0 }], "nextobjectid":1, "orientation":"orthogonal", "renderorder":"right-down", "templategroups":[], "tiledversion":"2017.10.31", "tileheight":32, "tilesets":[ { "columns":5, "firstgid":1, "image":"..\/tilesets\/lvl_1_tiles.png", "imageheight":256, "imagewidth":160, "margin":0, "name":"lvl_1_tiles", "spacing":0, "tilecount":40, "tileheight":32, "tilewidth":32 }], "tilewidth":32, "type":"map", "version":1, "width":20 }
  10. Sprite goes invisible if fixedToCamera enabled

    thanks for your responses, i already figured i have to tweak the cameraOffset values to make the sprite appear where i want it
  11. Sprite goes invisible if fixedToCamera enabled

    thanks, that at least put the sprite in the top right corner of my screen, but its really just confusing as why is behaving like that and why is necessary to set the camera offset. the fixedtocamera value must be enough, right?
  12. I'm trying to develop a HUD for my game but im having an unexpected behavior when setting one of my sprites like this: this.mysprite.fixedToCamera = true; the sprite desapears completely, but commenting the line makes the sprite visible just fine. I havent come up with the reason just yet. any ideas?
  13. Starting a state on input callback

    I figured it out I dont know why but it seems the adding events function requires the "this" parameter in order to work: this.txt = this.game.add.text( 30, 80, 'text', { font: '20px monospace', fill: '#fff', align: 'left' } ); this.txt.inputEnabled = true; this.txt.events.onInputUp.add( this.initiateState, this ); // <- heres the magic
  14. Starting a state on input callback

    Greetings, i'm having issues trying to initiate a state by clicking over an option text. I create my options inside a "LevelSelection" state with a function: addMenuOption: function(text, callback) { var text = this.game.add.text( ... ); var onOver = function(target) { ... }; var onOut = function(target) { ... } text.inputEnabled = true; text.events.onInputUp.add(callback); text.events.onInputOver.add(onOver); text.events.onInputOut.add(onOut); } So i can construct levels with difficulty inside create() by just: this.addMenuOption( "easy", function(target) { this.state.states['LevelLoad']._diff = "easy"; this.state.start('LevelLoad'); }); this.addMenuOption( "hard", function(target) { this.state.states['LevelLoad']._diff = "hard"; this.state.start('LevelLoad'); }); obviously the "levelLoad.js" and this "levelSelection.js" are included as states in my main.js and imported within my index.html but when i click over the "easy" text i create im getting the error: "Cannot read property 'start' of undefined". The same goes when i try with: this.game.state.start(...) And after some experimentation i may think it is because of how the callback is assigned or maybe it is the scope? I really dont know what to do Any insights are appreciated
  15. Determine if sprite is children of group

    oh, thank you so much, this will make my life so much easier. I'll try it right away