2011-09-02 43 views
0

我不是一個程序員,甚至是業餘愛好者,我只是想要一個能夠儘可能快地改變PSP屏幕(整體)顏色的程序。我做了些什麼:Lua - 快速變化的圖像

rdupa = Image.load("red.png") 
gdupa = Image.load("green.png") 
bdupa = Image.load("blue.png") 
screen:clear() 
while true do 
screen:blit(0, 0, rdupa, false) 
screen:clear() 
screen:blit(0, 0, gdupa, false) 
screen:clear() 
screen:blit(0, 0, bdupa, false) 
screen:clear() 
end 

使用谷歌,但這不起作用。我做錯了什麼(我在腳本所在的文件夾中有* .png圖片)?準備好的腳本會很好地被看到。

+1

* Lua *,而不是* LUA *。 – lhf

+1

也許你應該告訴我們你使用的是什麼,它允許你在PSP上運行Lua代碼。 –

回答

0

我不確定你的環境,但我猜想它最有可能無法更新其主窗口或任何因爲它本質上卡住執行剪斷的Lua代碼(除非它是在單獨的線程中執行的)。

0

Lua是一種小巧簡潔的編程語言,僅提供少量核心功能(請參閱this list)。

Lua沒有提供任何默認使用屏幕和圖像的功能,所以不知道您使用的是什麼庫/框架,我們很難做出幫助。

0

對於這個答案,我假設你正在使用Lua Player(考慮添加一個luaplayer標籤?)。從我可以在documentation看,每當你想更新屏幕,你應該使用的

screen.flip() 

代替

screen:clear() 

。不幸的是,我的PSP上沒有CFW,所以我無法親自測試。

0

說實話,我甚至不會考慮使用圖像。

這樣的事情會做:)

(這是使用PGELua,但可以很容易地適應LuaPlayer)

while pge.running() do 
    color = pge.gfx.createcolor(pge.math.rand(255),pge.math.rand(255),pge.math.rand(255)) 
    pge.gfx.startdrawing() 
    pge.gfx.drawrect(0,0,480,272,color) 
    pge.gfx.enddrawing() 
    pge.gfx.swapbuffers() 
end 
如果你想定義的顏色

,也許有點像。

red = pge.gfx.createcolor(255,0,0) 
gre = pge.gfx.createcolor(0,255,0) 
blu = pge.gfx.createcolor(0,0,255) 
loop = 1 
while pge.running() do 
    pge.gfx.startdrawing() 
    if loop==1 then 
     pge.gfx.drawrect(0,0,480,272,red) 
    elseif loop==2 then 
     pge.gfx.drawrect(0,0,480,272,gre) 
    elseif loop==3 then 
     pge.gfx.drawrect(0,0,480,272,blu) 
    end 
    loop=loop+1 
    if loop>4 then 
     loop=1 
    end 
    pge.gfx.enddrawing() 
    pge.gfx.swapbuffers() 
end