Search the Community

Showing results for tags 'container'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Coding and Game Design
  • Frameworks
    • Phaser 3
    • Phaser 2
    • Pixi.js
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start



Website URL





Found 40 results

  1. 01271

    Code that runs on resize

    Hey all, I want to resize an element but not as often as I currently do it. Right now I have a project with an html element that gets resized on every frame and it runs on every update. game.gui.TextArea = me.Renderable.extend({ init: function() { this.textarea = document.createElement('textarea'); = 'textHistory'; this.textarea.readOnly = "true"; this.textarea.disabled = "true";; }, update: function() { videoPos =; = 'width:' + (window.innerWidth - videoPos.width) + 'px; height:' + videoPos.height + 'px;'; } }); I'm concerned about this, this code will run way more often than it needs. Not sure about the performance impact but it only needs to run when the window size is updated. Is there a way I can piggyback on any melonjs functions that resize the canvas and only run it then?
  2. andrei.nicolae

    Bring to top container

    Hi guys, does anyone know how can I bring in front of all of my scene a container(popup) that was created in a previous scene? Is this possbile? Thanks.
  3. andrei.nicolae

    Pop-up window

    Hi guys, I'm trying to make some windows(pop-ups) that I will use in my game, these are for game over, game won or showing different text tips. Will contain text, buttons, sprites. What is the best way to achieve this? If I use a container, how can I show/hide it? This environment is new for me so I'm open to suggestions and ideas. Thank you!
  4. I am trying to get all the children of a container displayed inside a zone. var container = this.add.container(200, 200); var sprite0 = this.add.sprite(0, 0, 'box'); var sprite1 = this.add.sprite(0, 100, 'box'); container.add([ sprite0, sprite1 ]); var graphics =; var color = 0x00ffff; var thickness = 2; var alpha = 1; graphics.lineStyle(thickness, color, alpha); graphics.strokeRect(32, 32, 256, 256); graphics.fillStyle(color, 0); graphics.fillRect(32, 32, 256, 256); container.mask = new Phaser.Display.Masks.GeometryMask(this, graphics); However when they are outside and overlapping is seems like they are blending on each other? How should I proceed?
  5. When I extend a class, as shown here: export class AbstractType extends Phaser.GameObjects.Sprite and try to add a subclass of that type(AbstractType) into a container, symbols.add(symbol) I get the following error: TypeError: gameObject.once is not a function at Container.addHandler (/Users/schwarzj/Desktop/symphonymathhtml5/node_modules/phaser/dist/phaser.js:57689:1) at Object.Add (/Users/schwarzj/Desktop/symphonymathhtml5/node_modules/phaser/dist/phaser.js:100986:1) at Container.add (/Users/schwarzj/Desktop/symphonymathhtml5/node_modules/phaser/dist/phaser.js:57790:1) at NumberBarController.addSymbol (/Users/schwarzj/Desktop/symphonymathhtml5/app/controllers/numberbar.controller.ts:807:12) at NumberBarController.layoutTask (/Users/schwarzj/Desktop/symphonymathhtml5/app/controllers/numberbar.controller.ts:481:12) at NumberBarController.onSoundsLoad (/Users/schwarzj/Desktop/symphonymathhtml5/app/controllers/numberbar.controller.ts:364:9) at EventEmitter.emit (/Users/schwarzj/Desktop/symphonymathhtml5/node_modules/phaser/dist/phaser.js:1960:1) at Function.AudioController.sendAudioLoadComplete (/Users/schwarzj/Desktop/symphonymathhtml5/app/controllers/audio.controller.ts:300:44) at EventEmitter.AudioController.onSoundsLoaded (/Users/schwarzj/Desktop/symphonymathhtml5/app/controllers/audio.controller.ts:250:25) at EventEmitter.emit (/Users/schwarzj/Desktop/symphonymathhtml5/node_modules/phaser/dist/phaser.js:1939:1) TypeError: child.setScrollFactor is not a function at ContainerWebGLRenderer [as renderWebGL] (/Users/schwarzj/Desktop/symphonymathhtml5/node_modules/phaser/dist/phaser.js:135801:1) at WebGLRenderer.render (/Users/schwarzj/Desktop/symphonymathhtml5/node_modules/phaser/dist/phaser.js:63279:1) at CameraManager.render (/Users/schwarzj/Desktop/symphonymathhtml5/node_modules/phaser/dist/phaser.js:110694:1) at Systems.render (/Users/schwarzj/Desktop/symphonymathhtml5/node_modules/phaser/dist/phaser.js:25617:1) at SceneManager.render (/Users/schwarzj/Desktop/symphonymathhtml5/node_modules/phaser/dist/phaser.js:43412:1) at Game.step (/Users/schwarzj/Desktop/symphonymathhtml5/node_modules/phaser/dist/phaser.js:105691:1) at TimeStep.step (/Users/schwarzj/Desktop/symphonymathhtml5/node_modules/phaser/dist/phaser.js:102205:1) at step (/Users/schwarzj/Desktop/symphonymathhtml5/node_modules/phaser/dist/phaser.js:64607:1) Any suggestions on how to move forward from here? Thank you!
  6. paperjack

    Visibility of overlapping containers

    Hello, I am making an arena shooter multiplayer game with destroyable obstacles. You can see a pre-alpha here: I have encountered a problem I'm not sure on how to proceed on and I surprisingly couldn't find any information on similar issues. My game will have tall walls and other obstacles which can potentially cover the player's character. I would like to make an effect similar to RTS games, where an outline or a shadow of the player is visible on top of the obstacle. See the below picture to get an idea of what I mean. My player container contains several sprites. I have a few ideas on how to do this, but I do not think they are optimal. One is rendering the player container to a texture and using that a mask for potential overlapping obstacles, along with a filter. Secondly is just placing a simple GUI marker that shows where the player character is. In both cases, I am unsure on how to detect overlapping sprites. Is there an established solution for such cases? Thanks!
  7. Muhammad Adnan

    Drag and dropping in a container

    Hey guys, So I was fiddling around with Pixi's drag example on their website. I was wondering how can one drop the object in a container. For example I want to move and object and when it reaches near the container it attaches on top of it. I'm really scared of posting this since people might think I want someone to code it for me but I just want to understand the concept and the things I can use, so to say a guide. Would appreciate the help
  8. Giedrius

    Clone the PIXI Container

    Hi all, I am trying to clone an PIXI Container so that it will have no relationship with the original one, except that they both should share the same prototypes - DisplayObject, EventEmitter, Object. But somehow I loose the original Container, see demo:
  9. Gerente

    Virtual Container

    Container and DisplayObject do not have their own size, its depends of its children, so If you add a Child and use anchor property and others properties related with size it will not work. What would be the best practice to do a simple layout like HEAD, BODY and FOOT? where I can define and limit the size of each "area" and all their children? I thinking in create a new class that inherit Container and overwrite the width and height properties to be static but I'm not sure it will be considered in the anchor logic. Any advice?, here an example how it does not work
  10. Nephelococcygia

    Best way to handle Character with shadow

    I was wondering what is the best way to handle shadow for a "character". I made a character and i want to put a shadow at the bottom a kind of "circle" with opacity, for convenience let's say it's gonna be a transparent PNG. The way i can think of : - (1) Just add the sprite to the game, this leads to duplicated calculations in the update part cause i have to update both the "character" sprite and his shadow; - (2) Add the shadow as a child sprite of the "character", this leads to having the shadow on top of the sprite instead of back to it; - (3) Add the "character" sprite as a child of the shadow sprite, this seems not logical, but it works somehow; - (4) Create a group and add both the shadow and the sprite, (havn't test it but most likely) this leads to define specific property to the group for the size, the position and the overflow boundaries for collision relative to the "character" sprite and the shadow; - (5) Using a filter (Shader) applied on the hole game, with my character position as uniform to render the shadow directly on the "groundLayer". What do you think please ? Is there a better way that i am missing ? Thanks.
  11. I'm fairly new to pixi.js and programming altogether. I am making a plugin that parses the xml save file of a sprite animation program and recreates the result in a game engine. The animation program uses bones for skeletal animations and the images (sprite parts) inherit the x, y, angle, scale_x, scale_y of the parent bone. The main idea would be to create sprites for the bones and the images, set up the bone inheritance to make the skeleton animation work correctly and then addChild the image sprites to the respective bone sprites. The only problem is that along with the aforementioned values, my image sprites also inherit the z_index of their container. The spriter does not limit the z hierarchy of the images to that of the parent bones, meaning that the user can change their z. I attempted to use worldTransform and worldAlpha for the parent bone values (keeping all the image sprites in a single container, thus controlling the z_index), but I am unable to get the parent bone's rotation. So, I either need to get all the values of the container and apply them correctly on the image sprites, or keep the image sprites inside the container and find a way to change their world z. Any suggestions would be appreciated and I thank you for your time.
  12. Hi there, first i'm more or less new to JS and Pixi (comming from php), so please be patient if i ask strange questions i want to write an relative huge game/app with many locations and animations (spine maybe) and want to realize it in an one page app. To keep the memory usage low i try to write an stage/container management class that only initialize the elements (sprites/animations/dom elements) on demand and dispose them afterwards. My question is now is there allready an solution for this hidden in pixi? Or does a best practise exist for this? Or does there exist maybe even a tutorial for such a thing? Like mentioned i tried allready to write an class, but this works only for better management, but not for less memory usage or performance (app.js) And till now only adding (dom)elements and displaying them works (with resize! ) but destroying or adding the sprites in the container wont work. so any suggestions or guiding directions how to solve the many locations issue?
  13. Hello there, What an amazing engine to render on webGL/Canvas! We are getting such a boost on performance thanks to this great library. Now, let's go to the point: We managed to partly migrate all our SVG animations to canvas using PixiJS. In order to do that, we had to parse our SVG so we could have a Container/Sprite/Textures structure that Pixi could manage and understand. We finally did it, and we have an Object like the onw you can see on the attached image: It is coming from the SVG you can find here: So, what we have, is a lot of containers (what used to be groups in our SVG) and inside them, more Containers and finally Sprites containing Textures (what used to be paths). THE PROBLEM: We want to use Pixi's AnimatedSprite class so we can animate the mouth of our character, and when we do it, it works, but we lose the position of our Textures and they show at the upper left corner of our character. I can't see any position on this Sprites and Textures, so I guess they are just drawed where they are supposed to be and therefore when we try to animate them, we lose this relativeness to the parent and position. Any way to make them stay in place? Thank you very very much
  14. Hersir

    Group animation

    Hi ,is there some build in way to animate mesh and all its children together? Or I need to loop through all child meshes and apply animation separately? I have invisible mesh as container and I add children to it as I need group control. Works well for position changes but I need also to fade out children (opacity).
  15. When I first use PIXI.js I used to put every sprite onto the stage. Then I know that there is a Container class to hold the sprites. So I can add some sprites onto one container and other sprites to another container. After that I can add all the containers onto the stage and PIXI.js will handle the drawing for me. This is a very smart idea because I can use it to group sprites that I may want to scale together or delete together. But on some occasions I still have questions putting them together because I am afraid I may have a bad design. If deleting a container means it also delete everything inside the container, is it a good design to put sprites into a container if I want to delete them as a whole in the future? Does the computer need more resources if I use many levels of containers in my game? For example, if my player have several segments or several parts, like a plane with some shield or small added laser guns, is it better to group them into one container or just put them into the parent container? If I am building a train, is it better to put all the carriages of the train into a container as a whole, meaning the train is a container, or put them into the parent container? If robustness and efficiency are the main concern, what design rules should I follow?
  16. I am recently building a container / map with thousands of sprites in canvas. My player will be moving around among those sprites on a large map. But I find my game becomes very slow after I add too many (-about 5000+) units on the container. I think it may perform better if I only display units that are within the camera of my player as my player moves around on the map. But by doing this I will need to perform addChild / removeChild operation of pixi.Container many times during the game loop, because as my player moves new sprites come into sight and some sprites are out of sight. I am not sure if this is a good or bad decision. Maybe it’s too costly to do these operations in the ticker? But how can I draw as little in-sight sprites as possible otherwise?
  17. I have tried to put my sprites into a ParticleContainer but they won't show up. But if I put them into a PIXI.Container they show up. I don't understand. Here is my code: this.objectContainer = new PIXI.particles.ParticleContainer(6000, {scale: true, position: true, rotation: true, alpha: true}); // this.objectContainer = new Container(); // Code for building a single sprite: const g = new Graphics(); g.beginFill(0x24D5EF); g.lineStyle(0); g.drawCircle(radius, radius, radius); g.endFill(); const rt = RenderTexture.create(g.width, g.height); this.renderer.render(g, rt); const sprite = Sprite.from(rt); I have only 600 objects to display and I define my ParticleContainer as above. It worked before when all object information are local, but now I get my object information from the server. But the sprites are still built on the client. Nothing else had changed. Why does it work in a normal Container but not in ParticleContainer anymore?
  18. Does Phaser offer any concept of a "Scroll View"? Basically a box you can add content to and swipe up and down? I'm trying to create scrollable list of items. I think I can manually code a scroll view, but I just thought I'd check to see if it already exists first.
  19. Hey guys, Please take a look at this JSFiddle: As you can see I'm trying to have a button with a text on it. Therefore I create a Graphics object and draw it as a Rectangle. Afterwards I add a Text object to its children AND this Text object receives an option called "align : center". That way I expected the Text to be centered to its local container. Sadly the Text just got rendered at the global x:0;y:0 Can somebody tell me what I'm misunderstanding in regards to the container system of PIXI.js? greets Charlie!
  20. brdmg

    Using ParticleContainer

    Recently I've been developing small app for raspberry pi with few sets of sprites. I used PIXI.Container as stage for rendering with MovieClip objects inside of it. And it works fine. Then I tried to improve perfomances and changed PIXI.Container to PIXI.ParticleContainer(5000, {uvs: true }); It works fine on pc, but on pi i get error "TypeError: null is not an object (evaluating 'this.parent.transform')" which occurs in this part of pixi DisplayObject.prototype.updateTransform = function () { this.transform.updateTransform(this.parent.transform); // multiply the alphas.. this.worldAlpha = this.alpha * this.parent.worldAlpha; this._bounds.updateID++; }; I tested this part and it's used by PIXI.ParticleContainer and not PIXI.Container and i was wondering can i somehow avoid using this part of code
  21. How can I create a PIXI.Container with a transparent background which I can render on top of my main stage container? My goal is it to have 4 layers which contain PIXI.Sprites and PIXI.Texts: layer 1 should be rendered beneath the player layer 2 should be rendered above layer 1 layer 3 should be rendered above the player and above layer 1 and layer 2 layer 4 should be rendered above everything else for debug information In case I can cannot use multiple PIXI.Container then how else could I achieve this effect?
  22. flowww

    Gridify the Container Sprites

    Can we apply any plugin to gridify the sprites in a container? I am trying to group the sprites in a container so that I can move the container instead of all images inside it but I want sprites not to be overlapped.
  23. I am having the hardest time adding a list of objects to my container! For whatever reason, only the last container object appears on the left side of the screen. Any clue as to why only one container is being drawn? If anyone is interested in testing the program, here is a link to the related commit. Parent Container: (function (window) { function ChestManager() { container.Container_constructor(); container.addChest(640,100,1,1,"topClosed"); container.addChest(1100,360,1,1,"sideClosed"); container.addChest(640,620,1,1,"bottomClosed"); container.addChest(180,360,-1,1,"sideClosed"); } //instance of class var container = new createjs.extend(ChestManager, createjs.Container); //shared spritesheet properties var manifest = [{src: "chests.png", id: "chests"}]; container.loader = new createjs.LoadQueue(false); container.loader.addEventListener("complete", handleComplete); container.loader.loadManifest(manifest, true, "img/"); //configure after loaded function handleComplete() { container.spriteSheet = new createjs.SpriteSheet({ framerate: 4, images: [container.loader.getResult("chests")], frames: [[0,0,159,132,0,79.25,65.65],[159,0,193,107,0,98.25,40.650000000000006],[352,0,193,107,0,98.25,40.650000000000006], [545,0,113,147,0,56.5,73.4],[658,0,180,149,0,56.5,75.4],[838,0,180,149,0,56.5,75.4], //center bounds [0,149,116,97,0,57.25,47.75],[116,149,111,94,0,55.25,44.75],[227,149,111,94,0,55.25,44.75]], animations: { //"run": [0, 1, "run"], topClosed: [6], topOpenReward: [7], topOpenNothing: [8], sideClosed: [3], sideOpenReward: [4], sideOpenNothing: [5], bottomClosed: [0], bottomOpenReward: [1], bottomOpenNothing: [2] } }); } //update container.tick = function (event) { for (i=0; i<container.children.length; i++){ if (container.getChildAt(i).isClicked()){ container.removeChest(i); } } } container.addChest = function (x,y,scaleX,scaleY,frame){ container.addChild(new Chest(x,y,scaleX,scaleY,container.spriteSheet,frame)); //add to stage container.getChildAt(container.children.length-1).sprite.on("click", function(evt){ container.getChildAt(container.children.length-1).click(); }); } container.removeChest = function(i){ container.getChildAt(i).sprite.removeEventListener("click"); container.removeChildAt(i); } window.ChestManager = createjs.promote(ChestManager, "Container"); }(window)); Child Container: (function (window) { //constructors function Chest(){ container.Container_constructor(); } function Chest(x,y,scaleX,scaleY,spriteSheet,frame){ container.Container_constructor(); container.initChest(x,y,scaleX,scaleY,spriteSheet,frame); } //instance of class var container = new createjs.extend(Chest, createjs.Container); //initialize Chest container.initChest = function (x,y,scaleX,scaleY,spriteSheet,frame) { container.x = x; container.y = y; container.sprite = new createjs.Sprite(spriteSheet, frame); container.sprite.scaleX = scaleX; container.sprite.scaleY = scaleY; container.sprite.gotoAndStop(frame); container.customText = new CustomText(0,0,scaleX,scaleY,"car"); container.addChild(container.sprite); container.addChild(container.customText); } //public functions container.isClicked = function(){ return container.clicked; } = function() { container.clicked=true; } window.Chest = createjs.promote(Chest, "Container"); }(window)); Result (ignore the backwards 'R' haha)
  24. How add a PIXI container into a Phaser Game? I have a game made ONLY with PIXI. but now i would like to port it to a Phaser. All my game content happens inside a pixi container "screenContainer". I tried to add a pixi container like this. var created = function() { screenContainer = new PIXI.DisplayObjectContainer(); var sprite =; } = new Phaser.Game(gameWidth, gameHeight, Phaser.AUTO, "divId", { create: created }); but it stops here "phaser.js" line 33067 /** * The core update - as called by World. * @method Phaser.Group#update * @protected */ Phaser.Group.prototype.update = function () { var i = this.children.length; while (i--) { this.children[i].update(); // UPDATE IS UNDEFINED } }; because Pixi.Container, does not have "update" method. Is there any other way to add a pixi container inside a phaser game? thanks
  25. Shadowstep33

    Container switching in pixi

    Hi guys, I was trying to find an answer to this but had some problems (maybe my Google-fu is just a little off today). Thankfully, I figured out the answer myself. Assuming you have a character walking around in a world of containers (for example, walking from one zone to the other where each zone is a container that is next to the other) the calculation is: newX = oldX + (oldContainerX - newContainerX); newY = oldY + (oldContainerY - newContainerY); and a real code example: if(buckets['walking'].parent){ var newX = buckets['walking'].position.x + (buckets['walking'].parent.position.x - buckets.biomes[overlappingBiomes[0]].scen.position.x); var newY = buckets['walking'].position.y + (buckets['walking'].parent.position.y - buckets.biomes[overlappingBiomes[0]].scen.position.y); // buckets['walking'].parent.removeChild(buckets['walking']); buckets.biomes[overlappingBiomes[0]].scen.addChild(buckets['walking']); buckets['walking'].position.x = newX; buckets['walking'].position.y = newY; } Hopefully this helps someone! Cheers