Quantcast
Channel: Pixi.js Latest Topics
Viewing all 3980 articles
Browse latest View live

Strange things with TilingSprite

$
0
0
var renderer = PIXI.autoDetectRenderer(800, 600, { antialias: false });
document.body.appendChild(renderer.view);

// create the root of the scene graph
var stage = new PIXI.Container();

var grid = new PIXI.Graphics();

  grid.lineStyle(1, 0xffffff, 1);

  grid.moveTo(0,10);
  grid.lineTo(20,10);

  grid.moveTo(10,0);
  grid.lineTo(10,20);

//grid.cacheAsBitmap = true;

  stage.addChild(grid);

  var tilingSprite = new PIXI.extras.TilingSprite(grid.generateTexture(2), 800, 600);
    
//tilingSprite.cacheAsBitmap = true;

  tilingSprite.x = 0;
  tilingSprite.y = 0;

  stage.addChild(tilingSprite);

animate();

function animate() {

    renderer.render(stage);
    requestAnimationFrame( animate );
}

Drop this into https://pixijs.github.io/examples/

1) How can I eliminate spaces between tiles?

2) Is there some forced antialias? The tiled texture gets blurry and displaced :(

Help, plizz. I tested with both dev4 and 3.0.11


Load external json file

$
0
0

Hi, how can i load external JSON file in .js file using Pixi .js without jQuery ? Tnx 

Some newbie questions about pixi js

$
0
0

Hello, guys! I am junior-developer of mobile apps and games (:

I created one small game (2048 clone with pictures) for Android (only) on html5 (js) with css animation. Many users told me in reviews that game crashed many times. I also have some trace info:

Quote

backtrace:
    #00  pc 00000000  <unknown>
    #01  pc 00b5159f  /system/lib/libwebviewchromium.so
    #02  pc 001dbdcf  /system/lib/libwebviewchromium.so
    #03  pc 001dc01b  /system/lib/libwebviewchromium.so
    #04  pc 001da25b  /system/lib/libwebviewchromium.so
    #05  pc 0000d280  /system/lib/libc.so (__thread_entry+72)
#06 pc 0000d418 /system/lib/libc.so (pthread_create+240)

I think it happens because game container have many tiles with png or it's bug with chrome and css animation. Also game has some performance issues on old devices.

To solve this problems I want to try convert my game to pixi js engine (canvas, webgl). I already convert game logic to pixi. Some examples:

// init pixi engine
  function initPixi () {
    renderer = new PIXI.autoDetectRenderer(280, 280, {backgroundColor: 0x101822});
    document.getElementById('pixi-container').appendChild(renderer.view);
    stage = new PIXI.Container();
    requestAnimationFrame(animate);
  }

  function animate() {
    requestAnimationFrame(animate);
    renderer.render(stage);
  }

// create game container
setup = function() {
    // some code

    g = new PIXI.Graphics();
    g.beginFill(0x101822,1);
    g.drawRect(0,0,280,280);
    stage.addChild(g);
    for (var i = 0; i < this.size; i++) {
      for (var j = 0; j < this.size; j++) {
        g.beginFill(0x999999,1);
        g.drawRoundedRect(j * 68 + 10, i * 68 + 10, 58, 58, 3);
        g.endFill();
      };
    };
  };

// draw tile rectangle, add bg and png childs
function Tile (position, value) {
 // some code

    this.image = new PIXI.Graphics(); 
    this.image.position.x = this.x * 68 + 10;
    this.image.position.y = this.y * 68 + 10;
    this.image.beginFill(qualityColorsArray[this.value],1); 
    this.image.drawRoundedRect(0,0,58,58,3); 
    this.image.endFill(); 
    this.image.bg = PIXI.Sprite.fromImage('img/skins/skin-bg.png');
    this.image.bg.width = 58;
    this.image.bg.height = 58;
    this.image.addChild(this.image.bg); 
    this.image.png = PIXI.Sprite.fromImage('img/skins/' + collectionIid + '/' + this.skin + '.png');
    this.image.png.width = 58;
    this.image.png.height = 58;
    this.image.addChild(this.image.png); 
  }

// add tile to container
addTile = function(tile) {
  // some code
       g.addChild(tile.image);
}

// remove tile from container
removeTile = function(tile) {
  // some code
    g.removeChild(tile.image);
  };

// move tiles (animate with TweenMax) and crate merged tile
moveTile = function(direction) {
  // some code
  if (merged){
    TweenMax.to(tile.image, .2, {x: positions.next.x * 68 + 10, y: positions.next.y * 68 + 10, onComplete: removeTiles(merged.mergedFrom)});
    self.grid.insertTile(merged);
  } else {
    TweenMax.to(tile.image, .2, {x: positions.farthest.x * 68 + 10, y: positions.farthest.y * 68 + 10});
    moveTile(tile, positions.farthest);
  }
}

My questions is:

  1. On Genymotion Android Emulator instead of game container with tiles I see only black square. But game works (tiles moves, score updates etc). What's wrong? How can I debug game on Android emulator (I try already Canvas and WebGL render).
  2. My PNGs are bigger that tile size (350px vs 58px). Pixi render images like with bad antialiasing pixi1.PNG (pixi) vs pixi2.PNG (css). How can I fix this?
  3. How can I add animation for new tiles? I try to add some TweenMax functions after g.addChild() function but nothing happens. I want to recreate css animation (code bottom)
  4. I move merged tiles with TweenMax.to() animation and call removeTiles function after complete. I think function must play move animation and then remove tiles from container but in real world it just remove tiles and render merged tile so I don't see any animation. With Not merged tiles animation works correct.
  5. Do u have any other suggestions about game performance and correct work with canvas and sprites? It will be very helpful for me, newbie in game development ^^.
    @-webkit-keyframes pop {
        0% {
            -webkit-transform: scale(0);
            -moz-transform: scale(0);
        }
    
        50% {
            -webkit-transform: scale(1.2);
            -moz-transform: scale(1.2);
        }
    
        100% {
            -webkit-transform: scale(1);
            -moz-transform: scale(1);
        }
    }

    Great thanks to community! Sorry for my bad English. I try to explain better if u don't understand something.

how can i rotate effect by one image..

$
0
0

hi 

how can i calculate  like following image with pixi.js?

LHIHYU4.gif

rotating fire is calculating by only one image.

it can be by pixi.js too.

but i don't know correct calculating theory..

i wanna draw follawing image to effect like magic


magicshape02.png

 

thx...

.visible in ParticleContainer

$
0
0

Hello,

I'm rendering isometric terrain (about +700000 sprites) in ParticleContainer(for speed) and i need hide some blocks(occulusion culling). But .visible for childs in ParticleContainer not work. Can you help me?

Sorry for my bad english,

In pixi-gl-core float texture not working on multiple gl contexts

$
0
0

Experimenting with pixi-gl-core in Google Chrome ( 51.0.2704.103  ). It seems that GLTexture.js sets the global FLOATING_POINT_AVAILABLE  once the gl.getExtension("OES_texture_float") has been successfully triggered. When using multiple instances of this texture class with multiple gl contexts this means that OES_texture_float is only enabled on the first context.  

By the way I couldn't find float texture support in PIXI V4 - is that coming too?

screen coordinates vs. world coordinates

$
0
0

Hello,

I'm quite new to pixi, so I'm wondering about the following: how can I specify the game world size independent of the screen container size?

E. g. I want to transform my 20x16 tiles game from manual canvas drawing and scaling to pixi, for ultimate awesomeness ;-) and of course the screen container should be bigger than 20x16 pixels. How can I specify this?

And, in addition, how can I specify sprite size in world units, not pixels?

issue of base64 string size

$
0
0

hi all, just a new one in pixi.js, im having some issues, any help or suggestion will be appreciated.

1: i have a large image 12.7 MB, after transformed it to base64, chrome dev tools demonstrates the base64 string's length is >17 millions, but if i created a texture with this large image, then call getBase64(), the returned string's size is > 46 millions, what cause such an increase of the base64 string's size?

 

2: my app is almost an image editor,  most of time, i only care about the static image, that's why i only call renderer.render(stage) when i really  need it. but how about this scenario: i have a large image as a background, and on top of it, there is a draggable rectangle, so in the callback onDragMove, i need to render the entire canvas over and over again, in case the image is large image like 13 MB, this will cause the serious performance issue, i am wondering how could i improve or skip this issue, is the issue possible to get solved with only on canvas? some thing like we tell the renderer: hey, please just render container A, not for container B?

 


pixijs - drawing order/z-index (+using plugins)

$
0
0

Is there any easy way to specify drawing order and/or the z-index of sprites in a Container? The order of adding elements seems to have no influence.

My basic problem is that my background image renders over _some_ of the foreground sprites.

I tried to use pixi-display.js, but I seem not to be able to import it correctly. I just created a <script> tag linking to pixi-display.js after the <script> tag that loads pixi.min.js (v4 from GitHub), but it keeps telling me "DisplayGroup is not a constructor" or "DisplayGroup is not a function". I thought using display lists and groups was a nice thing, but I'm open for a simple hack, too ;-)

Uv in filters

$
0
0

Is there a way to get coordinates from 0...1 in filters that map to the actual viewing area rather than the texture size.

For example I want to tint an object so that it gradually changes color based on the distance from center point.

Doing that with this:

varying vec2 vTextureCoord;

uniform sampler2D uSampler;

void main(void)
{
	float dist = length(vTextureCoord - vec2(0.5, 0.5));
	gl_FragColor = dist * texture2D(uSampler, vTextureCoord);
}

Provides wrong results (sometimes correct) as the actual display area might not be in the 0-1 area.

One way to fix this would be to pass an uniform with the position and dimensions of current display. But I'm wondering if there's something that's built in to pixi already.

create an oop grid array ?

$
0
0

hi, 

i know create an oop object with a simple graphic shape like this :

 // create an new instance of a pixi container
var container = new PIXI.Container();
// create a renderer instance
var renderer = PIXI.autoDetectRenderer(320, 480);

// add the renderer view element to the DOM
document.body.appendChild(renderer.view);

requestAnimationFrame( animate );


var T={}
T.draw = function() {
PIXI.Graphics.call(this)
this.beginFill(0xFFFFFF)
this.drawRect(100,100,80,200)
}

T.draw.prototype = Object.create(PIXI.Graphics.prototype);
T.draw.prototype.constructor = T.draw;

var button=new T.draw()

container.addChild(button);

function animate() {

	requestAnimationFrame( animate );
	renderer.render(container);
}

 

but I am lost on the fact of doing the same with  an 2d array. Can you point me ?

var graphics = [];
for (var j = 0; j < 5; j++) {
    graphics[j] = [];
    for (var i = 0; i < 5; i++) {
        graphics[j][i] = new PIXI.Graphics();

        graphics[j][i].beginFill(0xFF3300);
        graphics[j][i].lineStyle(4, 0xffd900, 1);
        graphics[j][i].drawRect(0,0,10,10);
        graphics[j][i].position.x = 40 * i;
        graphics[j][i].position.y = 40 * j;
        container.addChild(graphics[j][i]);
    };
};

 

filter area acting strange?

$
0
0

I was trying out some filter effects in Pixi 4 and noticed by setting the filterArea the region outside the area is no longer rendered. i.e. black
Is this the intended behaviour a filterArea? I was hoping for the filter to be applied only to the specified area and leave the rest of the image unaffected.
I made a codepen here http://codepen.io/anon/pen/VjAGmJ

Performance Tips

$
0
0

What are some general performance tips that you would have for newcomers to Pixi? Also what should we really take care of if we want to avoid memory leaks, performance issues, etc. I currently destroy all graphics objects, sprites and textures that I use. I also take care of the stage and the renderer. Also I store references to dynamically created objects in arrays and then clear them afterwards when I need to. However I still see small memory leaks here and there. I use chrome dev tools to identify the leaks..

Also, consider this scenario. I have two pages, and on both of them I have a Pixi canvas with some stuff being drawn. When switching from page 1 to page 2, the whole page 2 throttles, until the Pixi canvas is loaded, although this is just a guess for now. However when I remove the Pixi canvas the page loads, fast, normal.. I am just asking this vaguely, since I haven't looked at what might be causing the issue yet, but I want to have some more input before I start. I do draw around 100+ different graphics elements on the second page.. Are there any ways to improve this loading, rendering time of the second canvas? Also I am running this on a 3rd party device, and that's why I need to be very conservative with memory and performance. When running on PC, I do not see performance issues, however the device is also really powerful, so I would not say this is a hardware limitation.

Unreliable mouse interaction with rope mesh

$
0
0

Hi, I'm trying to modify the 'strip' pixi.js example that demonstrates the rope mesh. I tried adding interactivity to the rope so that when I click it the size changes.

https://codepen.io/aatish/pen/yJPWBx

However, the click behavior seems unreliable for me. It works in some places and not in others, and I'm having trouble understanding where in the image I should be clicking for the interaction to occur. Ideally I would like the interaction behavior to happen whenever I click within the boundaries of the snake. 

Any pointers would be much appreciated.

Best,

Aatish

 

 

Text Width

$
0
0

Some text appears too wide and some not wide enough.   I'm using 3.0.11.  Is setting the width needed somehow?

 

LnnhM7j.png


Blend/shader that lerps between SRC and DST?

$
0
0

Hi!

Shader newbie. I have a need to interpolate between DST and SRC colors while rendering a sprite. I kind of assumed this would be easy since some blend funcs involve DST_COLOR, but when I got into it, seems there is no way to read DST inside a fragment shader.

1) Is this true?

2) If this is true, then it seems like my only recourse is to capture my target into a texture and lerp between the sprite's texture and that captured texture. Is that right?

If (2) is the only way forward, it seems that Pixi v3 lacks multitexturing support. v4 seems to have it in some capacity, but maybe not in the sense that I can assign two textures to a sprite?

Is there any way to do this in Pixi v3 OR v4?

Thanks!

Brian

 

I've created a Flash animation runtime for PixiJS (Pixi Flump Runtime)

$
0
0

I've been developing a Flump runtime for Pixi.js over the last 6 months for a game I am working on. I would now like to share my library with the Pixi community. 

For those of you unfamiliar with Flump (a seperate project), it is a Flash animation exporter that converts your nested timeline animation to sprite atlases with keyframe data. Previously no runtime existed for PixiJS.

Here are two examples of exported Flash animation running in PixiJS with Pixi Flump Runtime.

Dog example

Monster example

Flump has been an invaluable tool in my arsenal, I hope you guys find it useful! Check out the github project for the source code of the examples. Documentation will be coming soon. It has currently been tested with Haxe projects, but I would really like some feedback on your experiences using it with Javascript.

Also, thank you Mathieu Anthoine for your valuable input and testing of the library! It's been immensely useful having a second set of eyes early in the development :)

blendMode only working with ADD, OVERLAY and SCREEN

$
0
0

Hi,

I cannot get blendMode to work with anything but ADD, OVERLAY and SCREEN. Its not down to browser as I have tested working versions that use all the other blend modes in all the browsers Im using outside of PixiJS, so could it be down the the wrong version of Pixi?

I tried this here, http://codepen.io/ianmcgregor/pen/CtjeI which allows you to upload a test image and live set the blendmode, and it definitely does not work for me, other than the three mentioned.

My code is just standard generate a sprite and apply the blend mode to it

myObject.blendMode = PIXI.BLEND_MODES.DIFFERENCE;

Am I right in thinking that Pixi can actually use all the other blend modes? the site examples seems to suggest you can - hence Im thinking my version of Pixi might be dated...

Spine hierarchy

$
0
0

Hi,

how can I get access to specific slot in my spine skeleton? I have simple spine skeleton animation and sprite which is a few display layers under the spine skeleton, and I need that sprite will be reproduce moves of specific slot. Is there any way how can I get global coords of the slots? Thx 

Animated Text

$
0
0

Hello, is it possible to animate a text?

For example, don't render the entire text in an instant, but do it word by word.

Or, making the words move when the mouse is over.

Thank you.

Viewing all 3980 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>