pixelDimension for PackedSprite?

This is the place to find out how to accomplish something specific with SM2.

pixelDimension for PackedSprite?

Postby hima » Mon Mar 14, 2011 3:54 am

I just noticed that only Sprite class has a pixelDimension vector2d. Is there a way to get that information for a PackedSprite?
Posts: 37
Joined: Mon Jan 03, 2011 2:25 pm

Re: pixelDimension for PackedSprite?

Postby Brady » Mon Mar 14, 2011 4:06 am

Actually, pixelDimensions are the dimensions of the sprite on the atlas. It's part of the information you fill out in the inspector to setup the sprite. If you want to know how big a sprite's graphic is in the atlas, I suppose you could get that by getting the UVs, looking at the width and height of the UV rect, and then multiplying that by the number of pixels per-UV (which is basically 1 divided by the texture width or height, depending on the axis). There's a "pixelsPerUV" member in SpriteRoot you could use for the calculation.
Posts: 5361
Joined: Tue Jul 06, 2010 11:33 pm

Re: pixelDimension for PackedSprite?

Postby hima » Mon Mar 14, 2011 4:19 am

Thanks for the quick reply, Brady. I'll try calculating it with the method you suggested. One question though, why does Sprite class is the only class that has this and not the others? I think it's a pretty important attribute, so I'm just wondering the reasoning behind the decision :)
Posts: 37
Joined: Mon Jan 03, 2011 2:25 pm

Re: pixelDimension for PackedSprite?

Postby Brady » Mon Mar 14, 2011 4:24 am

I'm not sure if there may be a misunderstanding as to what it's for, but the Sprite class you have to have a pre-made atlas and tell it where on the atlas the image you want is. That involves specifying the lower-left pixel coordinate, and then the width and height on the atlas. The latter is what the pixelDimensions is for. This isn't needed on PackedSprite since you just drag the textures you want onto the timeline and it's all automatic from there.
Posts: 5361
Joined: Tue Jul 06, 2010 11:33 pm

Re: pixelDimension for PackedSprite?

Postby hima » Mon Mar 14, 2011 5:31 am

I see. But I think it might be useful even if it's a read-only attribute. For instance, the shooting game that I make, I need to know when the bullet leave the screen. The sprite pixel width and height is important in this case since bullet sprites come with many sizes.
Posts: 37
Joined: Mon Jan 03, 2011 2:25 pm

Re: pixelDimension for PackedSprite?

Postby Brady » Mon Mar 14, 2011 5:39 am

I see. But couldn't you check the position +/- the height or width? That would avoid having to translate the position into screen space first.
Posts: 5361
Joined: Tue Jul 06, 2010 11:33 pm

Re: pixelDimension for PackedSprite?

Postby hima » Mon Mar 14, 2011 5:52 am

Hmmm, for some reason, the position is already in screen space to me...maybe because I use pixel perfect for all the sprites. Anyway, I tried your method and got it to work correctly now :) Thanks! ( I tried width and height before, but it looks wrong )
[EDITED] Never mind, I found that I did translate the position to screen position first >_<; But it's easier to understand for me...at least for now.
Posts: 37
Joined: Mon Jan 03, 2011 2:25 pm

Re: pixelDimension for PackedSprite?

Postby Brady » Mon Mar 14, 2011 8:27 am

Don't forget that if you're using an orthographic camera, you can set its ortho size to 1/2 the screen height in pixels, and that will cause there to be 1 screen pixel for every 1 world unit of space. So effectively, the width/height of a sprite (assuming it hasn't been scaled) will be the same as its pixel dimensions. And its position in the game world correlates to its screen position. In other words, if you move 1 world unit to the right, it moves 1 pixel to the right on-screen.
Posts: 5361
Joined: Tue Jul 06, 2010 11:33 pm

Postby czwen » Fri Dec 02, 2016 12:41 pm

coach factory outlet online
stan smith adidas
adidas superstar
adidas superstars
adidas nmd r1
adidas nmd runner
adidas nmd r1
adidas nmd runner
adidas yeezy boost 350
yeezy boost
adidas yeezy boost
yeezy shoes
cheap jerseys wholesale
cheap nfl jerseys
coach outlet online
coach factory outlet online
michael kors outlet sale
michael kors handbags
mlb jerseys
mlb jerseys
cheap air max
air max outlet
louboutin outlet
louboutin sale
yeezy boost
adidas nmd runner
michael kors outlet clearance
michael kors outlet store
coach outlet online
coach factory outlet online
discount nike shoes
cheap nike sneakers
coach outlet online
coach factory outlet online
hollister clothing store
hollister co
red bottom shoes
cheap bottom shoes
cheap ray bans
air max 90
louis vuitton outlet online
north face outlet
coach outlet store online
michael kors outlet online
michael kors outlet store
james shoes
lebron shoes 
birkenstock uk
cheap jordan shoes
air jordans
nike flyknit
nike free 4.0 flyknit
timberland outlet
timberland shoes
pandora outlet
pandora charms
abercrombie outlet
kobe bryant shoes
polo ralph lauren outlet
polo ralph lauren outlet online
true religion sale
true religion uk
rolex watches for sale
Replica Rolex
michael kors uk
kate spade uk
kate spade bags
louis vuitton uk
louis vuitton purse
hollister uk
christian louboutin uk
louboutin shoes
north face jackets
north face uk
true religion jeans outlet
true religion outlet store
true religion outlet store
cheap jordan shoes
dolce and gabbana outlet online
hugo boss outlet online
hugo boss suits
pandora charms sale clearance
rolex watches
toms outlet store
michael kors handbags outlet
kate spade outlet online
canada goose outlet
canada goose outlet
ugg sale
christian louboutin outlet
longchamp bag
longchamp handbags
michael kors bags
michael kors
moncler outlet online
moncler jackets
moncler jackets
ugg australia
Posts: 64
Joined: Fri Dec 02, 2016 8:57 am


Postby hhcg » Tue Dec 06, 2016 6:14 am

Lebron 13
Moncler Jacket Womens
adidas schoenen
nike sportschuhe damen
Jordan Schoenen
cheap uggs for women
air jordan
vans shoe store
zapatillas nike baratas
botas de futbol
Bottes Ugg Pas Cher
chaussures de foot pas cher
australia uggs outlet
womens nike air max
Ugg Femme Pas Cher
Moncler Outlet Online
ugg boots for women
Air Jordan Release Date
pandora rings
cheap uggs
nike air
zapatos de futbol nike
reebok running shoes
Canada Goose Outlet
pandora outlet store
portafoglio michael kors
canada goose jacket outlet
nike free
new yeezy shoes
louboutin heels
ugg boots outlet online
Nike Air Max 90
coach factory outlet online
adidas outlet stores online
uggs for cheap
nfl store
nike sb stefan janoski
Doudoune Femme Pas Cher
canada goose jackets on sale
Nike Air Max Cheap
Michael Kors handbag discount
Ray ban sale online
Moncler Sale
moncler jacket sale
air force one pas cher
Nike Store
adidas kläder
nike damenschuhe
adidas outlet
sac a main michael kors
uggs outlet
pandora charm bracelet sale
Jordan Store
cheap real uggs
Pandora Official Website
cheap christian louboutin
Air Huarache
Moncler Soldes
ugg boots cheap
Orecchini Pandora
goedkope nike air max
Coach Bags On Sale
Veste Moncler Pas Cher
Uggs Outlet Store
Nike Black Friday
australia uggs outlet
Chaussure Nike Pas Cher
Pandora Beads And Charms
Boty Nike Air
adidas store
Uggs Pas Cher Soldes
Ugg Boots On Clearance
Veste Moncler Femme
Toms Shoes For Women
ugg outlet online
Canada Goose Sale Outlet
hyperdunk 2014
new jordan releases
tru religion jeans
retro jordans for cheap
Oakley Outlet
prada outlet
billige nike sko
Air Jordan News
Air Max 90
Toms Outlet Online
canada goose coats
cheap air max outlet
Soldes Ugg
moncler girls
ugg boots classic
pandora jewelry store
Doudoune Moncler Pas Cher
Nike Online Store
Doudoune Moncler Site Officiel
nike joggesko
michael kors bags outlet
nike mercurial soccer cleats
Ugg Button
Cheap Michael Kors
Nike Air Jordan 11
Ugg Noir Pas Cher
ugg factory outlet
canada goose sale online
nike sneakers
chaussures nike pas cher
Ugg boots Sale
ugg clearance
Canada Goose Outlet Store
Doudoune Moncler Solde
michael kors handbags on sale
Canada Goose Womens Coats
Uomo Hogan
hogan rebel donna
Moncler Store
nike sportschuhe
Womens Ugg Boots
Anelli Pandora
Timberland skor
nike chaussures
scarpe hogan outlet
Michael Kors handbag on sale
Michael Kors
Canada Goose Official Site
religion store
Ugg Pas Cher Femme
moncler coats for women
ray ban wayfarer eyeglasses
Chestnut Ugg Boots
hogan scontate
nike jordan shoes
nike tn pas cher
Negozi Pandora
toms sale
Oakley Sunglasses Cheap
Adidas Shoes Discount Marketplace
Ugg Classic Tall
chaussure Nike homme
Sneakers Nike
Nike Zapatos
Canada Goose Outlet
nike boty dámské
pandora bracelet charms
nike schuhe günstig
Doudoune Femme Pas Cher
nike air jordan pas cher
oakley sunglasses clearance
Stone Island Outlet
chaussure basket homme
moncler outlet
pandora beads
canada goose online store
Original Ugg Boots
nike air max running shoes
Canada Goose Coats For Men
Boutique Ugg
Soccer Boots Outlet nike
Sheepskin Ugg Boots
pandora online
nike air schuhe herren
cheap nike air max
zapatillas running
běžecké boty nike
converse store
scarpe nike
uggs for women
longchamp tote bag
new pandora charms
Jordan Sneakers For Sale
Ugg Homme Pas cher
longchamp bags on sale
zapatilla adidas
Ugg Grise Pas Cher
fitflops sale uk
Doudoune Moncler Pas Cher
nike shoes
Ugg Outlet Online Store
abercrombie and fitch store
newest lebron shoes
huarache sneakers
Bottes Ugg Femme Pas Cher
christian louboutin outlet
Botte Ugg Femme
official NHL jerseys
Cheap Stone Island Jackets
Nike Factory Store
toms shoes outlet
canada goose jackets for women
23 is back
sac coach soldes
ugg store
Jordan Future
hhcg 12.6
Posts: 164
Joined: Sun Nov 20, 2016 1:47 am


Return to SM2 How to...

Who is online

Users browsing this forum: No registered users and 4 guests