ptotheaul

Members
  • Content Count

    31
  • Joined

  • Last visited

About ptotheaul

  • Rank
    Advanced Member

Recent Profile Visitors

881 profile views
  1. ptotheaul

    ios12 video only playing audio

    I figured out that if I remove the .addToWorld from above the video plays however now the issue is that without the video added to the world my onComplete handler doesn't fire. Anyone have any insight into this issue? this.video = this.game.add.video('introvideo'); this.vidsprite = this.video.addToWorld(0, 0, 0, 0, 1, 1); this.video.onComplete.add(function(obj){ console.log("video over"); }, this);
  2. ptotheaul

    ios12 video only playing audio

    I just noticed that in ios12 when a video is opened in the native player from an ios phone device only the audio plays. I play the video inline on ipads: this.video = this.game.add.video('introvideo'); this.vidsprite = this.video.addToWorld(0, 0, 0, 0, 1, 1); and this code would just open the native player on phones. The video plays fine on older ios versions, ipad inline on io12 and older versions, and the video plays fine in the native player if you just open it from a direct link from the browser. Any ideas why I would only be getting audio from the native player when launched from phaser but the video plays fine in the native player when opened directly?
  3. 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 / this.game.width, window.innerHeight / this.game.height); //canvas.width = (game.width * hScale) - hTrim //canvas.height = (game.height * vScale) - vTrim manager.setUserScale(scale, scale, 0, 0); }
  4. 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?
  5. 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.
  6. 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();
  7. 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 this.game.state.start("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"); }, }
  8. 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"); } }
  9. 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.game.make.bitmapData(this.Badguy.x + 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= this.game.add.sprite(-800, 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); this.Badguy.animations.play('walk');
  10. 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 'this.game.input' 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; this.game.input.hitContext.clearRect(0, 0, 1, 1); x += this.kaiju.texture.frame.x; y += this.kaiju.texture.frame.y; this.game.input.hitContext.drawImage(this.Badguy.texture.baseTexture.source, x, y, 1, 1, 0, 0, 1, 1); var rgb = this.game.input.hitContext.getImageData(0, 0, 1, 1); if (rgb.data[3] >= pixelPerfectAlpha) { return true; } } return false; },
  11. 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.
  12. 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: https://phaser.io/examples/v2/input/pixel-perfect-click-detection Is this possible?
  13. 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 = this.game.add.sprite(100, 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.
  14. 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).
  15. 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?