Jump to content

Black box (no green) in place of sprite


michaelcalkins
 Share

Recommended Posts

1 minute ago, drhayes said:

Are these in a sprite atlas? Any chance the atlas JSON is getting loaded differently in Firefox for some reason, like server config? (total guess!)

No sprite atlas just a spritesheet.

Preload

this.load.spritesheet('commando', '/images/commando.png', 300, 315)

Create

    this.player = this.add.sprite(spawnPoint.x, spawnPoint.y, 'commando')
    this.player.scale.setTo(GameConsts.PLAYER_SCALE)
    this.player.anchor.setTo(GameConsts.PLAYER_ANCHOR)
    this.player.height = 91
    this.player.width = 94
    this.player.debug = true

    //  We need to enable physics on the player
    this.physics.arcade.enable(this.player)

    // Enable physics on the player
    this.game.physics.enable(this.player, Phaser.Physics.ARCADE)

    // Make player collide with world boundaries so he doesn't leave the stage
    this.player.body.collideWorldBounds = true

    // Set player minimum and maximum movement speed
    this.player.body.maxVelocity.setTo(GameConsts.MAX_SPEED, GameConsts.MAX_SPEED * 10) // x, y

    // Add drag to the player that slows them down when they are not accelerating
    this.player.body.drag.setTo(GameConsts.DRAG, 0) // x, y
    this.player.body.setSize(145, 295, 0, -3)

    //  Our two animations, walking left and right.
    this.player.animations.add('left', GameConsts.ANIMATION_LEFT, GameConsts.ANIMATION_FRAMERATE, true)
    this.player.animations.add('right', GameConsts.ANIMATION_RIGHT, GameConsts.ANIMATION_FRAMERATE, true)
    this.player.animations.add('death', GameConsts.ANIMATION_DEATH, 20, false)

 

Link to comment
Share on other sites

  • 3 months later...
13 hours ago, samme said:

My Firefox says "Error: WebGL: texImage2D: Requested size at this level is unsupported."

I just saw that in when I found where the console was in Firefox.  At least I know what the error is now.

10 hours ago, yahiko said:

Maybe a stupiid advice, but have you tried to manually clear the cache of Firefox?

hahah not stupid extremely valid and I did many times just in case.

7 hours ago, lewster32 said:

Is your spritesheet a power of two size? I.e. are both the width and the height a power of two (they don't necessarily need to be the same)? It seems like this may be what the error is referring to.

The image in question is 10,800x329.  I can reduce this in size because I think I scale down atm.

commando.png

Link to comment
Share on other sites

I would rearrange your spritesheet to fit in a 2048x2048 image and try again. Pretty much all sprite packing tools have the ability to do this, and it'll ensure that your image can be loaded on pretty much any device/browser correctly. I'd further recommend you switch to a sprite atlas, as you'd be able to pack a lot more of your graphics into a single image (which could vastly improve the performance of your game on GPU-powered devices) by using something such as TexturePacker: https://www.codeandweb.com/texturepacker

Link to comment
Share on other sites

Just so you know, I see this in Chrome (the black box for pants).

Here are the errors:

WebGL: INVALID_VALUE: texImage2D: width or height out of range
153/game?roomId=chilly-zebra-75:1 [.Offscreen-For-WebGL-0x110520a73000]RENDER WARNING: texture bound to texture unit 0 is not renderable. It maybe non-power-of-2 and have incompatible texture filtering.
102game:1 [.Offscreen-For-WebGL-0x110520a73000]RENDER WARNING: texture bound to texture unit 0 is not renderable. It maybe non-power-of-2 and have incompatible texture filtering.

Link to comment
Share on other sites

On 9/15/2016 at 8:36 AM, lewster32 said:

I would rearrange your spritesheet to fit in a 2048x2048 image and try again. Pretty much all sprite packing tools have the ability to do this, and it'll ensure that your image can be loaded on pretty much any device/browser correctly. I'd further recommend you switch to a sprite atlas, as you'd be able to pack a lot more of your graphics into a single image (which could vastly improve the performance of your game on GPU-powered devices) by using something such as TexturePacker: https://www.codeandweb.com/texturepacker

I can't believe I wasn't using that before.  It's fixed now :P

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...