Skip to content

Instantly share code, notes, and snippets.

@makotok
Created December 28, 2012 18:00
Show Gist options
  • Save makotok/4400312 to your computer and use it in GitHub Desktop.
Save makotok/4400312 to your computer and use it in GitHub Desktop.
Sample layout of Hanappe.
module(..., package.seeall)
Component = require "hp/gui/Component"
function onCreate(params)
view = View {
scene = scene,
layout = {
VBoxLayout {
align = {"center", "center"},
padding = {10, 10, 10, 10},
}
},
children = {{
Component {
layout = {
VBoxLayout {
align = {"center", "center"},
padding = {10, 10, 10, 10},
}
},
children = {{
Button {
name = "startButton",
text = "はじめ",
onClick = onStartClick,
},
Button {
name = "backButton",
text = "戻る",
onClick = onBackClick,
},
}},
},
Component {
layout = {
VBoxLayout {
align = {"center", "center"},
padding = {10, 10, 10, 10},
}
},
children = {{
Button {
name = "testButton1",
text = "disabled",
enabled = false,
},
}},
},
}},
}
view:updateComponent()
MOAIGfxDevice.setListener(MOAIGfxDevice.EVENT_RESIZE, onResize)
end
function onResize(width, height)
print("onResize(width, height)", width, height)
Application.screenWidth = width
Application.screenHeight = height
Application.viewWidth = width
Application.viewHeight = height
-- resize main view
view:setSize(width, height)
view:getLayer():setSize(width, height)
--view:updateLayout()
end
function onStartClick(e)
print("onStartClick")
end
function onBackClick(e)
SceneManager:closeScene({animation = "fade"})
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment