I am using the Game Master Template posted by ar2rsawseen I believe. While trying to add more buttons to one of the menus it seems that four buttons are all that it will allow. What would I need to modify to allow for more menu buttons?
@pie Ive already tried the scale and position but it didn't help. Seems no matter how many buttons I add the last added just replaces the fourth in the list. I guess I could just add another menu but that seems inefficient.
weird but i was able to add 5th button without changing the code. Just copy paste one of the button code and here it is. I guess either we are misunderstanding your problem either you are terribly doing something wrong:D
My all start.lua code:
--[[
*************************************************************
* This script is developed by Arturs Sosins aka ar2rsawseen, <a href="http://appcodingeasy.com" rel="nofollow">http://appcodingeasy.com</a>
* Feel free to distribute and modify code, but keep reference to its creator
*
* Gideros Game Template for developing games. Includes:
* Start scene, pack select, level select, settings, score system and much more
*
* For more information, examples and online documentation visit:
* <a href="http://appcodingeasy.com/Gideros-Mobile/Gideros-Mobile-Game-Template" rel="nofollow">http://appcodingeasy.com/Gideros-Mobile/Gideros-Mobile-Game-Template</a>
**************************************************************
]]--localfunction randomize(elem)
elem:setPosition(math.random(-1000, 1000), math.random(-1000, 1000))
elem:setRotation(math.random(0, 360))
elem:setAlpha(math.random())
elem:setScale(math.random())end
start = Core.class(Sprite)function start:init()--here we'd probably want to set up a background picturelocal screen = Bitmap.new(Texture.new("images/gideros_mobile.png", conf.textureFilter))
self:addChild(screen)
screen:setPosition((conf.width-screen:getWidth())/2, (conf.height-screen:getHeight())/2)
self:addEventListener("enterEnd", self.onEnterEnd, self)endfunction start:onEnterEnd()--create menu--with 20px padding between buttonslocal menu = VerticalView.new({padding =20, easing = conf.easing})
self:addChild(menu)local button = Button.new(Bitmap.new(Texture.new("images/start_up.png", conf.textureFilter)), Bitmap.new(Texture.new("images/start_down.png", conf.textureFilter)))
randomize(button)
button:addEventListener("click", function()
menu:reverse()--go to pack select scene
sceneManager:changeScene("pack_select", 1, conf.transition, conf.easing)end)--add menu buttons
menu:addChild(button)local button = Button.new(Bitmap.new(Texture.new("images/options_up.png", conf.textureFilter)), Bitmap.new(Texture.new("images/options_down.png", conf.textureFilter)))
randomize(button)
button:addEventListener("click", function()
menu:reverse()--go to pack select scene
sceneManager:changeScene("options", 1, conf.transition, conf.easing)end)
menu:addChild(button)local button = Button.new(Bitmap.new(Texture.new("images/help_up.png", conf.textureFilter)), Bitmap.new(Texture.new("images/help_down.png", conf.textureFilter)))
randomize(button)
button:addEventListener("click", function()
menu:reverse()--go to pack select scene
sceneManager:changeScene("help", 1, conf.transition, conf.easing)end)
menu:addChild(button)local button = Button.new(Bitmap.new(Texture.new("images/help_up.png", conf.textureFilter)), Bitmap.new(Texture.new("images/help_down.png", conf.textureFilter)))
randomize(button)
button:addEventListener("click", function()
menu:reverse()--go to pack select scene
sceneManager:changeScene("help", 1, conf.transition, conf.easing)end)
menu:addChild(button)local button = Button.new(Bitmap.new(Texture.new("images/help_up.png", conf.textureFilter)), Bitmap.new(Texture.new("images/help_down.png", conf.textureFilter)))
randomize(button)
button:addEventListener("click", function()
menu:reverse()--go to pack select scene
sceneManager:changeScene("help", 1, conf.transition, conf.easing)end)
menu:addChild(button)--position menu in center
menu:setPosition((conf.width-menu:getWidth())/2, (conf.height-menu:getHeight())/2)end
@Creekmonkey I think that there's something wrong in your code: attached you can find a "working example" made with copy/paste. I stopped at 6 buttons because others would go out of the screen (they would be there though if you plan to scroll the list later on development) [edit talis was faster!]
Comments
I suppose that you are trying to add buttons to start.lua (https://github.com/ar2rsawseen/GameTemplate/blob/master/start.lua)
I didn't try it but you should be able to do it by just copying/pasting a "button snippet" and change its graphics and actions.
you can try changing the menu object position from this line:
My all start.lua code:
https://github.com/ar2rsawseen/GameTemplate
[edit talis was faster!]
Likes: pie, antix
Likes: talis