Android Game Recipes: A Problem-Solution Approach by Jerome Dimarzio
Author:Jerome Dimarzio [Dimarzio, Jerome]
Language: eng
Format: epub, mobi
Tags: Computers, Programming, Games, Hardware, Mobile Devices
ISBN: 9781430257646
Google: 0ipsmwEACAAJ
Amazon: 1430257644
Publisher: Apress
Published: 2013-10-23T04:00:00+00:00
7.2 Scroll the Background Horizontally
Problem
The background is currently static, and it should scroll horizontally.
Solution
Create a new class in the game loop that translates the background texture a set amount on the y axis.
How It Works
The first step in the OpenGL ES 1 version of this solution is to create two variables that will be used to track the current location of the background texture and the value by which to translate the texture, respectively.
int bgScroll1 = 0;
float SCROLL_BACKGROUND_1 = .002f;
These variables can be local to your Renderer class, or you can store them in a separate class.
The onDrawFrame() method, within an implementation of an OpenGL ES Renderer, is called on every iteration of the game loop. You need to create a new method, called scrollBackground(), that is in turn called from the onDrawFrame() method (see Listing 7-5).
Listing 7-5. scrollBackground() (OpenGL ES 1)
private void scrollBackground1(GL10 gl){
if (bgScroll1 == Float.MAX_VALUE){
bgScroll1 = 0f;
}
Download
Android Game Recipes: A Problem-Solution Approach by Jerome Dimarzio.mobi
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Deep Learning with Python by François Chollet(15444)
The Mikado Method by Ola Ellnestam Daniel Brolund(12712)
Hello! Python by Anthony Briggs(12566)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(11871)
Dependency Injection in .NET by Mark Seemann(11669)
A Developer's Guide to Building Resilient Cloud Applications with Azure by Hamida Rebai Trabelsi(10534)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(10481)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(10191)
Grails in Action by Glen Smith Peter Ledbrook(9797)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(9497)
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(9225)
Hit Refresh by Satya Nadella(9040)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(8541)
The Kubernetes Operator Framework Book by Michael Dame(8480)
Exploring Deepfakes by Bryan Lyon and Matt Tora(8301)
Robo-Advisor with Python by Aki Ranin(8256)
Practical Computer Architecture with Python and ARM by Alan Clements(8228)
Kotlin in Action by Dmitry Jemerov(8209)
Implementing Enterprise Observability for Success by Manisha Agrawal and Karun Krishnannair(8199)