More code help (control problem)
Im having 2 very big problems and untill they are solved i cant progress.
-1st problem
It seems that the sprites are not blit to the screen for the whole time it only stay on for a mili second then goes away. This happenes from the transition from the menu.lua to the scene.lua. where the text from the menu.lua stays on the screen when the scene.lua is initiated. The scene.lua only blits the sprites for a short time then goes away. why its doing this i have no idea.
Code from menu.lua
Code:
status = "menu"
Black = Color.new(0, 0, 0)
Red = Color.new(255, 0, 0)
--load images--
Background = Image.load("backgrounds/menu.png")
--load files--
LoadA = loadfile("scene.lua")
LoadB = loadfile("instructions.lua")
LoadC = loadfile("credits.lua")
while true do
current = 1
oldpad = Controls.read()
while true do
pad = Controls.read()
screen:clear()
----prints to the screen-------
screen:blit(0, 0, Background)
screen:print(185, 175, "Start Game", Black)
screen:print(185, 195, "Instructions", Black)
screen:print(185, 215, "Credits", Black)
screen:print(314, 263, "Press Home to exit", Black)
screen:print(320, 4, "Gunntims0103-Coder", Black)
-----this code is so that when you highlight an option in a menu it turns red-----
if current == 1 then
screen:print(185, 175, "Start Game", Red)
end
if current == 2 then
screen:print(185, 195, "Instructions", Red)
end
if current == 3 then
screen:print(185, 215, "Credits", Red)
end
-----this makes it so that you can scroll through your menu----
if pad:up() and oldpad:up() ~= pad:up() then
current = current-1
end
if pad:down() and oldpad:down() ~= pad:down() then
current = current+1
end
if current == 4 then
current = 1
end
if current == 0 then
current = 3
end
-----this is to select your menu options------
if pad:cross() and current == 1 then
LoadA()
end
if pad:cross() and current == 2 then
LoadB()
end
if pad:cross() and current == 3 then
LoadC()
end
screen.waitVblankStart()
screen:flip()
oldpad = pad
end
end
Code from scene.lua
Code:
Black = Color.new(0, 0, 0)
--load images, this is for the cutscene--
Background = Image.load("backgrounds/scene1.png")
Sora = Image.load("sprites/sora.png")
Enemie = Image.load("sprites/enemie.png")
Talk = Image.load("sprites/talk.png")
--load files--
LoadA = loadfile("menu.lua")
pad = Controls.read()
screen:clear()
--prints to screen--
screen:blit(0, 0,Background)
screen:blit(31, 230,Sora)
screen:blit(330, 230,Enemie)
screen:blit(35, 30,Talk)
if pad:cross() then
LoadA()
Screen:waitVblankStart()
Screen:flip()
end
-2nd problem
Also another problem that i am having is that the credits.lua and the instructions.lua are not initiated when picked from the menu. how do i fix this
Code from credits.lua
Code:
black = Color.new(0, 0, 0)
background = Image.load("backgrounds/credits.png")
loadA = loadfile("menu.lua")
while true do
pad = Controls.read()
screen:blit(0, 0, background)
if pad:cross() then
loadA()
end
screen.waitVblankStart()
screen:flip()
end
Code from instructions.lua
Code:
black = Color.new(0, 0, 0)
background = Image.load("backgrounds/instructions.png")
loadA = loadfile("menu.lua")
while true do
pad = Controls.read()
screen:blit(0, 0, background)
if pad:cross() then
loadA()
end
screen.waitVblankStart()
screen:flip()
end
Well basically i want to be able to eliminate the text that shows up on the scene.lua. I want to have the sprite blit to the screen perminitly. I also want to be able to go into the credits and instructions.lua from the menu
any help would be much apprecaiated, thank you