corona


Create moving background vertically - Corona SDK


I am working on a car racing game and one of the things I am trying to achieve is to ensure that the background image moves vertically infinitely while at the same time when you touch the background, it changes the car's lanes.
function scene:create( event )
physics.start();
physics.setGravity(0, 0);
local group = self.view;
local bg = display.newImageRect(group, "IMG/bg.png", 384, totalHeight);
bg.x, bg.y = centerX, centerY;
function bg:touch(event)
if event.phase == "began" then
if event.x < centerX then
redCar:changeLane();
else
blueCar:changeLane();
end
end
end
bg:addEventListener("touch", bg);
end
I have tried different articles online but none works well. Any guide would be appreciated. Thanks
Here is the code to make a vertical scrolling background:
local function moveBg(dt)
bg1.y = bg1.y + scrollSpeed * dt
bg2.y = bg2.y + scrollSpeed * dt
if (bg1.y - display.contentHeight/2) > display.actualContentHeight then
bg1:translate(0, -bg1.contentHeight * 2)
end
if (bg2.y - display.contentHeight/2) > display.actualContentHeight then
bg2:translate(0, -bg2.contentHeight * 2)
end
end
And the complete tutorial is here: http://lomza.totem-soft.com/tutorial-scrollable-background-in-corona-sdk/

Related Links

Drop Down animation for Image on Tap
Sound is not working properly in Corona SDK
How can i properly align Arabic text using the Corona SDK?
Can we change physics body properties in runtime - corona sdk
How to slide pages in Corona SDK
Return Data on showwebpopup
How to pause game and display new layer in corona
Corona SDK pathToFile issue
How to integrate fortumo In-App purchase plugin to Corona Sdk game?
How to make the PNG's transparent region not be listened by the EventListener when a touch event happened?
Corona SDK - group with image rect, wrong reference point
CORONA SDK Physics that dont affect every sprite
corona storyboard dispatch event error
Web view Background trasparency
Changing display Image when interacting to other display
Tap on display objects in Corona SDK

Categories

HOME
list
openxml
couchdb
stacktrace.js
dafny
initialization
typeerror
autocomplete
elisp
native-base
phpseclib
sharepoint-online
azure-logic-apps
siesta
heuristics
parsley.js
mahout-recommender
corona
nest-api
l20n
asciimath
scala-ide
gmp
cloudsim
http-authentication
scheduled-tasks
spyder
opam
libgit2
node-webkit
sybase-ase
chronicle-queue
jstree
web-push
unordered-multimap
pubxml
prompt
php-5.3
cube
tsung
nic
vcenter
directfb
busboy
jfxtras
numerics
netstat
ms-solver-foundation
macports
tidal-scheduler
ejml
robust
google-prediction
web-inspector
morphline
sonarqube5.2
return-type
non-linear-regression
winmerge
nslayoutconstraint
nivo-slider
portal
pjax
msg
livecycle
yii2-model
odp.net-managed
simian
exists
processor
openmrs
onepage-checkout
myfaces
pack
servicestack-bsd
godeps
espresso
ngcordova
modern.ie
swagger-maven-plugin
darwin
alwayson
explain
erlog
deque
debug-symbols
maven-shade-plugin
tkx
cakephp-2.2
device-admin
image-rotation
multivariate-testing
windows-rt
object-code
jquery-mobile-flipswitch
jini
incognito-mode
miglayout
wso2bam
roxy-fileman
unrealscript
jquery-transit
django-facebook
hints
pacman
void-pointers
email-verification
multiscaleimage
daap
pageheap
winsxs
powergui

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App