Jump to content


  • Content Count

  • Joined

  • Last visited

About DanielKlava

  • Rank

Recent Profile Visitors

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

  1. Hello @Salomão Neto! If you are using P2 physics (or any other system other than P2), you have to explicitly activate it before using. The default Physics system is ARCADE, so that's why you didn't have to start it when you were using it. Please, try updating the line: game.physics.enable(this.player, Phaser.Physics.P2JS) // Error To: this.game.physics.startSystem(Phaser.Physics.P2JS); //You do it only once, and then use it at will. Not necessary with ARCADE physics. this.game.physics.p2.enable(this.player); Also, regarding the "moveToPointer()" function, it's not av
  2. Hi, @v33dub! You can use a Timer object to control the duration of the attack movement, and to control which animation to play: 1. Player presses the attack button which calls the "attack" function; 2. Set the animation to "attacking", and trigger the Phaser.Timer object to last 1 second or so (depends on how fast is the attack movement); 3. You set the "idle" animation again in the function that is called when the timer ends. The code would be something like this: attack(){ //We use a boolean var to check if the player is currently attacking to prevent a new a
  3. Hello @Jirash! Could post the link to which Hello World Example you are following? In Phaser 3.1 you should use a "config" JSON structure for initializing the Phaser.Game object, like so: var config = { type: Phaser.AUTO,//renderer type width: 215, height: 270, scene: { // here you set up which functions you are using for each step in the game loop init: init, preload: preload, create: create } }; //you finally instantiate the "game" object using the "config" one var game = new Phaser.Game(config); I've attached a example below with "Init", "Create" and
  4. Hello! You need to set the "fireAngle" of the weapon object. For example: this.weapon.fireAngle = Phaser.ANGLE_RIGHT;
  5. Hello there! I think that you should use "this.collisionHandler" instead of "self.collisionHandler". Generally, the object "self" will point to window.self, and "this" will point to the context the function is in. Since you want to use the function "collisionHandler" in the context of the Game (or State) object, you should reference the function with "this". Hope it works
  6. Not exactly with Tern, but @speedo did a tutorial for Vim:
  7. Hello espace! I think the issue is in the following line: this.button=game.add.button(this.posx,this.posy,this.image,this.anim_on_click,this,1); The sixth parameter defines which frame the button will be when you move the cursor over it. Since you are passing "1", Phaser will set the button's frame to 1 in a mouse over event. As of now, the result logic is: Player moves the cursor over the button; Button's frame is "1", as specified; Player clicks the button; Function "anim_on_click" is called, and since the frame was set to "1", it will always enter in
  8. Hello! I think there are no right answers for these topics, but let me add my two cents: You could do that, of course, but you could also add a loop event that will run your custom logic that may call fireAtSprite(). The advantage would be that you may also call other functions, like animations and sound effects. Sure, you could also call that in your overridden function, but I think it would mix different concepts in your "fire()" function. I would go with option 2)! Although it will have the same effects as 3), you would have more control over the behavior of the collisi
  9. Great, glad it worked! I know the issue is done, but just one comment, if that's ok! I guess that you don't have to set up the "...onDown.add(..)" inside the event, since you already did it in "create" function. Since it's the function "add" instead of "addOnce" (as @rich mentioned), you wouldn't have to worry to set it up again after the first time (which would be the case if you are using addOnce). Just pointing it out because it could lead to some unpredictable behavior further down the road
  10. Hello! Just one question: on "create" you are setting the event for space bar only, but inside "tapStop", when the event is finished, you are setting the "tapStop" to any kind of input? Also I ran with some issues as well regarding timer after some action, and what worked for me was to define a separate Timer, and then clear all events with the timer.stop(), like so: create (){ //... this.doingAction = false; this.customTimer = this.game.time.create(false); this.jumpButton = this.game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR); this.jumpButton.onDown.add(
  11. Hello! Can you check the contents of "_this.car" using "console.log(_this.car)", and see if it's a valid object? And, could you also post the code part where you initialize the "_this" variable? There may be some issue where it doesn't correctly point to the "this" object, so your code may not find the "car" object with the animations set up.
  12. Hello! Can you confirm if the problem is so that your code never reaches inside the IFs with "jump" and "left/right" pressed? It could be a case of anti-ghosting with your keyboard. Does the behavior still occurs in another machine? I've attached a link of a similar scenario that you mentioned (there doesn't seem to be anything wrong with the code). And, regardless, would it be acceptable for the player to change the jump direction midair? If so, you could change your logic to check those buttons separately, and work around the issue. Oh, one more thing: if you are creating the
  13. Hello! You can try setting the scale as below: sprite.scale.x = 1.5; // Increases the X scale by 1.5x times. sprite.scale.y = 2; // Increases the X scale by 2x times. A similar use of this example is to "invert/mirror" the sprite, you just have to set the scale to -1.
  14. Hello! Perhaps you could insert a blank sprite where you want the sprite to stop, and check the collision between only the sprites you want. Then, in the collision callback you set the velocity to 0. Something like this. Assuming that your sprite is moving horizontally from left to right, and that he must stop regardless of it's Y position: create : function (){ //adds sprite at the position needed this.checkpoint = this.add.sprite(100, 2); //scale the height of the sprite to full height, so the user cannot miss it. this.checkpoint.scale.y = this.game.height; }, update : fun
  15. Hi @davestephans, Just a quick question, what is the exact resolutions you are testing on? It's working on resolutions lower than the max one you specified, right? Because, going over this "if": if((GAME_MAX_WIDTH/windowWidth) > (GAME_MAX_HEIGHT/windowHeight)) { scaleFactor = (windowWidth / GAME_MAX_WIDTH); } else { scaleFactor = (windowHeight / GAME_MAX_HEIGHT); } If you are testing on resolution 1920x1080, then the "scaleFactor" will always be set to 1, and therefore you would be calling: mainGame.scale.setUserScale(1, 1); Which wouldn't actua
  • Create New...