[COLOR="DarkRed"]post ur code...[/CKLOR]
hi im learning lua, but i need to find how to make and image scroll and repeat. please any1 who knows how HELP ME!
lol y.
all i needed to know was the function to scoll. which i found
Something like
if player.x>50 then
bg.x=bg.x-2
end
yea i figured that out thanks
ok it scrolls fine but i how do i make the picture repeat.
cause right now it just scrolls and leaves black
Im not to sure how to due that but I would either but more than one background image( makes it alot harder to make background scroll ) or just have one really huge background image.
yea i just have it set so that there are like 10 background images in a line and the just all scroll like that. but after all 10 have scrolled past im left with black. i could just make like 1000 background varialbes but thats kinda the half ass way. im sure theres a better way
the psp screen in 480x272 - when drawing outside that area to the right or to the left, it goes to a max of -480 and -272, to create a continuous scroll of a single image do this
set a varable as an x offset:
X_offset = 0
Blit the three images:
screen:blit(-480+X_offset, 0, image)
screen:blit(X_offset, 0, image)
screen:blit(480+X_offset, 0, image)
when the player is moving left do this:
X_offset = X_offset - 1
if X_offset < -480 then X_offset = 0 end
when moving right, use the same thing only do a +1 instead of a -1, and set it to check if it's >480
if you want to make it srcroll up and down instead, do the same except use a Y offset instead of an X
Try this:
BG = Image.load("Bg2.png")
slide = {}
slide[1] = { x = 0, y = 0, pic = BG }
slide[2] = { x = -480, y = 0, pic = BG }
slide[3] = { x = -960, y = 0, pic = BG }
for blit_slides = 1,2 do
screen:blit(slide[blit_slides].x, slide[blit_slides].y, slide[blit_slides].pic)
oldslidesx = slide[blit_slides].x
end
for repeat_slides = 1, 2 do
if slide[repeat_slides].x > 480 then
slide[repeat_slides].x = -480
end
end
for repeat_slides = 1, 2 do
if slide[repeat_slides].x < -480 then
slide[repeat_slides].x = 480
end
Taken from my unreleased "Pokemon : Ditto's Quest".
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks