Changing skins
Moderators: Shine, Insert_witty_name
-
- Posts: 53
- Joined: Wed Aug 31, 2005 1:43 am
Changing skins
Ok, I set up a menu in my app so that I could change the background. My menu is set up pretty close to the menu in Shine's Snake game. My question is, is there a way to make it change all the graphics in the app, and not just the background, without having to make a option for each seperate object? Also, I remember seeing something about the reason mp3 were not going to be supported was because of having to buy the rights or something. If thats the case how do other homebrew makers get away with it, for example, I have XBMC on my xbox and it supports mp3.
I want my money back!?
-
- Posts: 116
- Joined: Mon Jul 18, 2005 2:20 am
Re: Changing skins
Using XBMC as an example for guys who cares about rights, isn't exactly good ;)
And .ogg is probably a better format to use anyway...
And .ogg is probably a better format to use anyway...
-
- Posts: 53
- Joined: Wed Aug 31, 2005 1:43 am
I was not applying that they care about rights, I don't know if they do or not, either way I was just using them as an example. Anyways.. I have never heared of .ogg, is there any kind of .mp3 to .ogg converter. Will Lua support .ogg in the future?
Last edited by 2Xtremes2004 on Sun Oct 23, 2005 2:36 am, edited 1 time in total.
I want my money back!?
-
- Posts: 53
- Joined: Wed Aug 31, 2005 1:43 am
I have never used an array, so I am a bit clueless about them. Could you point me towards an example please. Maybe, it is something like this:
Code: Select all
-- Default options
options = { theme = "Skin#1", music = "Song#1" }
-- Possible options for system config menu
possibleOptions = {
theme = {
displayName = "Themes",
values = {"Skin#1, Skin#2"} },
music = {
displayName = "Background Music",
values = {"Song#1", "Song#2", "Song#3"} }
-- Skin Arrays
Skin#1 = {
background = Image.load("Skins/Background.png"),
hold = Image.load("Data/Hold.png"),
battl = Image.load("Data/Battery Low.png"),
batth = Image.load("Data/Battery Half.png"),
battf = Image.load("Data/Battery Full.png"),
usba = Image.load("Data/USBON.png"),
baudio = Image.load("Data/Audio.png"),
bimage = Image.load("Data/Image.png"),
pointer = Image.load("Data/Pointer.png"),
lshoulder = Image.load("Data/LON.png"),
rshoulder = Image.load("Data/RON.png")
}
I want my money back!?
array = table in lua
Code: Select all
-- Skin Arrays
Skins# = {
{
background = Image.load("Skins/Background.png"),
hold = Image.load("Data/Hold.png"),
battl = Image.load("Data/Battery Low.png"),
batth = Image.load("Data/Battery Half.png"),
battf = Image.load("Data/Battery Full.png"),
usba = Image.load("Data/USBON.png"),
baudio = Image.load("Data/Audio.png"),
bimage = Image.load("Data/Image.png"),
pointer = Image.load("Data/Pointer.png"),
lshoulder = Image.load("Data/LON.png"),
rshoulder = Image.load("Data/RON.png")
}
{
background = Image.load("Skins/Background2.png"),
hold = Image.load("Data/Hold2.png"),
battl = Image.load("Data/Battery Low2.png"),
batth = Image.load("Data/Battery Half2.png"),
battf = Image.load("Data/Battery Full2.png"),
usba = Image.load("Data/USBON2.png"),
baudio = Image.load("Data/Audio2.png"),
bimage = Image.load("Data/Image2.png"),
pointer = Image.load("Data/Pointer2.png"),
lshoulder = Image.load("Data/LON2.png"),
rshoulder = Image.load("Data/RON2.png")
}
}
this codeholds 2skins
-
- Posts: 53
- Joined: Wed Aug 31, 2005 1:43 am
Ok, I got it put into my script, but it shows an error every time its suppose to blit an image. Do I need to go back through and edit my script to load from the array?
This is how it was set up:
Do I change it to something like this?
...or something else. Sorry for being such a noob, but I'm slowly learning :-P Thx for all the help so far.
This is how it was set up:
Code: Select all
screen:blit(0, 0, background, 0, 0, background:width(), background:height(), false)
Code: Select all
screen:blit(0, 0, Skin{background}, 0, 0, Skin{background}:width(), Skin{background}:height(), false)
I want my money back!?
-
- Posts: 22
- Joined: Mon Aug 22, 2005 4:06 am
I think you need a variable to track which skin is active
Since tables start with an index of 1, one is the starting point of the variable.
activeSkin = 1
to change the skin just increase the activeSkin variable
screen:blit(0, 0, Skin[activeSkin].background, 0, 0, Skin[activeSkin].background:width(), Skin[activeSkin].background:height(), false)
Since tables start with an index of 1, one is the starting point of the variable.
activeSkin = 1
to change the skin just increase the activeSkin variable
screen:blit(0, 0, Skin[activeSkin].background, 0, 0, Skin[activeSkin].background:width(), Skin[activeSkin].background:height(), false)
-
- Posts: 53
- Joined: Wed Aug 31, 2005 1:43 am
When I tried it like this:
It gives me the following error:
Any ideas, anyone?
Code: Select all
Skin = {
{
background = Image.load("Skins/Background.png"),
hold = Image.load("Data/Hold.png"),
battl = Image.load("Data/Battery Low.png"),
batth = Image.load("Data/Battery Half.png"),
battf = Image.load("Data/Battery Full.png"),
usba = Image.load("Data/USBON.png"),
baudio = Image.load("Data/Audio.png"),
bimage = Image.load("Data/Image.png"),
pointer = Image.load("Data/Pointer.png"),
lshoulder = Image.load("Data/LON.png"),
rshoulder = Image.load("Data/RON.png")
}
{
background = Image.load("Skins/Background2.png"),
hold = Image.load("Data/Hold2.png"),
battl = Image.load("Data/Battery Low2.png"),
batth = Image.load("Data/Battery Half2.png"),
battf = Image.load("Data/Battery Full2.png"),
usba = Image.load("Data/USBON2.png"),
baudio = Image.load("Data/Audio2.png"),
bimage = Image.load("Data/Image2.png"),
pointer = Image.load("Data/Pointer2.png"),
lshoulder = Image.load("Data/LON2.png"),
rshoulder = Image.load("Data/RON2.png")
}
}
Code: Select all
error: System/SYSTEM.LUA:70 '}' expected (to close '{' at line51)
near '{'
Error: No script file found.
Press start to restart
I want my money back!?
U must put a "," between "options" like this:
Regards,
ShUr1k3n
Code: Select all
Skin = {
{
background = Image.load("Skins/Background.png"),
hold = Image.load("Data/Hold.png"),
battl = Image.load("Data/Battery Low.png"),
batth = Image.load("Data/Battery Half.png"),
battf = Image.load("Data/Battery Full.png"),
usba = Image.load("Data/USBON.png"),
baudio = Image.load("Data/Audio.png"),
bimage = Image.load("Data/Image.png"),
pointer = Image.load("Data/Pointer.png"),
lshoulder = Image.load("Data/LON.png"),
rshoulder = Image.load("Data/RON.png")
}, < --------- HERE........
{
background = Image.load("Skins/Background2.png"),
hold = Image.load("Data/Hold2.png"),
battl = Image.load("Data/Battery Low2.png"),
batth = Image.load("Data/Battery Half2.png"),
battf = Image.load("Data/Battery Full2.png"),
usba = Image.load("Data/USBON2.png"),
baudio = Image.load("Data/Audio2.png"),
bimage = Image.load("Data/Image2.png"),
pointer = Image.load("Data/Pointer2.png"),
lshoulder = Image.load("Data/LON2.png"),
rshoulder = Image.load("Data/RON2.png")
}
}
ShUr1k3n
-
- Posts: 53
- Joined: Wed Aug 31, 2005 1:43 am
So, this should work right?
Ok, I updated my script with the above code and now it gives me this error:
Code: Select all
-- Default options
options = { theme = "Skin1", music = "Song#1" }
activeSkin = 1
-- Possible options for system config menu
possibleOptions = {
theme = {
displayName = "Themes",
values = {"Skin1, Skin2"} },
music = {
displayName = "Background Music",
values = {"Song#1", "Song#2", "Song#3"} }
Skin1 = Skin[1]
Skin2 = Skin[2]
Skin = {
{
background = Image.load("Skins/Background.png"),
hold = Image.load("Data/Hold.png"),
battl = Image.load("Data/Battery Low.png"),
batth = Image.load("Data/Battery Half.png"),
battf = Image.load("Data/Battery Full.png"),
usba = Image.load("Data/USBON.png"),
baudio = Image.load("Data/Audio.png"),
bimage = Image.load("Data/Image.png"),
pointer = Image.load("Data/Pointer.png"),
lshoulder = Image.load("Data/LON.png"),
rshoulder = Image.load("Data/RON.png")
},
{
background = Image.load("Skins/Background2.png"),
hold = Image.load("Data/Hold2.png"),
battl = Image.load("Data/Battery Low2.png"),
batth = Image.load("Data/Battery Half2.png"),
battf = Image.load("Data/Battery Full2.png"),
usba = Image.load("Data/USBON2.png"),
baudio = Image.load("Data/Audio2.png"),
bimage = Image.load("Data/Image2.png"),
pointer = Image.load("Data/Pointer2.png"),
lshoulder = Image.load("Data/LON2.png"),
rshoulder = Image.load("Data/RON2.png")
}
}
screen:blit(0, 0, Skin[activeSkin].background, 0, 0, Skin[activeSkin].background:width(), Skin[activeSkin].background:height(), false)
Code: Select all
error: System/SYSTEM.LUA:48: attempt to index global 'Skin' (a nil value)
Error: No script file found.
Press start to restart
Last edited by 2Xtremes2004 on Wed Oct 26, 2005 5:43 am, edited 1 time in total.
I want my money back!?
you can remove the following lines:
greets
Code: Select all
Skin1 = Skin[1]
Skin2 = Skin[2]
-
- Posts: 53
- Joined: Wed Aug 31, 2005 1:43 am
-
- Posts: 53
- Joined: Wed Aug 31, 2005 1:43 am
I Finaly got it!!!! ;-P Turns out, all I needed was this:
Thx for the help LuMo, ShUr1k3n, and flattspott!
Code: Select all
selectedLevel = (options["level"])
if skinSelected ~= selectedLevel then
if selectedLevel == "Skin#1" then
activeSkin = 1
skinSelected = "Skin#1"
elseif selectedLevel == "Skin#2" then
activeSkin = 2
skinSelected = "Skin#2"
end
end
I want my money back!?