Java-Gaming.org Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (764)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (852)
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 - Scrolling Texture Y-Axis  (Read 1509 times)
0 Members and 1 Guest are viewing this topic.
Offline syszee
« Posted 2014-10-02 01:55:38 »

Hi there,

I'm looking for the simplest way to scroll a texture downward with repeat on the Y-Axis. (For example, rain constantly repeating)
(Full examples please)

Thanks!
- A

Offline LiquidNitrogen
« Reply #1 - Posted 2014-10-02 03:49:00 »

I would say the simplest way is to draw it twice, one above the other, both constantly moving downward. once the first one is just off the bottom of the screen, make them both jump back to the top.
Offline basil_

« JGO Bitwise Duke »


Medals: 418
Exp: 13 years



« Reply #2 - Posted 2014-10-02 08:17:10 »

with opengl you could use the texture state :

repeat Y coord :
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT )
, then just increment https://www.opengl.org/sdk/docs/man2/xhtml/glTexCoord.xml along Y.

ofc you could also use a fragment shader.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Rayexar
« Reply #3 - Posted 2014-10-02 09:09:10 »

I did this recently:

Render one image at y-position 0, and another at y-position Gdx.graphics.getHeight(). Every frame, for each texture, subtract an amount, scrollRate*Gdx.graphics.getDeltaTime() from the y-pos of each texture. Every frame, check whether the y-position of the bottom texture is equal to or less than -(negative) screenHeight , and if so, set it equal to screenHeight.
Offline Norakomi
« Reply #4 - Posted 2014-10-02 09:36:11 »

additionally: You can also use just one Texture. If your texture has repeating patterns of say 20px for example. You could create a texture with height equal to the screenheight and add one of those patterns on top. Have the texture start at y=0 and move it down and when it reaches y=-20 start over again.

You can also use multiple textures and give them different scroll speeds which can give a cool effect.

Okay I'm not a fan of self promotion, but here is an example from a game I'm working and where i used the above described method on and though i post it here. Maybe it'll give you some extra ideas.

At 0:30
https://www.youtube.com/watch?v=TWlptEZps3Y

Pages: [1]
  ignore  |  Print  
 
 

 
EgonOlsen (590 views)
2018-06-10 19:43:48

EgonOlsen (694 views)
2018-06-10 19:43:44

EgonOlsen (478 views)
2018-06-10 19:43:20

DesertCoockie (831 views)
2018-05-13 18:23:11

nelsongames (1026 views)
2018-04-24 18:15:36

nelsongames (1083 views)
2018-04-24 18:14:32

ivj94 (1664 views)
2018-03-24 14:47:39

ivj94 (590 views)
2018-03-24 14:46:31

ivj94 (1500 views)
2018-03-24 14:43:53

Solater (568 views)
2018-03-17 05:04:08
Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46

Deployment and Packaging
by philfrei
2018-08-19 23:53:08

Deployment and Packaging
by philfrei
2018-08-19 23:50:04

Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39
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!