player:width should be player:width() :PZitat:
Hmm... But can anyone help me out with that error? My code is on the page before this. (And the reason that segment of code is there is to prevent the character from going offscreen when I move him)
Printable View
player:width should be player:width() :PZitat:
Hmm... But can anyone help me out with that error? My code is on the page before this. (And the reason that segment of code is there is to prevent the character from going offscreen when I move him)
hey guys! How do you make a picture overlap another picture? I have a normal picture and when you press a button the old picture is supposed to dissapear and a new one come. help please!
Try that.Code:black=Color.new(0, 0, 0)
player={}
player[1]={x=240, y=250}
screenwidth=480 - player:width()
while true do
screen:blit(0, 0, background, false)
screen:blit(player[1].x,player[1].y,player)
for a=0,10 do
screen:blit(45*a, 45*b, spike)
end
for b=0,0 do
screen:blit(45*a, 45*b, spike)
end
pad = Controls.read()
screen:clear()
if pad:left() then
player[1].x = player.x - 2
end
if pad:right() then
player[1].x = player.x + 2
end
screen.waitVblankStart()
screen.flip()
end
make some variables at the beginning of your program to store the images.
myImage = Image.load("yeahyeah.png" )
newImage = Image.load("newimage.png" )
in your code for your x button use something like
if pad:cross() then myImage = newImage end
make sure your blitting command is outside of the pad:cross() statement
ex... screen:blit(100,100,myIma ge)
I think he did in his loading screen scipt, otherwise where would "player" come from in the second screen:blit? Either that or there is some made up image loading names going around here.
thanks but I ran into a problem. When I run it and press the button, the top of the old image flickers at the top of the new image. Help please! Oh and how do you make it so the old image reappears when you let go of the button?Zitat:
Zitat von PSPMillionaire
to make it reappear put your blit command inside your pad:cross statement
could make these variables at the top of your code, or use the last, i forgot them lol..
imageOne = Image.load("whatever.png" )
imageTwo = Image.load("whatever.png" )
then your pad:cross() could look like so..
if pad:cross() then
screen:blit(100,100,image One)
else
screen:blit(100,100,image Two)
end
make sure you use screen:clear() in your while true do loop, right after it starts is a good place.
sorry I'm just learning to code. I need to put a while true statement? Can you show me waht you mean please?Zitat:
Zitat von PSPMillionaire
however your programming is looping, put the screen:clear() in the loop.
paste your code if you want, and still dont understand
mind if I PM it to you? I don't want anyone stealing my idea...Zitat:
Zitat von PSPMillionaire