• Content count

  • Joined

  • Last visited

About ptotheaul

  • Rank

Recent Profile Visitors

825 profile views
  1. I've found this code that does what Phaser.ScaleManager.SHOW_ALL if I put it in the call back of USER_SCALE but know I need help figuring out how to limit the user scaling to the horizontal: gameResized(manager, bounds) { var scale = Math.min(window.innerWidth /, window.innerHeight /; //canvas.width = (game.width * hScale) - hTrim //canvas.height = (game.height * vScale) - vTrim manager.setUserScale(scale, scale, 0, 0); }
  2. I have a game that on mobile devices I want to scale the game to 100% of the window width and keeping the aspect ratio have the height scale up and go off screen at the bottom if the aspect ratio make the height taller then the view area. Is this possible just using the Scale Manager?
  3. ptotheaul

    Rotate game / force into landscape

    I have a game that is loaded into and app that doesn't have device rotation. The aspect ration of the game is for landscape but the app is portrait so I need to rotate the whole game 90 degrees(ie so when you view it in a regular browser it's rotated. Can this be done with the forceOrientation? I can't figure it out.
  4. ptotheaul

    Call functon in Game state from the DOM

    In case anyone else is looking for the answer to this I figured it out. From the DOM you can just call: game.state.states[game.state.current].funcFromDom();
  5. I need to call to call a function in my game state from the Dom to toggle the audio of my game. Is this possible? In index.html the game is set up like this: //////// index.html ///////////////////////////////////////////////////////////////////////// var game; (function() { game = new Phaser.Game(640, 1195, Phaser.CANVAS, 'the-game'); game.state.add("Boot",boot); game.state.add("Preload",preload); game.state.add("TheGame",theGame); game.state.start("Boot"); })(); /////////////////////////////////////////////////////////////////////////////////////////////// After preload"TheGame"); is called to load the game. The function I need to call from a button in the DOM is funcFromDom /////////////////////////////////////////////////////////////////////////////////////////////// var theGame = function(game){ }; theGame.prototype = { create: function(){ console.log("create()") }, funcFromDom: function(){ console.log("called from the dom"); }, }
  6. I have a polygon and a sprite inside of an extended group that I'm trying to check .contains on. Even though the polygon and the sprite are visually overlapping the contains is returning false. Would the .contains be relative to the stage even though //hitx , hity are points in the main game world passed into this which is an extended group that is placed at a position on the stage Building.prototype.checkbuildingoverlap = function(hitx, hity) { //this is just set up so i can see the spot i'm checking in the .contains this.tempspot.x = hitx - this.x; this.tempspot.y = hity - this.y; //this.buildinggraphics is a polygon shape if (this.buildinggraphics.contains(hitx - this.x, hity - this.y)) { console.log("CONTAINS IS HAPPENING"); } }
  7. I'm using bitmapData to capture a frame from a sprite with an atlas animation. Every thing work fine except the location of the draw is offset for the location of the original. I am scaling the original sprite but the image that is dawn is perfect except for a seemly random 155 x and 65 y offset. I can't figure out where the offset value is coming from. Can anyone see a reason this is happening? var bmd = + this.Badguy.width, this.Badguy.y + this.Badguy.height); //seems like this should should put bmd directly on top of sprite bmd.draw(this.Badguy, this.Badguy.x, this.Badguy.y); //but have to off set by 155 and 65 for it to match up. //bmd.draw(this.kaiju, this.kaiju.x + 155, this.kaiju.y + 65); bmd.update(); bmd.addToWorld(); ///////// This is how the Badguy sprite/animation is set up this.Badguy=, 180, 'badguywalk', '01.png'); this.Badguy.scale.set(2,2); this.Badguy.animations.add('walk', Phaser.Animation.generateFrameNames('', 1, 48, '.png', 2), 15, true, false);'walk');
  8. ptotheaul

    over write input pointer x/y postion

    I've decided to just try and modify the pixel collision function from the Phaser source to try and occomplish what I described in the first post. Here is the general function that I"m modifying. I've changed the general sprite to the sprite I'm checking against 'Badguy'. Can someone explain what '' would be if I'm not using input and just want to check the point(x,y) passed in against the sprite 'Badguy'? checkBadGuyHitPixel: function (x, y) { // Grab a pixel from our image into the hitCanvas and then test it if (this.Badguy.texture.baseTexture.source) { var pixelPerfectAlpha = 255;, 0, 1, 1); x += this.kaiju.texture.frame.x; y += this.kaiju.texture.frame.y;, x, y, 1, 1, 0, 0, 1, 1); var rgb =, 0, 1, 1); if ([3] >= pixelPerfectAlpha) { return true; } } return false; },
  9. ptotheaul

    over write input pointer x/y postion

    Is there a way to pass in an input pointer x/y values instead of having it use the mouse/tap location? What I want to do with this is at a certain time check a point against a sprite using: this.sprite.input.pointerOver() but I want to be able to define the input point that's being checked. In the end what I'm trying to do is record a tap event and then later in time(about 2 seconds) check if the tap event is over the sprite. After the initial tap the input position might move or be lifted but I still want to check against the initial tap position.
  10. I'm trying to get a pixel perfect detection of an animated sprite sheet and a single point. So in this example at any give check i could see if 'checkpoint' is over 'badguy' but the actual badguy pixels and not the rect: if (this.badguy.contains(checkpoint.x, checkpoint.y)) { //do stuff } It's like an input pixel perfect detection but with a time delay. I don't need to be constantly checking for the collisoin/contains, only at a single moment in time. Most of what comes up when looking for this is P2 physics editor collisions but that's not what I'm trying to do. It might be like the bunny example but I just want to set the input _temp point manually and relay on the mouse poisition: Is this possible?
  11. I have a long animation that will not fit on a single 2048x2048 sprite sheet. I need to keep the spritesheet/atlas that size though. What is the best way to go about defining the animation. With one Texture Packer spritesheet/atlas it looks like this: caster =, 100, 'caster', 'FIRE_00001.png'); animation = caster.animations.add('fire', Phaser.Animation.generateFrameNames('FIRE_000', 1, 23, '.png', 2), 30, true, false); Where the sprite sheet is caster.json and caster.png. With two sprite sheets the animations would be over two sprite sheets: caster-1.png caster-1.json and caster-2.png caster-2.json Since i have to preload both 'caster-1' and 'caster-2' I can't just reference a single atlas 'caster'. Do I have to create two animations and call oncomplete functions to play the next? It seems like there should be a simper way.
  12. ptotheaul

    Determine sprite directly under another sprite

    The ball is not moving. it just gets placed in a certain spot. I've tried using overlapping but it returns every object that the ball overlaps with and I just want it to return the object that is on the top(or ideally the objects that are not covered by another oject).
  13. I have a game where a sprite(ball) is dropped and then I need to determine what the sprite(object) is directly under it is, where there are a lot of object sprites. If an object sprite covers another object sprite I would only want the top object sprite to be detected(ideally if the ball sprite overlapped the visible area of multiple object sprites I would like all of the of the ball/objects detections to show). I've looked into .intersects and even just using a single point with .contains but can't figure it out. If I check for collisions is there a way to just check for the visible(not covered up by other sprite) area?
  14. ptotheaul

    Animate CC exporter

    Hi. I know there has been some discussion about how to export an Animate CC animation for use with Phaser/Pixi on the forums but it all is kind of old so I figured I'd ask to see if there is a new method of doing this. I have a movie clip that has other nested movie clips(each with a timeline animation) that need to be triggered. This is a conversion from Flash and works in createJS but it's really slow and I think would be much better if done with Phaser or Pixi. Also do any of the Phaser IDEs have timeline animators in them? That could also be an option.
  15. ptotheaul

    Transfer sprite velocity to another sprite

    What I'm doing is really going to be one sprite image that turns into two sprite images. I know there is this: sprite.body.bounce.setTo(1, 1); but I'm wondering if there's already a solution for transferring that bounce energy into two sprites.