• Content Count

  • Joined

  • Last visited

About kgibson

  • Rank

Contact Methods

  • Twitter

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Ah, that works!! He now walks back and forth between two set points! For my own sanity, let me see if I'm understanding this right. I was originally trying to control the velocity with the if statement, which updated at a very fast rate because of the update loop. Meaning that, the very second he went back below x = 300, the if statement wouldn't return true and wouldn't fire again, which pushed him forward. The if statement is what pushes him backwards. I knew there had to something with the logic but I just couldn't wrap my head around it! Thank you so much! This is fantastic! NOTE: What is .factor? Is that a JavaScript thing? I'd guess it's sort of like giving a variable to an object without really doing anything to the object itself. Thank you again!
  2. Thanks for the reply! I tried this and functionally it's much better, however the sprite still seems to stop wherever I say the point is. Debugging the sprite shows that x is say, 300, but its shifting between 299 and 300 at a fast rate, its makes me think he's being still being pulled by something. Here's the change I made: function update() { steve.body.velocity.x = 50; if (steve.body.x >= 300) { steve.scale.x = -1; steve.body.velocity.x *= -1; } } Is my logic wrong? I can't get him to turn around even at a point, let alone, the world bounds (which I don't think I have the syntax right for anyway). And yeah, sorry, that was me messing around, I made the initial x +2 because I was getting him to move faster. You can disregard that.
  3. Alright, been stuck on this for a few days and starting to think I'm overlooking a very simple solution. I have a character that I want to walk back and forth on the screen. He needs to walk to one edge, turn around, then walk to the other edge, again turn, walk, etc.; rinse and repeat. I've tried simply '+=' and '-=' on his x coord with an if statement but he wont seem to walk in the other direction. Example, writing 'steve.x += 1;' then 'steve.x -= 1;' won't work. He gets to one edge but then stops. I've also tried using tweens but he seems to become jittery as he's a spritesheet already, maybe? His physics body will stay, but the pixels themselves seem to move outOfBounds. Anyway, here's the full code for what I'm working on, any help is greatly appreciated. Also still learning Phaser so any feedback on code flow is helpful too! Thanks!
  4. Ah, yeah I guess that would be way more helpful if I just showed the the whole thing lol
  5. I'm currently using version 2.4.4 Amador. I'm trying to debug a sprite but can't seem to get render or debug to work. I understand that phaser needs to be rendering using Phaser.CANVAS that I need to include the "render: render" function. My code looks like: render: function() { game.debug.spriteInfo(sprite, 32, 32); } but I've also tried: function render() { game.debug.spriteInfo(sprite, 32, 32); } Console log seems to suggest I'm creating the function the wrong way? Thanks in advance! Side note: my other main functions, preload, create, and update, all look like my first snippet and seem to work fine.