Jump to content

And if I don't scale for mobile targets?


Recommended Posts

Hi, I'm working on a game based in Pixi and I want to avoid the black borders when scaling the game for multiple mobile devices.

The question is, is safe to just use for example assets considering the maximum width and height of a specific model but the game safe area occurs in a space of 320x480 and the gui elements are positioned depending on the actual innerWidth / innerHeight?


Link to comment
Share on other sites

I think instead of posing renderer.view in the dom, you can set position of your background container, so coords from (0,0) - (320x480) will be seen in the screen.


Then you

1) either position gui elements as sprites, manually

2) or you can create GUI elements in the dom and use CSS to set their position :) which wont work for cocoonjs in some configurations...

Link to comment
Share on other sites

For example I have a device with an innerWidth and innerHeight of 400x640, so the renderer view match this size but my assets are positioned in a safe area (ex: 320x480) and the background is bigger and centered all inside the canvas, is safe that to fight the black borders and have compatibility with multiple devices?

Link to comment
Share on other sites

on resize event of window you need to resize canvas (renderer).


you can check how I did it in chi land:

screen.renderer = PIXI.autoDetectRenderer(options);// and call on window.resizescreen.getSizes = function() {    this.sizes = {        canvas: {            width: $('canvas').width(),            height: $('canvas').height()        }    };};// important part screen.resize = function() {    // get canvas current size with jquery     this.getSizes();    // resize your renderer to 100% 100%     this.renderer.resize(this.sizes.canvas.width, this.sizes.canvas.height);};$(window).on('resize', screen.resize.bind(screen));


This is simplified example writing part from memory but it should help i hope

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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