if you want to display an image without pressing a button you just do EG
screen:clear()
background = Image.load("background.png")
and it should display the image and of course blit it at the bottom
i have question about lua on psp
i want to print a image to the screen if no button is pressed not always just if no button is pressed
kind like this:
if pad:nil() then
screen:blit(............)
nil is if no button is pressed but that doesnt work
if you want to display an image without pressing a button you just do EG
screen:clear()
background = Image.load("background.png")
and it should display the image and of course blit it at the bottom
Benh = Coder, main language C other language LUA
Check out my first C app Super - flasher here
visit my dev site where you can download all of my coding projects - http://benh-pspdev.bravehost.com/
Please visit my site www.pspfanatic.bravehost.com
and join the forums
You have to set a flag when a button is pressed
nil() is not a function of the object pad. That is why pad:nil() doesn't work.IsButtonPressed = false
if pad:cross() then
IsButtonPressed = true
-- Do whatever happens when a button is pressed
end
if pad:square() then
IsButtonPressed = true
-- Do whatever happens when a button is pressed
end
-- etc
if not IsButtonPressed then
screen:blit(............)
end
I think you are looking for this:
"Controls.read():buttons()" returns 0 if no button pressed
--begin example
lastpad = nil;
pic = Image.load("a.png");
while (not Controls.read():start()) do
pad = Controls.read();
--shows the pic if no button pressed
--and a black screen if pressed
if (pad:buttons() == 0) then
screen:blit(0,0,pic);
else
screen:clear(Color.new(0,0,0))
end
screen.waitVblankStart();
screen.flip();
lastpad = pad;
end
--end example
Nice, didn't know about that function.Originally Posted by xiringu
i used it in a example but it doesnt work:![]()
lastpad = nil;
player = Image.load("stand.png");
swordattack= Image.load("swordattackright.png");
while (not Controls.read():start()) do
pad = Controls.read();
if (pad:buttons() == 0) then
screen:blit(0,0,player);
else
screen:clear(Color.new(0,0,0))
end
if pad:cross() then
screen:blit(0,0,swordattack)
end
screen.waitVblankStart();
screen.flip();
lastpad = pad;
end
when i start it and puss cross swordattack will be blit and player will be gone but when i dont push cross swordattack stays on the screen and player.png and swordattackright.png overlaps each other. i thought maybe it works this way(didnt work swordattack wont be even blit when i push cross):
if (pad:buttons() == 0) then
screen:blit(0,0,player);
swordattack:clear()
else
screen:clear(Color.new(0,0,0))
end
This would be better in this case:
orplayer = Image.load("stand.png");
swordattack= Image.load("swordattackright.png");
while (not Controls.read():start()) do
pad = Controls.read();
screen:clear();
if pad:cross() then
screen:blit(0,0,swordattack);
else
screen:blit(0,0,player);
end
screen.waitVblankStart();
screen.flip();
end
player = Image.load("stand.png");
swordattack= Image.load("swordattackright.png");
while (not Controls.read():start()) do
pad = Controls.read();
screen:clear();
if pad:cross() then
screen:blit(0,0,swordattack);
end
if pad:buttons() == nil then
screen:blit(0,0,player);
end
screen.waitVblankStart();
screen.flip();
end
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks