• Content Count

  • Joined

  • Last visited

  1. Hi, i wondering what is correct way to remove container ? Is it enough to call destroy function on container, or do i need to remove each sprite first. And what about removing container from root stage ?
  2. I did not asked about math, i can make calculations later. For now i have basic function that adds or removes fixed number (speed) to coordinates X and Y. And its doing it each frame. I was just wondering if PIXI have its own hooks / pre-made functions for movement. PIXI.DisplayObject.prototype.moveTo = function (x: number, y: number, speed: number, onComplete?: Function): void { this._moveTo = {}; this._moveTo.x = x; this._moveTo.y = y; this._moveTo.speed = speed; this._moveTo.callback = onComplete; } PIXI.DisplayObject.prototype.move = function (): boolean { if (this._moveTo === undefined) return false; if (this.x == this._moveTo.x && this.y == this._moveTo.y) { if (this._moveTo.callback) this._moveTo.callback(); delete this._moveTo; return false; } if (this.x > this._moveTo.x) { if (this.x - this._moveTo.speed < this._moveTo.x) { this.x = this._moveTo.x; } else { this.x -= this._moveTo.speed; } } else if (this.x < this._moveTo.x) { if (this.x + this._moveTo.speed > this._moveTo.x) { this.x = this._moveTo.x; } else { this.x += this._moveTo.speed; } } if (this.y > this._moveTo.y) { if (this.y - this._moveTo.speed < this._moveTo.y) { this.y = this._moveTo.y; } else { this.y -= this._moveTo.speed; } } else if (this.y < this._moveTo.y) { if (this.y + this._moveTo.speed > this._moveTo.y) { this.y = this._moveTo.y; } else { this.y += this._moveTo.speed; } } return true; } Btw. i don't need to time it. (i don't care how long it will take to move sprite to the target), so this works fine for now. move function is hooked to game tick.
  3. Hi, i wondering how properly animate movement of sprite ? In pixi example it is clearly shown that sprite could be animated by increasing x / y axis. But if i want to move something quickly then i need to increment it by a big number (like 10 or 20) that creates ugly "jumping" effect. Is that the best i can do with pixi ? Also changing sprite texture to make walking animation (for example), can someone show me example of it
  4. Hi, i trying to do exacly the same think as posted here: But, using json textures on object that extends PIXI.sprite public cropTexture(x?: number, y?: number, width?: number, height?: number): void { let croppedTexture = new PIXI.Texture(this.texture.baseTexture, new PIXI.Rectangle(x, y, width, height)); this.texture = croppedTexture; } And the problem is, that this.texture.baseTexture is whole textureset (json) not just texture of this sprite. How to crop sprite that have texture from textureset (json) ?
  5. That's kind of working. There is just problem with positioning. How does scale affect position ?
  6. Hi, i trying to implement different resizing styles for different containers. Right now i have to choose between: public height: number = window.innerWidth; public width: number = window.innerHeight; (Keep position of sprites / resize them exacly as window is resizes) = this.height + "px"; = this.width + "px"; and (Keep sprites where they are, do not move them) this.renderer.resize(this.width, this.height); But how can i achieve first effect on one Container and second on other Container in the same renderer ?
  7. Hi, Is there any function for relative sprite height / width (%) ? I need sprite with 50% height of stage, now i keep tracking height of root stage and re-calculate height's. Is there better way to do it ? Like: stage{ position:relative; } sprite{ position:absolute; height:50%; width:100%; }
  8. Thanks for explanation. I have managed to fix everything on my own. I using RGBA8888 width .png image - i guess that is not supported by firefox. What format do you recommend to use ?
  9. Hi, i successfully made simple code that creates sprite and adds it to root stage. But i keep getting errors in console: What do they mean, and how to fix them ?
  10. All depend how developer made game, you cannot just say "it is slow" without specifying what game and how its made and expect someone to tell you why. Pixi is just tool in the hand of developer.
  11. Ok, and if i would like to make json myself (yes, i know that it is not practical): "frames" meaning that there is more then one texture, right ? But what is the point of it when spritesheet always contains more then one texture. Do i always need to put it in json file ? Then there is naming, how can i get that texture from loader, do i need to get full path or just "img1.png". And at the end there is "meta", is that actually used by pixi ? Looks like just bunch of crap added by program for advertise. Well, technically scale and size could be use some way but what about smartupdate ?
  12. Hi, i trying to find out in what format json spritesheet should be loaded. And how to do it properly. I have seen tons of examples but all on old version of pixi. In documentation i found function, but there is nothing about structure of json. Can anyone show me valid spritesheet json with example of how to properly load it to Pixi 4.4.3 ?
  13. Fovi

    Couple basic questions

    Thanks for fast replay. One last question: What's the proper way of making complex animated sprites ? I thinking about user character for example. Where he can wear different hair depend of stat of the game. His head moves, meaning that i have to animate hair with whole base. The way i was thinking to solve this is to make two textures one that will contains player base and second one with hair. Just overlap each other and animate them synchronously. This way hair will be where they should be. What do you think about that ? Btw. i want make that sprite on the fly, not pre-made textures with different hair. That's because if we will add possibility to change shirt and let's say boots suddenly we will end up with insane amount of combinations.
  14. Hi, I made socket-server in C# and now i working on client. But I'm new to whole HTML5 graphic idea and i do not quite understand couple standards. Sprites animation: Is there an function to animate sprite (if so, how could i use it) ? Or do i need to make that function myself. ( If so, what is the best way ? Is that just function that will change sprite texture every couple frames ? ) Tile-map view: I found out that pixi still renders tiles that are not in point of view. Meaning that i have to check it myself. I found couple people saying that best way is to change visibility of tile, but is that enough ? What if there is gonna be 90k of tiles that are hidden, will it affect speed ? Isn't it better to remove them totally ? Tile-map construction: Is tile-map just and X sprites next to each other ? Em i understand it correctly ? (meaning everything in game is just sprites with texture on it) Collisions: Is pixi have some build-in function for collisions ? I would be thankful for easy to understand explanation, like i mentioned i new in graphic world.