nicolatroehler Posted October 31, 2014 Share Posted October 31, 2014 Hey there!I was thrilled to hear that pixi now supports retina screens. But somehow it won't work on TilingSprites?//Global VariablesmyDisplayResolution = window.devicePixelRatio; if(myDisplayResolution === 2){ ww = $(window).width()/2; wh = $(window).height()/2;} else { ww = $(window).width(); wh = $(window).height();}rendererOptions = { antialiasing:true, transparent:true, resolution:myDisplayResolution}//FullscreenStage Constructorfunction rendererstage(type, cavansid, width, height){ if (type == "fullscreen"){ width = ww; height = wh; } this.renderer = new PIXI.autoDetectRenderer(width, height, rendererOptions); document.getElementById(cavansid).appendChild(this.renderer.view); this.interactive = true; this.stage = new PIXI.Stage(0x000000, this.interactive); }//Stage Constructorfunction welcomestage() { if(myDisplayResolution === 2) { // load a retina texture if the resolution is 2 // because of the @x2 in the name pixi will assume the textures resolution is 2 this.logoTexture = PIXI.Texture.fromImage(logourl_2x); } else{ // load a normal texture if the resolution is one this.logoTexture = PIXI.Texture.fromImage(logourl); } //Sprites this.letter = new Object(); this.letter.n1 = new PIXI.TilingSprite(this.logoTexture, 27, 38); //Add to Stage this.rendererstage.stage.addChild(this.letter.n1); //Animate Method this.animate = function(){ that.rendererstage.renderer.render(that.rendererstage.stage); requestAnimationFrame(that.animate); }}//init function (called on body load)function init() { //Hide Overflow -> No scrollbars $('html, body').css({ 'overflow': 'hidden', 'height': '100%' }) welcomestage = new welcomestage(); requestAnimationFrame(welcomestage.animate); }Also, I noticed that in your documentation you talk about auto-dedecting the resolution with the "@2x" at the end, but in your code-sample the file ends with "@x2" Thanks for your help! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.