These are chat archives for pixijs/pixi.js

9th
Oct 2016
Bailey Stoner
@monokrome
Oct 09 2016 22:14
It seems like you can't create multiple textures using Texture.from(anotherTexture) because it overrides the previous one when you create additional textures. Does this seem to be accurate?
I am trying to load a set of tiles in a single texture / sprite map but it doesn't seem to work as I expected... https://github.com/monokrome/ORBIS/blob/master/orbis.js#L36-L54
Ivan Popelyshev
@ivanpopelyshev
Oct 09 2016 22:17
hey
Bailey Stoner
@monokrome
Oct 09 2016 22:17
hi :)
Ivan Popelyshev
@ivanpopelyshev
Oct 09 2016 22:19
Texture.from(anotherTexture.baseTexture) will work, according to the source code
but its easier if you just call directly
Bailey Stoner
@monokrome
Oct 09 2016 22:19
Call what directly?
Ivan Popelyshev
@ivanpopelyshev
Oct 09 2016 22:19
new PIXI.Texture(anotherTexture, new Rectangle(x,y w, h));
x,y,w,h is your tile
also, if you work with tiles, https://github.com/pixijs/pixi-tilemap will work just fine
but better to use new branch, https://github.com/pixijs/pixi-tilemap/tree/dev-multitexture - it supports up to 12 base textures up to 1024x1024. Its experimental
Bailey Stoner
@monokrome
Oct 09 2016 22:20
the method without "from" doesn't seem to work
didn't know about pixi-tilemap though! That looks cool
Ivan Popelyshev
@ivanpopelyshev
Oct 09 2016 22:20
that's how "from" works itself
it must work
Bailey Stoner
@monokrome
Oct 09 2016 22:21
hmm
Ivan Popelyshev
@ivanpopelyshev
Oct 09 2016 22:21
you specify texture or baseTexture and rectangle from it
Bailey Stoner
@monokrome
Oct 09 2016 22:21
Switching to that says "An attempt was made to use an object that is not, or is no longer, usable"
oooh
never mind, I'm just dumb :)
Ivan Popelyshev
@ivanpopelyshev
Oct 09 2016 22:21
"new PIXI.Texture(anotherTexture.baseTexture, new PIXI.Rectangle(x,y,w,h));
sorry
forgot about PIXI.Rectnagle
Bailey Stoner
@monokrome
Oct 09 2016 22:21
yep lol
hmm
It worked that way!
Thanks :D
Ivan Popelyshev
@ivanpopelyshev
Oct 09 2016 22:22
also you better to create one Texture object per every rectangle you have on your tilemap
not per every Sprite
Bailey Stoner
@monokrome
Oct 09 2016 22:22
That's what I'm doing
It uses a cache :)
(or I misunderstand)
Ivan Popelyshev
@ivanpopelyshev
Oct 09 2016 22:22
pixi-tilemap works differently: you just "clear" it every time something changes, and fill with stuff
it doesnt need Sprites
Bailey Stoner
@monokrome
Oct 09 2016 22:23
I'll look into that :)
Ivan Popelyshev
@ivanpopelyshev
Oct 09 2016 22:23
also, its better to use TexturePacker or may be "ShoeBox" tool to create an atlas with json file
you can just pick rectangles from your texture, but that may cause some border artifacts when you start to zoom in/zoom out
if you dont zoom, then its ok :)
Bailey Stoner
@monokrome
Oct 09 2016 22:25
Yeah, I'm trying to fix border artifacts at the moment acutally
but only because I'm using TilingSprite, and don't want this one to tile horizontally
I guess if I don't use scaling like planned anyway, it's not an issue :)
Thanks, @ivanpopelyshev :)
Ivan Popelyshev
@ivanpopelyshev
Oct 09 2016 22:27
hm
tilingSprite will work in latest pixi, yep
in that one - pixijs.download/dev/pixi.js
i actually worked on border artifacts issue last week
also, just updated https://github.com/pixijs/pixi-tilemap/tree/dev-multitexture , please re-download it
Bailey Stoner
@monokrome
Oct 09 2016 22:31
oh cool :)
Looks like tilemap isn't in the latest release?
I'm using CDNJS still :O
Ivan Popelyshev
@ivanpopelyshev
Oct 09 2016 22:32
tilemap is separated
Bailey Stoner
@monokrome
Oct 09 2016 22:32
ah
I'll look into that then
Thanks so much :)
pixi is awesome :D
Ivan Popelyshev
@ivanpopelyshev
Oct 09 2016 22:33
oh
wait
i dont see it :)
the binary file.. hm
wait a moment, i cant find where is pixi-tilemap.js
Bailey Stoner
@monokrome
Oct 09 2016 22:34
What is the format of atlas.json? I don't think I'm familiar with that
its better to not create atlas.json by hands
Bailey Stoner
@monokrome
Oct 09 2016 22:35
Seems like black is transparent by default in PIXI? :smile:
Ivan Popelyshev
@ivanpopelyshev
Oct 09 2016 22:36
use JSON output from http://renderhjs.net/shoebox/
no, black is not transparent
Bailey Stoner
@monokrome
Oct 09 2016 22:36
hmm
seems to be transparent here, so I wonder what I did -.-
ooh, Pyxel Edit has alpha maps I bet - but they don't show in my image view
dances
Ivan Popelyshev
@ivanpopelyshev
Oct 09 2016 22:38
PIXI doesnt support alpha maps correctly, yet. Its just works with png files that have alpha
Bailey Stoner
@monokrome
Oct 09 2016 22:38
That's what I meant
alpha channel, sorry :)
Ivan Popelyshev
@ivanpopelyshev
Oct 09 2016 22:40
yeah, because some stuff required alpha maps
for example when you want to use JPG :)
and its only in a roadmap, not yet ready
Bailey Stoner
@monokrome
Oct 09 2016 22:41
cool
I was just wondering why it was working :)
I wonder if the format exported from Pyxel Edit is similar to the ShoeBox one
Ivan Popelyshev
@ivanpopelyshev
Oct 09 2016 22:42
it must be JSON HASH
Bailey Stoner
@monokrome
Oct 09 2016 22:42
ah
similar
Ivan Popelyshev
@ivanpopelyshev
Oct 09 2016 22:42
may be different though
Thanks for all the help! :)
Ivan Popelyshev
@ivanpopelyshev
Oct 09 2016 22:43
you can make your own loader later, like https://github.com/pixijs/pixi.js/blob/master/src/loaders/spritesheetParser.js , but right now its better to create textures manually
also i see "rot" param, is that rotation?
if you want to flip or rotate, use "texture.rotate" param
Bailey Stoner
@monokrome
Oct 09 2016 22:45
It is, but I don't use it :D
Downloading AIR for Shoebox
Ivan Popelyshev
@ivanpopelyshev
Oct 09 2016 22:45
basically, you can rotate/flip any texture
that's better than doing sprite.scale.x = -1 stuff
Bailey Stoner
@monokrome
Oct 09 2016 22:47
sounds good :)
Bailey Stoner
@monokrome
Oct 09 2016 23:59
This may be a weird question, but is there a way to randomize the textures that tile in a sprite?