Thank you very much cmbeke. That solved the issue! Now I can continue adding new functionality.
Printable View
Thank you very much cmbeke. That solved the issue! Now I can continue adding new functionality.
hI GUYS,
i want to make a NAME ENTRY!
Where a player can write his name and it should get Saved anywhere and when the player starts the game again it should show for like 5 sek his name and start then the game......
Hee is my script what have i to change to make it work???
Sry,for my bad english.....
here is my script:
Code:Bild2 = Image.load("Bild2.jpg")
white = Color.new(255,255,255)
red = Color.new(255,0,0)
characters = { "a", "b", "c", "d", "e", "f", "g",
"h", "i", "j", "k", "l", "m",
"n", "o", "p", "q", "r", "s", "t", "u", "v", "w",
"x", "y", "z", " " }
selector = Image.createEmpty(10,10)
selector:clear(red)
charX = 100
charY= 100
currentLetter = 1
currentX = 107
currentY = 98
uppercase = true
name = ""
oldpad = Controls.read()
addX = 0
addY = -10
addRow = -9
-- FUNCTION TO DRAW LETTERS
function drawLetters()
for a = 1, 3 do
addX = 0
addY = addY + 10
addRow = addRow + 9
for b = 1, 9 do
addX = addX + 10
if uppercase == false then
screen:print(charX + addX,charY + addY,
characters[b + addRow],white)
else
screen:print(charX + addX,charY + addY,
string.upper(characters[b + addRow]),white)
end
end
end
addX = 0
addY = -10
addRow = -9
end
-- END FUNCTION
-- LOOP
while true do
pad = Controls.read()
screen:clear()
screen:blit(0,0,Bild2)
if tostring(pad) == "Controls (0)" then
screen:print(10,30,tostring(Controls.read()),white)
else
screen:print(10,30,"Weiter",white)
end
screen:print(10,10,"Dein Name: "..name,white)
screen:blit(currentX,currentY, selector)
drawLetters()
-- TYPE LETTERS
if pad:cross() and oldpad:cross() ~= pad:cross() then
if uppercase == false then
name = name .. characters[currentLetter]
else
name = name .. string.upper(characters[currentLetter])
end
end
-- DELETE LETTER
if pad:square() and oldpad:square() ~= pad:square() then
name = string.sub(name, 1, string.len(name) - 1)
end
-- UPPER OR LOWER
if pad:triangle() and oldpad:triangle() ~= pad:triangle() then
if uppercase == false then
uppercase = true
else
uppercase = false
end
end
-- MOVE SELECTOR RIGHT
if pad:right() and currentLetter ~= 9 and
currentLetter ~= 18 and currentLetter ~= 27
and oldpad:right() ~= pad:right() then
currentLetter = currentLetter + 1
currentX = currentX + 10
elseif pad:right() and oldpad:right() ~= pad:right() then
if currentLetter == 9 or currentLetter == 18
or currentLetter == 27 then
currentLetter = currentLetter - 8
currentX = 107
end
end
-- MOVE SELECTOR LEFT
if pad:left() and currentLetter ~= 1 and
currentLetter ~= 10 and currentLetter ~= 19
and oldpad:left() ~= pad:left() then
currentLetter = currentLetter - 1
currentX = currentX - 10
elseif pad:left() and oldpad:left() ~= pad:left() then
if currentLetter == 1 or currentLetter == 10 or
currentLetter == 19 then
currentX = 107 + 80
currentLetter = currentLetter + 8
end
end
-- MOVE SELECTOR DOWN
if pad:down() and currentLetter < 19 and
oldpad:down() ~= pad:down() then
currentLetter = currentLetter + 9
currentY = currentY + 10
elseif pad:down() and currentLetter > 18 and
oldpad:down() ~= pad:down() then
currentY = 98
currentLetter = currentLetter - 18
end
-- MOVE SELECTOR UP
if pad:up() and currentLetter > 9 and
oldpad:up() ~= pad:up() then
currentLetter = currentLetter - 9
currentY = currentY - 10
elseif pad:up() and currentLetter < 18 and
oldpad:up() ~= pad:up() then
currentY = 118
currentLetter = currentLetter + 18
end
screen.flip()
screen.waitVblankStart()
oldpad = pad
end
I would need some guidance with Lua's (automated) memory handling. I keep loading an image, but memory runs out at some point ("Image.load: Error loading image"). I would like to free image memory, but can't figure out how.
-- this code block is repeated
myImage = nil;
collectgarbage();
myImage = Image.load(imagePath);
--
And this does not work... New memory is allocated (tested with System.getFreeMemory()). So, can I somehow force Lua to free the memory of specific image? Example would be nice.
EDIT: Found the function Image.free(imageName);
Is it possible to use Japanese OSK to write hiragana/katakana/kanji in Lua (Euphoria V8)? The following code brings only numbers:
name, result = System.osk("Name", "", System.OSK_INPUTTYPE_JAPA NESE_HIRAGANA)
Another question, which I don't find a documentation. If I want to use volume down/up, note and screen keys to trigger a function call, what are the pad commands for these (like pad:cross())?
Hello, I am using the Corona SDK software and I am having troubles with some timer coding. What my goal is in my little test game is is that I have bubbles that players will have to tap as many times as possible before they disappear. After the bubbles disappear a menu screen is supposed to appear saying "Restart" or "Main Menu". Unfortunately, I have not been able to get this to work like I have planned. I used a timer.PerformWithDelay command and it runs on a timer. My question is, should I be using the timer.PerformWithDelay command if I want the menu screen to appear after all the bubbles have disappeared? Right now the menu screen appears but it is only after a certain amount of time has passed. I am going to place the bit of code below to see if anyone can figure it out.
Code:
function fadeBubble(bubble)
local bubble = bubble
local t = counter
counter = t - 1 -- must be left as a global variable
transition.to( bubble, { time=10000, alpha=0})-- Test the delay to check the affects
timer.performWithDelay(4025, -- Test the delay to check the affects
function()
bubbleremoveSelf() -- Destroys the Bubble
if counter == 0 then -- When all the bubbles fade away display the Menu Screen
local menu = display.newImage("http://www.iphonedevsdk.com/forum/images/menu.png")
menu.x = _W/2; menu.y= _H/2
menu.scene = "menu";
function changeScene(e)
if(e.phase == "ended") then
director:changeScene(e.target.scene);
end
end
menu:addEventListener("touch", changeScene);
timer.cancel(tmr) -- Cancel the timer
end
end,
1)
end
tmr = timer.performWithDelay(timerSpeed, spawnBubble, v)
Can anyone tell me how to make a map scrolling like the one in the desert stunts game and what is the benefit of animations. Srry i am new to programming.
So im new to the forums but I have a bit of LUA experience, every time I try to run a script of my own I get an error that reads:
the U is upside down but im not sure if its an N or a U, either way there are no capital Ns or Us in my code atm, I will get back to here with the code when I canCode:Error: index(dot)lua:1: unexpected symbol near 'U'
every time I try to post it I get an error saying I cannot post links.
PSP LUA Programming - Timed Delay Needed
I am looking for a way to print a wait message on screen for a timed delay and then continue with the rest of the script
the above code does the delay, but my message does not print to the screen until after the delay, i need it before the delay but within this if statement.Code:if waittime == "1" then
screen:fontPrint(info,180,216,"Wait....",red)
screen. waitVblankStart(300) --Space added to posting restrictions thinking its a link
waittime = "0"
end
any thoughts?