cornstipated

Members
  • Content Count

    19
  • Joined

  • Last visited

About cornstipated

  • Rank
    Member

Recent Profile Visitors

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

  1. cornstipated

    Why are my sprites rendered badly on mobile browser?

    it has probably to do with devicePixelRatio . You can configure phaser to use a higher dpi by setting a value for 'resolution' in the game config or by using setResolution on specific gameobjects(like text) config = { resolution : window.devicePixelRatio } but it will warned that it can be very costly battery and performance wise.
  2. cornstipated

    Can't create image 2 conditionals in

    all the callbacks in phaser have an argument after the function that will be used as the scope ie gameobject.on(eventtype,callback,callbackscope) which could be gameobject.on('pointerdown',function(){},this) About your original question: it really doesnt ask what you want to achieve or how the code output differs from what you would expect and on top of that it is not self contained so it cant be executed to reproduce and see the problem (relies on things that are not visible in the snippet). That being said one potential problem I see is adding eventlisteners inside eventlistener callback and i doubt this is intentional. For example every time you drop something you will add an on pointerdown listener to clickbutton so the first time you drop it will have one but the second one it will have two and call the callback twice and so on. Also it is totally unnecessary to setinteractive there, you could just do it when you create the button.
  3. cornstipated

    How to modify gravity from user input?

    this.physics.world.gravity in the context of a scene.
  4. cornstipated

    Recommended approach in setting collision properties

    If you dont want to use indices there is another way setCollisionByProperty You'll have to add the property to the tile in Tiled
  5. cornstipated

    Update tween END value

    good god just create the tween when you know what value to tween to
  6. You can control roundpixels/antialiasing on a per texture basis by using sprite.texture.setFilter(filtermode) Phaser.Textures.FilterMode.LINEAR or Phaser.Textures.FilterMode.Nearest
  7. cornstipated

    Object Specific Event Handlers

    this.input.on('drop', function (pointer, gameObject, dropZone) { if(gameObject.myondrop) gameObject.myondrop(pointer,dropZone,whatever) });
  8. cornstipated

    How do I call a callback function when two objects stop overlapping?

    it is one way but it is so desperately dependant on phaser. Why not a simple check for distance in the npc update loop
  9. cornstipated

    How to replace arrow keys with wasd movement?

    this.cursors = this.input.keyboard.addKeys( {up:Phaser.Input.Keyboard.KeyCodes.W, down:Phaser.Input.Keyboard.KeyCodes.S, left:Phaser.Input.Keyboard.KeyCodes.A, right:Phaser.Input.Keyboard.KeyCodes.D});
  10. cornstipated

    Destroying a Blitter

    blitter.children.each(function(bob,context){bob.destroy()},this) is a way
  11. the code would definitely help but it might be something as simple as trying to use something you have not loaded yet. IE scene.js references player.js but player.js is loaded after scene.js (the order of the script elements matter)
  12. cornstipated

    Help understanding createContainer

    parent isnt created automatically. If there an element with id parent then createContainer flag will append a properly styled div to it and create the canvas in there. If parent has a bogus value then it will just default to the body element
  13. cornstipated

    Extending GameObjects?

    class MySprite extends Phaser.GameObjects.Sprite { constructor (scene, x, y,myExtra) { super(scene, x, y); this.myExtra = myExtra; this.setTexture('cachedtexturekey'); this.setPosition(x, y); } preload() { } create() { } preUpdate (time, delta) { // do stuff with this.myExtra } } Yes you can example above. Those 3 functions overload function of the baseclass GameObject that are called at various points of the object lifecycle. You could Also overload Sprite specific methods like preUpdate if you needed to. All and all it is just javascript and you can do what you want with it. The extended class istance can be pooled too
  14. cornstipated

    Rotating / changing angular velocity

    physicsenabledgameobject.body.angularVelocity = 100; positive for clockwise, body also has angularDrag for damping, both are in degrees per second
  15. cornstipated

    Killing a Tween

    var tobeinterrupted = this.tweens.add({targets: this.titleGraphic, scaleX: 1, scaleY: 1, duration: 1000, ease: Phaser.Math.Easing.Back.Out}); tobeinterrupted.stop(); This is the controlled way to do it with single tween granularity. Anyhow both your ways should work too you should try better or more specific test cases