Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (109)
games submitted by our members
Games in WIP (536)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  [LibGDX] Resize Texture for use with TextureRegion  (Read 2117 times)
0 Members and 1 Guest are viewing this topic.
Offline Slyntax

Junior Member


Medals: 3



« Posted 2013-03-27 03:17:09 »

I want to resize a texture before sending it to be chopped up by TextureRegion.

Is this possible?

I've already tried using Sprites and that didn't work and I'm really not sure where else to look. It's probably something simple I'm just missing.

Note: I'm aware I can do this in an external program but I want my game to be able to do this on the fly.
Offline ReBirth
« Reply #1 - Posted 2013-03-27 03:21:40 »

I rarely use Texture now. I get a Drawable from atlas and scale it freely with setWidth(), setHeight(), scale(), or setScale().

Offline Slyntax

Junior Member


Medals: 3



« Reply #2 - Posted 2013-03-27 03:34:53 »

Resizing the texture on the screen isn't the problem. TextureRegion using the textures native resolution is my problem.

Let's say I have a texture that's 100x100 but I need it to be 50x50 for use with TextureRegion. I need to resize the native resolution to 50x50 before sending it to be cut into pieces by TextureRegion.

For further clarification I'm splitting up a single picture into many little pictures that make up the main picture. I'm making a puzzle type game.

The pictures all need to be a certain resolution for the game to work correctly.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline pitbuller
« Reply #3 - Posted 2013-03-27 09:46:52 »

Resizing the texture on the screen isn't the problem. TextureRegion using the textures native resolution is my problem.

Let's say I have a texture that's 100x100 but I need it to be 50x50 for use with TextureRegion. I need to resize the native resolution to 50x50 before sending it to be cut into pieces by TextureRegion.

For further clarification I'm splitting up a single picture into many little pictures that make up the main picture. I'm making a puzzle type game.

The pictures all need to be a certain resolution for the game to work correctly.

Then you have logic problem if TextureRegion size dictate the code flow.

Just think about it little. Texture is nothing more than 2d array of bytes at gpu memory. This 2d array have size and those bytes are interpreted as colors usually. You can pretty much use this data how you want.
TextureRregion is just helper class that has texture as reference and texture coordinates that describe rectangle shaped portion of that original texture. So textureRegion does no split anything it just have additional texture coordinates.

So what you want to achieve?
Offline Slyntax

Junior Member


Medals: 3



« Reply #4 - Posted 2013-03-27 09:49:16 »

You have a good point. I was looking at this wrong. Instead of downsizing the image I can just increase the tile size based on the texture resolution and then downsize the sprite that holds the tile so it will work with any size image..

Thank you, sir.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

CogWheelz (18 views)
2014-07-30 21:08:39

Riven (27 views)
2014-07-29 18:09:19

Riven (16 views)
2014-07-29 18:08:52

Dwinin (14 views)
2014-07-29 10:59:34

E.R. Fleming (35 views)
2014-07-29 03:07:13

E.R. Fleming (13 views)
2014-07-29 03:06:25

pw (44 views)
2014-07-24 01:59:36

Riven (44 views)
2014-07-23 21:16:32

Riven (30 views)
2014-07-23 21:07:15

Riven (31 views)
2014-07-23 20:56:16
List of Learning Resources
by SilverTiger
2014-07-31 18:29:50

List of Learning Resources
by SilverTiger
2014-07-31 18:26:06

List of Learning Resources
by SilverTiger
2014-07-31 13:54:12

HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!