KINGx - Das inoffizielle PlayStation Forum & News Portal

Normale Version: [LUA] PROBLEME!
Sie sehen gerade eine vereinfachte Darstellung unserer Inhalte. Normale Ansicht mit richtiger Formatierung.
Hi Leute!
Ich bin neu hier und habe auch schon gleich eine Frage Noidea
(Ich bin Lua-Anfänger)
Ich habe ein Bild eingefügt, als Cursor. Ja, alles funzt, bloss wenn ich den Cursor bewege, dann zieht es eine weisse Spure hinter sich (Farbe vom Bild, sprich cursor siesta )
Wenn ich dann das transparency-Argument bei screen:blit(...) auf false stelle, dann tut es... Jaaah toll heul Ich will aba Transparenz OHNE dass der Cursor ne Spur hinter sich her zieht!

Hat jemand ne Lösung dafür? Danke im Vorraus Tongue

siesta
Kannst du den code Posten?
joh

Code:
...
-- pictures --
level = Image.load("images/level.png")
cursor = Image.load("images/cursor.png")
figure1 = Image.load ("images/figure1.png")

-- fonts --

-- sound --

-- anderes --
cursor_x = 50
cursor_y = 50
speed = 0.1
a = 0
b = 0
c = 0
i = 0
o = 1

while true do
pad = Controls.read()
screen:print(200, 8, "Wadabasaga!", gray)

screen:blit(0,0,level)

screen:blit(cursor_x,cursor_y,cursor,false)

-- steuerung --
if pad:left() then
cursor_x = cursor_x - speed
end

if pad:right() then
cursor_x = cursor_x + speed
end

if pad:up() then
cursor_y = cursor_y - speed
end

if pad:down() then
cursor_y = cursor_y + speed
end

if pad:cross() then
if x > 0 and x < 464 and y > 0 and y < 256 then
screen:blit(cursor_x,cursor_y,figure1,true)
end
end

-- ränder --
if cursor_x < 0 then
cursor_x = 0
end

if cursor_x > 464 then
cursor_x = 464
end
    
if cursor_y < 0 then
cursor_y = 0
end

if cursor_y > 256 then
cursor_y = 256
end

--wichtig--
screen.flip()
screen.waitVblankStart(0)
end

screen:clear() -- ja, ich habs mal mit screen:clear nach jedem schritt versucht

dies ist der code, wo ich transparenz vom bild auf FALSE hab, wos auch tut ;D ich will aba transparenz haben heul

ich kanns leider nicht testen, da der luaplayer mir ne fehlermeldung gibt bei:

Code:
if pad:cross() then
if x > 0 and x < 464 and y > 0 and y < 256 then
screen:blit(cursor_x,cursor_y,figure1,true)
end
end


dass ein then fehlt neben &.

aber an deinem code sind mir noch 2 dinge aufgefallen.

1.) hast du die farbe "gray" nicht definiert
2.) versuch mal screen:clear() nach pad = Controls.read() zu setzen, wenn du das nicht schon ausprobiert hast.

leider kann ich dir nicht helfen :/

ah hi
1) alle farben schon definiert habs vorher bloss weggelassen
2) werds mal versuchen, ka ob ichs schon versucht hatte

und lassen diesen code teil den du oben gemeldet hast, einfach weg der failt bei mir auch

code zum testen:

Code:
-- farben --
green = Color.new(0, 255, 0)
yellow = Color.new(255,255, 0)
red = Color.new(255, 0, 0)
blue = Color.new(0, 0, 255)
lightblue = Color.new(0, 0,128)
purple = Color.new(200, 0, 128)
black = Color.new(0, 0, 0)
gray = Color.new(128,128,128)
lightgray = Color.new(200,200,200)
white = Color.new(255,255,255)

-- pictures --
level = Image.load("images/level.png")
cursor = Image.load("images/cursor.png")
figure1 = Image.load ("images/figure1.png")

-- fonts --

-- sound --

-- anderes --
cursor_x = 50
cursor_y = 50
speed = 0.1
a = 0
b = 0
c = 0
i = 0
o = 1

while true do
pad = Controls.read()
screen:clear()
screen:print(200, 8, "Wadabasaga!", gray)

screen:blit(0,0,level)

screen:blit(cursor_x,cursor_y,cursor,true)

-- steuerung --
if pad:left() then
cursor_x = cursor_x - speed
end

if pad:right() then
cursor_x = cursor_x + speed
end

if pad:up() then
cursor_y = cursor_y - speed
end

if pad:down() then
cursor_y = cursor_y + speed
end

-- ränder --
if cursor_x < 0 then
cursor_x = 0
end

if cursor_x > 464 then
cursor_x = 464
end
    
if cursor_y < 0 then
cursor_y = 0
end

if cursor_y > 256 then
cursor_y = 256
end

--wichtig--
screen.flip()
screen.waitVblankStart(0)
end


EDIT:
haha, XD so funktionierts

aber ich hab noch ein problem:

Code:
if pad:cross() then
if x > 0 and x < 464 and y > 0 and y < 256 then
screen:blit(cursor_x,cursor_y,figure1,true)
end
end


ziel: wenn man mit dem cursor irgendwo AUFM bildschirm ist, dann soll man mit taste:cross ein bild erstellen lassen, bei der pos vom cursor

hab es so gemacht und es funktioniert:

Code:
-- farben --
green = Color.new(0, 255, 0)
yellow = Color.new(255,255, 0)
red = Color.new(255, 0, 0)
blue = Color.new(0, 0, 255)
lightblue = Color.new(0, 0,128)
purple = Color.new(200, 0, 128)
black = Color.new(0, 0, 0)
gray = Color.new(128,128,128)
lightgray = Color.new(200,200,200)
white = Color.new(255,255,255)

-- pictures --
level = Image.load("images/level.png")
cursor = Image.load("images/cursor.png")
figure1 = Image.load ("images/figure1.png")

-- fonts --

-- sound --

-- anderes --
cursor_x = 50
cursor_y = 50
speed = 0.1
a = 0
b = 0
c = 0
i = 0
o = 1

while true do
pad = Controls.read()
screen:clear()
screen:print(200, 8, "Wadabasaga!", gray)

screen:blit(0,0,level)

screen:blit(cursor_x,cursor_y,cursor,true)

-- steuerung --
if pad:left() then
cursor_x = cursor_x - speed
end

if pad:right() then
cursor_x = cursor_x + speed
end

if pad:up() then
cursor_y = cursor_y - speed
end

if pad:down() then
cursor_y = cursor_y + speed
end

if pad:cross() then
screen:blit(cursor_x,cursor_y,figure1,true)
end

-- ränder --
if cursor_x < 0 then
cursor_x = 0
end

if cursor_x > 464 then
cursor_x = 464
end
    
if cursor_y < 0 then
cursor_y = 0
end

if cursor_y > 256 then
cursor_y = 256
end

--wichtig--
screen.flip()
screen.waitVblankStart(0)
end


leider geht das bild wieder weg aber wenn du willst, kann man das auch noch ändern

ey thx,

zitat: leider geht das bild wieder weg aber wenn du willst, kann man das auch noch ändern
aba wie kann man das ändern?



mal ein bild^^

racer_et :
ey thx,

zitat: leider geht das bild wieder weg aber wenn du willst, kann man das auch noch ändern
aba wie kann man das ändern?


muss ich mir noch anschauen ^^

Edit: eventuell könntest du ein unsichtbares bild nehmen und das permanent zeigen lassen(sieht man ja nicht Wink)
und wenn man x drückt wird es mit dem anderem bild ersetzt

wenn dus nicht schaffst mach ich das später für dich nur habe ich grad keine zeit Smile

ich werde mal wieder SELBER schauen ;D
(anstatt die anderen es tun zu lassen)
yay das bild bleibt da wenn man einmal auf cross drückt siesta

ich hatte noch ne idee mit ner einheiten-variable. ja gemacht, aba wenn ich cross gedrückt halte, dann geht der wert immer weiter nach oben, aber ich will dass der wert der einheiten (auch wenn man cross gedrückt hält) IMMER NUR EINS nach oben geht

Code:
if pad:cross() then
figure = figure1
e = e + 1            -------------------------------- SOO NICHT ?!
end

if e > 100 then
e = 0
end


EDIT:
Hat sich erledigt, ich gebe bescheid, wenns ein neues Problem gibt Lehrer

Ok Wink
Neues Problem heul

Ich wollte Kollision machen!
Bild + Erklärung:


Code:
-- farben --
green = Color.new(0, 255, 0)
darkgreen = Color.new(0,128,0)
yellow = Color.new(255,255, 0)
red = Color.new(255, 0, 0)
blue = Color.new(0, 0, 255)
lightblue = Color.new(0, 0,128)
purple = Color.new(200, 0, 128)
black = Color.new(0, 0, 0)
gray = Color.new(128,128,128)
lightgray = Color.new(200,200,200)
white = Color.new(255,255,255)

-- pictures --
level = Image.load("images/level.png")
cursor = Image.load("images/cursor.png")
figure = Image.load("images/figure1.png")

-- fonts --

-- sound --

-- anderes --
cursor_x = 50
cursor_y = 50
speed = 2
a = 0
b = 0
c = 0
i = 0
o = 1
cg1 = 1
oldpad = Controls.read()

-- einheiten --
pos = {}
for i=1,20 do
pos[i] = {}
pos[i].x = 0
pos[i].y = 0
pos[i].s = 0.5
if cg1 > 1 then
pos[i].gravity = screen:pixel(pos[i].x+16,pos[i].y-33)

if pos[i].gravity:color(darkgreen) then
pos[i].y = pos[i].y
else
pos[i].y = pos[i].y - 1
repeat pos[i].y = pos[i].y - 1 until pos[i].gravity:color = pos[i].gravity:color(darkgreen)
end
end
end


while true do
pad = Controls.read()
screen:clear()
screen:print(200, 8, "Wadabasaga!", gray)

screen:blit(0,0,level)
screen:blit(cursor_x,cursor_y,cursor,true)

-- steuerung --
if pad:left() then
cursor_x = cursor_x - speed
end

if pad:right() then
cursor_x = cursor_x + speed
end

if pad:up() then
cursor_y = cursor_y - speed
end

if pad:down() then
cursor_y = cursor_y + speed
end

if pad:cross() and oldpad:cross() ~= pad:cross() and cg1 <= 20 then
pos[cg1].y = cursor_y
pos[cg1].x = cursor_x
cg1 = cg1 + 1
end

i=1
while i<cg1 do
screen:blit(pos[i].x,pos[i].y,figure,true)
i=i+1
end

screen:print(200,260,"i:"..i.."   "..cg1.."",lightgray)

-- ränder --
if cursor_x < 0 then
cursor_x = 0
end

if cursor_x > 464 then
cursor_x = 464
end

if cursor_y < 0 then
cursor_y = 0
end

if cursor_y > 256 then
cursor_y = 256
end

--wichtig--
oldpad = pad
screen.flip()
screen.waitVblankStart()
end


thx im vorraus siesta

schick mir mal den code als pn
hä? wie? oben steht er doch!?
aber egal...
ok
kann es sein, dass du den code bereits geschrieben hast(s. oben), aber er einfach außerhalb der Schleife steht??
Seiten: 1 2
Referenz-URLs