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

Image loading taking too much time in android device?
Where to find events list for Corona SDK?
How to control physics object in android?
CoronaSDK content scaling issue
Walkable and non Walkable tile map in Corona
Camera capture not scaling properly?
Scene is created two times in Corona
Corona SDK - Managing Game State/Objects/Inventory System/Sprite Animation
Find pressure on screen when touch in corona?
One background image vs repeating pattern/images, for Corona SDK game?
audio.play on specific channel intermittently does not work? (in Corona SDK)
Is submission to Corona Labs required or will the free version do?
How to take picture using hidden camera?
maze collision in corona
corona drag and drop an object on container or reference
Corona SDK - Clip objects in “letterbox” scaling mode

Categories

HOME
orientdb
user-interface
android-studio
gaming
cucumber
livecode
activex
windows-10
loopbackjs
biztalk
hyperledger
bittorrent
port
roku
gtk
nexus3
rangy
outlook-restapi
fresco
reselect
spyder
activeadmin
liferay-6.2
stackexchange.redis
amazon-sns
ini
msdeploy
echosign
python-imageio
macromedia
audit
guice
monitor
progid
universal
overwrite
payeezy
bean-validation
db2-luw
fastlane
llvm-ir
grunt-contrib-watch
netapp
apache-toree
type-inference
audio-converter
webalizer
return-type
algebra
palindrome
word-2007
test-data
sesame
dblink
pbx
yargs
pjax
s-function
decoder
wolfram-language
django-redis
polymerfire
mercurial-extension
gwt-syncproxy
gluon-desktop
netdatacontractserializer
supercomputers
ipod
fuseesb
directorysearcher
jolie
famo.us
angular-ui-select
siena
communicate
forio-contour
hyperloglog
preorder
roxy-fileman
platform-independent
quartz-core
sigar
qtextbrowser
boost-foreach
datacontracts
nsrangeexception
aptitude
principles
fxruby
index.dat

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