remove noble
@ -1,26 +0,0 @@
|
|||||||
title = 'Noble Engine API reference'
|
|
||||||
|
|
||||||
project = 'Noble Engine'
|
|
||||||
description = 'A li\'l game engine for Playdate.'
|
|
||||||
|
|
||||||
format = 'markdown'
|
|
||||||
|
|
||||||
no_lua_ref = true
|
|
||||||
wrap = true
|
|
||||||
no_space_before_args = true
|
|
||||||
backtick_references = true
|
|
||||||
|
|
||||||
dir = '../../.docs'
|
|
||||||
file = {
|
|
||||||
'../../',
|
|
||||||
exclude = {
|
|
||||||
'../../.lua',
|
|
||||||
'../../.luarocks',
|
|
||||||
'../../.docs'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
style = "."
|
|
||||||
template = "."
|
|
||||||
|
|
||||||
examples = "../../templates"
|
|
@ -1,524 +0,0 @@
|
|||||||
@import url(https://fonts.googleapis.com/css?family=Quicksand:300,700);
|
|
||||||
@import url(https://fonts.googleapis.com/css?family=Lato);
|
|
||||||
@import url(https://fonts.googleapis.com/css2?family=Source+Code+Pro:wght@200;300;400;600;700;900&display=swap);
|
|
||||||
* {
|
|
||||||
-webkit-box-sizing: border-box;
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
|
||||||
margin: 2em;
|
|
||||||
font-family: "Lato", arial, helvetica, geneva, sans-serif;
|
|
||||||
background-color: #ffcb1f;
|
|
||||||
color: #31302f;
|
|
||||||
}
|
|
||||||
|
|
||||||
code,
|
|
||||||
tt {
|
|
||||||
font-family: "Source Code Pro", monospace;
|
|
||||||
font-size: 1.1em;
|
|
||||||
letter-spacing: -1px;
|
|
||||||
font-weight: 600;
|
|
||||||
color: #056d8d;
|
|
||||||
}
|
|
||||||
|
|
||||||
span.types:before {
|
|
||||||
content: ": ";
|
|
||||||
}
|
|
||||||
|
|
||||||
span.types:after {
|
|
||||||
content: "";
|
|
||||||
}
|
|
||||||
|
|
||||||
.type,
|
|
||||||
.default,
|
|
||||||
.optional {
|
|
||||||
color: #74726e;
|
|
||||||
}
|
|
||||||
|
|
||||||
.default .value {
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
.parameters {
|
|
||||||
list-style-type: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.parameters li {
|
|
||||||
margin-bottom: 10px;
|
|
||||||
line-height: 1.5em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.parameter {
|
|
||||||
font-weight: 600;
|
|
||||||
color: #045771;
|
|
||||||
}
|
|
||||||
|
|
||||||
body, td, th {
|
|
||||||
font-size: .95em;
|
|
||||||
line-height: 1.2em;
|
|
||||||
}
|
|
||||||
|
|
||||||
p, ul {
|
|
||||||
margin: 10px 0 0 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
ul {
|
|
||||||
padding-left: 25px;
|
|
||||||
}
|
|
||||||
|
|
||||||
strong {
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
em {
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
|
|
||||||
.logo {
|
|
||||||
width: 100%;
|
|
||||||
background-image: url("logo.png");
|
|
||||||
background-repeat: no-repeat;
|
|
||||||
background-position: center;
|
|
||||||
height: 150px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.logo h1 {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
h1 {
|
|
||||||
font-family: 'Quicksand', sans-serif;
|
|
||||||
font-weight: bold;
|
|
||||||
color: #cf5a5a;
|
|
||||||
font-size: 2.5em;
|
|
||||||
margin: 20px 0 30px 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
h2, h3, h4 {
|
|
||||||
font-family: 'Quicksand', sans-serif;
|
|
||||||
font-weight: 700;
|
|
||||||
margin: 15px 0 10px 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
h2 {
|
|
||||||
font-size: 1.25em;
|
|
||||||
color: #cf5a5a;
|
|
||||||
}
|
|
||||||
|
|
||||||
h3 {
|
|
||||||
font-size: 1.15em;
|
|
||||||
}
|
|
||||||
|
|
||||||
h4 {
|
|
||||||
font-size: 1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.section-header {
|
|
||||||
margin-top: 50px;
|
|
||||||
padding: 10px;
|
|
||||||
padding-left: 15px;
|
|
||||||
margin-left: -25px;
|
|
||||||
border-radius: 50px;
|
|
||||||
border-left: 20px solid #cf5a5a;
|
|
||||||
background-color: #e9cfc8;
|
|
||||||
color: #31302f;
|
|
||||||
}
|
|
||||||
|
|
||||||
a:link {
|
|
||||||
font-weight: bold;
|
|
||||||
color: #cf5a5a;
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
a:visited {
|
|
||||||
font-weight: bold;
|
|
||||||
color: #cf5a5a;
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
a:link:hover {
|
|
||||||
text-decoration: underline;
|
|
||||||
}
|
|
||||||
|
|
||||||
hr {
|
|
||||||
background: #cf5a5a;
|
|
||||||
border-radius: 100px;
|
|
||||||
height: 6px;
|
|
||||||
margin: 60px 20%;
|
|
||||||
border: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
blockquote {
|
|
||||||
margin-left: 3em;
|
|
||||||
}
|
|
||||||
|
|
||||||
ul {
|
|
||||||
list-style-type: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
p.name {
|
|
||||||
font-family: "Andale Mono", monospace;
|
|
||||||
padding-top: 1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
span.item-name {
|
|
||||||
background-color: #fbd350;
|
|
||||||
display: inline-block;
|
|
||||||
color: #31302f;
|
|
||||||
padding: 10px 20px;
|
|
||||||
border-radius: 25px;
|
|
||||||
border: 2px solid #bf9817;
|
|
||||||
font-size: 1em;
|
|
||||||
font-family: "Source Code Pro", monospace;
|
|
||||||
font-weight: 700;
|
|
||||||
letter-spacing: -1px;
|
|
||||||
}
|
|
||||||
|
|
||||||
pre {
|
|
||||||
background-color: #056d8d;
|
|
||||||
border: 2px solid #03475c;
|
|
||||||
-webkit-box-shadow: 0 0 10px 0 rgba(49, 48, 47, 0.5);
|
|
||||||
box-shadow: 0 0 10px 0 rgba(49, 48, 47, 0.5);
|
|
||||||
border-radius: 15px;
|
|
||||||
color: #f0ece3;
|
|
||||||
padding: 15px 20px;
|
|
||||||
margin: 10px 0 10px 0;
|
|
||||||
font-family: "Source Code Pro", monospace;
|
|
||||||
-moz-tab-size: 4;
|
|
||||||
-o-tab-size: 4;
|
|
||||||
tab-size: 4;
|
|
||||||
overflow-x: auto;
|
|
||||||
width: 100%;
|
|
||||||
font-weight: 400;
|
|
||||||
}
|
|
||||||
|
|
||||||
pre .keyword {
|
|
||||||
color: #ffcb1f;
|
|
||||||
}
|
|
||||||
|
|
||||||
pre .string, pre .number {
|
|
||||||
color: #eb6e6e;
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
pre .comment {
|
|
||||||
color: #b4b1aa;
|
|
||||||
}
|
|
||||||
|
|
||||||
pre.example {
|
|
||||||
font-size: .85em;
|
|
||||||
}
|
|
||||||
|
|
||||||
table.index td {
|
|
||||||
text-align: left;
|
|
||||||
vertical-align: top;
|
|
||||||
}
|
|
||||||
|
|
||||||
#container {
|
|
||||||
margin-left: auto;
|
|
||||||
margin-right: auto;
|
|
||||||
border-radius: 25px;
|
|
||||||
-webkit-box-shadow: 0 0 25px 0 rgba(49, 48, 47, 0.3);
|
|
||||||
box-shadow: 0 0 25px 0 rgba(49, 48, 47, 0.3);
|
|
||||||
overflow: hidden;
|
|
||||||
max-width: 1600px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#product {
|
|
||||||
text-align: center;
|
|
||||||
height: 500px;
|
|
||||||
background-color: #31302f;
|
|
||||||
color: #f0ece3;
|
|
||||||
}
|
|
||||||
|
|
||||||
#product > :before {
|
|
||||||
content: 'Noble Engine';
|
|
||||||
}
|
|
||||||
|
|
||||||
#product big {
|
|
||||||
font-size: 2em;
|
|
||||||
}
|
|
||||||
|
|
||||||
#main {
|
|
||||||
background-color: #31302f;
|
|
||||||
display: -webkit-box;
|
|
||||||
display: -ms-flexbox;
|
|
||||||
display: flex;
|
|
||||||
-webkit-box-orient: horizontal;
|
|
||||||
-webkit-box-direction: normal;
|
|
||||||
-ms-flex-direction: row;
|
|
||||||
flex-direction: row;
|
|
||||||
}
|
|
||||||
|
|
||||||
#navigation {
|
|
||||||
-webkit-box-flex: 1;
|
|
||||||
-ms-flex-positive: 1;
|
|
||||||
flex-grow: 1;
|
|
||||||
-ms-flex-negative: 0;
|
|
||||||
flex-shrink: 0;
|
|
||||||
-ms-flex-preferred-size: auto;
|
|
||||||
flex-basis: auto;
|
|
||||||
width: 275px;
|
|
||||||
padding: 0 10px;
|
|
||||||
overflow: hidden;
|
|
||||||
color: #f0ece3;
|
|
||||||
}
|
|
||||||
|
|
||||||
#navigation a:link, #navigation a:visited {
|
|
||||||
font-weight: normal;
|
|
||||||
}
|
|
||||||
|
|
||||||
#navigation .nav-module,
|
|
||||||
#navigation .nav-modules {
|
|
||||||
color: #31302f;
|
|
||||||
padding: 15px;
|
|
||||||
border-radius: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#navigation .nav-module a:link, #navigation .nav-module a:visited,
|
|
||||||
#navigation .nav-modules a:link,
|
|
||||||
#navigation .nav-modules a:visited {
|
|
||||||
color: #31302f;
|
|
||||||
}
|
|
||||||
|
|
||||||
#navigation .nav-module ul a:active, #navigation .nav-module ul a:hover, #navigation .nav-module ul .selected,
|
|
||||||
#navigation .nav-modules ul a:active,
|
|
||||||
#navigation .nav-modules ul a:hover,
|
|
||||||
#navigation .nav-modules ul .selected {
|
|
||||||
color: #f0ece3;
|
|
||||||
background-color: #cf5a5a;
|
|
||||||
padding: 5px 10px;
|
|
||||||
margin-left: -10px;
|
|
||||||
border-radius: 30px;
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
#navigation .nav-module ul .selected,
|
|
||||||
#navigation .nav-modules ul .selected {
|
|
||||||
line-height: 2em;
|
|
||||||
margin-left: -28px;
|
|
||||||
padding-left: 28px;
|
|
||||||
border-radius: 0 30px 30px 0;
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
#navigation .nav-module {
|
|
||||||
background-color: #eb6e6e;
|
|
||||||
margin: 0 -10px 20px 10px;
|
|
||||||
border-radius: 20px 0 0 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#navigation .nav-module h2 {
|
|
||||||
background-color: #cf5a5a;
|
|
||||||
color: #f0ece3;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#navigation .nav-module ul a:active, #navigation .nav-module ul a:hover {
|
|
||||||
color: #31302f;
|
|
||||||
background-color: #ffcb1f;
|
|
||||||
}
|
|
||||||
|
|
||||||
#navigation .nav-modules {
|
|
||||||
background-color: #f3e5bc;
|
|
||||||
margin: 0 10px 30px 10px;
|
|
||||||
padding-top: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#navigation h1 {
|
|
||||||
color: #eb6e6e;
|
|
||||||
line-height: 80%;
|
|
||||||
font-family: 'Quicksand', sans-serif;
|
|
||||||
font-weight: 900;
|
|
||||||
font-size: 32px;
|
|
||||||
padding-left: 20px;
|
|
||||||
padding-bottom: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#navigation h2 {
|
|
||||||
color: #31302f;
|
|
||||||
font-size: 1.1em;
|
|
||||||
background-color: #f0ece3;
|
|
||||||
padding: 5px 10px;
|
|
||||||
margin-right: 20px;
|
|
||||||
border-radius: 30px;
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
#navigation ul {
|
|
||||||
font-size: 1em;
|
|
||||||
list-style-type: none;
|
|
||||||
margin: 1px 1px 10px 1px;
|
|
||||||
padding-left: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#navigation li {
|
|
||||||
display: block;
|
|
||||||
margin: 0px 0px 6px 12px;
|
|
||||||
padding-left: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#navigation li li a {
|
|
||||||
margin: 0px 3px 0px -1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
#content {
|
|
||||||
-webkit-box-flex: 1;
|
|
||||||
-ms-flex-positive: 1;
|
|
||||||
flex-grow: 1;
|
|
||||||
-ms-flex-negative: 1;
|
|
||||||
flex-shrink: 1;
|
|
||||||
-ms-flex-preferred-size: auto;
|
|
||||||
flex-basis: auto;
|
|
||||||
min-width: 0;
|
|
||||||
padding: 2em;
|
|
||||||
padding-left: 3.5em;
|
|
||||||
border-left: 4px solid #cf5a5a;
|
|
||||||
-webkit-box-shadow: inset 0 0 50px 0 rgba(207, 90, 90, 0.25);
|
|
||||||
box-shadow: inset 0 0 50px 0 rgba(207, 90, 90, 0.25);
|
|
||||||
background-color: #f0ece3;
|
|
||||||
}
|
|
||||||
|
|
||||||
#about {
|
|
||||||
clear: both;
|
|
||||||
padding: 20px;
|
|
||||||
border-top: 2px solid #31302f;
|
|
||||||
background-color: #cf5a5a;
|
|
||||||
color: #f0ece3;
|
|
||||||
}
|
|
||||||
|
|
||||||
#about a:link, #about a:visited, #about a:hover, #about a:active {
|
|
||||||
color: #ffcb1f;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media print {
|
|
||||||
body {
|
|
||||||
font: 12pt "Times New Roman", "TimeNR", Times, serif;
|
|
||||||
}
|
|
||||||
a {
|
|
||||||
font-weight: bold;
|
|
||||||
color: #1c4e68;
|
|
||||||
text-decoration: underline;
|
|
||||||
}
|
|
||||||
#main {
|
|
||||||
background-color: #ffffff;
|
|
||||||
border-left: 0px;
|
|
||||||
}
|
|
||||||
#container {
|
|
||||||
margin-left: 2%;
|
|
||||||
margin-right: 2%;
|
|
||||||
background-color: #ffffff;
|
|
||||||
}
|
|
||||||
#content {
|
|
||||||
padding: 1em;
|
|
||||||
background-color: #ffffff;
|
|
||||||
}
|
|
||||||
#navigation {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
pre.example {
|
|
||||||
font-family: "Andale Mono", monospace;
|
|
||||||
font-size: 10pt;
|
|
||||||
page-break-inside: avoid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
table.module_list {
|
|
||||||
border-width: 1px;
|
|
||||||
border-style: solid;
|
|
||||||
border-color: #b1e3fa;
|
|
||||||
border-collapse: collapse;
|
|
||||||
}
|
|
||||||
|
|
||||||
table.module_list td {
|
|
||||||
border-width: 1px;
|
|
||||||
padding: 3px;
|
|
||||||
border-style: solid;
|
|
||||||
border-color: #b1e3fa;
|
|
||||||
}
|
|
||||||
|
|
||||||
table.module_list td.name {
|
|
||||||
background-color: #e0f4fc;
|
|
||||||
min-width: 200px;
|
|
||||||
}
|
|
||||||
|
|
||||||
table.module_list td.summary {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
table.function_list {
|
|
||||||
border-width: 1px;
|
|
||||||
border-style: solid;
|
|
||||||
border-color: #b1e3fa;
|
|
||||||
border-collapse: collapse;
|
|
||||||
}
|
|
||||||
|
|
||||||
table.function_list td {
|
|
||||||
border-width: 1px;
|
|
||||||
padding: 3px;
|
|
||||||
border-style: solid;
|
|
||||||
border-color: #b1e3fa;
|
|
||||||
}
|
|
||||||
|
|
||||||
table.function_list td.name {
|
|
||||||
background-color: #e0f4fc;
|
|
||||||
min-width: 200px;
|
|
||||||
}
|
|
||||||
|
|
||||||
table.function_list td.summary {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
ul.nowrap {
|
|
||||||
overflow: auto;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
dl.table dt,
|
|
||||||
dl.function dt {
|
|
||||||
padding-top: 1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
dl.table dd dd,
|
|
||||||
dl.function dd {
|
|
||||||
padding-bottom: 30px;
|
|
||||||
margin: 10px 0 10px 20px;
|
|
||||||
border-bottom: 2px dotted #056d8d;
|
|
||||||
}
|
|
||||||
|
|
||||||
dl.table dd > :last-child,
|
|
||||||
dl.function > :last-child {
|
|
||||||
border-bottom: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
dl.table h3,
|
|
||||||
dl.function h3 {
|
|
||||||
font-size: .95em;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* stop sublists from having initial vertical space */
|
|
||||||
ul ul {
|
|
||||||
margin-top: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
ol ul {
|
|
||||||
margin-top: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
ol ol {
|
|
||||||
margin-top: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
ul ol {
|
|
||||||
margin-top: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* make the target distinct; helps when we're navigating to a function */
|
|
||||||
a:target + * {
|
|
||||||
border: 2px solid #31302f;
|
|
||||||
border-bottom: 6px solid #31302f;
|
|
||||||
background-color: #cf5a5a;
|
|
||||||
color: #f0ece3;
|
|
||||||
}
|
|
||||||
/*# sourceMappingURL=ldoc.css.map */
|
|
@ -1,299 +0,0 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
||||||
<html>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=$(ldoc.doc_charset)"/>
|
|
||||||
<head>
|
|
||||||
<title>$(ldoc.title)</title>
|
|
||||||
<link rel="stylesheet" href="$(ldoc.css)" type="text/css" />
|
|
||||||
<link rel="icon" href="favicon.ico">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<div id="container">
|
|
||||||
|
|
||||||
<div id="main">
|
|
||||||
|
|
||||||
# local no_spaces = ldoc.no_spaces
|
|
||||||
# local use_li = ldoc.use_li
|
|
||||||
# local display_name = ldoc.display_name
|
|
||||||
# local iter = ldoc.modules.iter
|
|
||||||
# local function M(txt,item) return ldoc.markup(txt,item,ldoc.plain) end
|
|
||||||
# --local nowrap = ldoc.wrap and '' or 'nowrap'
|
|
||||||
|
|
||||||
<!-- Menu -->
|
|
||||||
|
|
||||||
<div id="navigation">
|
|
||||||
<a href="../$(ldoc.output).html"><div class="logo">
|
|
||||||
<h1>$(ldoc.project)</h1>
|
|
||||||
</div></a>
|
|
||||||
|
|
||||||
# --------- contents of module -------------
|
|
||||||
# if module and not ldoc.no_summary and #module.items > 0 then
|
|
||||||
<div class="nav-module">
|
|
||||||
<h2>$(module.name)</h2>
|
|
||||||
<ul>
|
|
||||||
# for kind, items in module.kinds() do
|
|
||||||
# kind = kind:gsub("modules.", ""):gsub(" Functions", ""):gsub("%.", "\u{200B}.")
|
|
||||||
<h3>$(kind)</h3>
|
|
||||||
<ul>
|
|
||||||
# for item in items() do
|
|
||||||
# local subName = item.name
|
|
||||||
# if (item.name:sub(1, #module.name) == module.name) then
|
|
||||||
# subName = item.name:sub(#module.name+1, #item.name)
|
|
||||||
# elseif (module.name == "Noble") then
|
|
||||||
# subName = "." .. item.name
|
|
||||||
# end
|
|
||||||
<li><a href="#$(item.name)">$(subName)</a></li>
|
|
||||||
# end
|
|
||||||
</ul>
|
|
||||||
# end
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
# end
|
|
||||||
|
|
||||||
|
|
||||||
# -------- contents of project ----------
|
|
||||||
# local this_mod = module and module.name
|
|
||||||
<div class="nav-modules">
|
|
||||||
# for kind, mods, type in ldoc.kinds() do
|
|
||||||
<div class="nav-kind">
|
|
||||||
# if ldoc.allowed_in_contents(type,module) then
|
|
||||||
<h3>$(kind)</h3>
|
|
||||||
<ul>
|
|
||||||
# for mod in mods() do
|
|
||||||
# local name = display_name(mod)
|
|
||||||
# if mod.name == this_mod then
|
|
||||||
<li><span class="selected">$(name)</span></li>
|
|
||||||
# else
|
|
||||||
<li><a href="$(ldoc.ref_to_module(mod))">$(name)</a></li>
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
</ul>
|
|
||||||
# end
|
|
||||||
</div>
|
|
||||||
# end
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="content">
|
|
||||||
|
|
||||||
# if ldoc.body then -- verbatim HTML as contents; 'non-code' entries
|
|
||||||
$(ldoc.body)
|
|
||||||
# elseif module then -- module documentation
|
|
||||||
<h1>$(module.name)</h1>
|
|
||||||
<p>$(M(module.summary,module))</p>
|
|
||||||
<p>$(M(module.description,module))</p>
|
|
||||||
# if module.tags.include then
|
|
||||||
$(M(ldoc.include_file(module.tags.include)))
|
|
||||||
# end
|
|
||||||
# if module.see then
|
|
||||||
# local li,il = use_li(module.see)
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
# for see in iter(module.see) do
|
|
||||||
$(li)<a href="$(ldoc.href(see))">$(see.label)</a>$(il)
|
|
||||||
# end
|
|
||||||
</ul>
|
|
||||||
# end
|
|
||||||
# if module.usage then
|
|
||||||
# local li,il = use_li(module.usage)
|
|
||||||
<h3>Usage</h3>
|
|
||||||
# for usage in iter(module.usage) do
|
|
||||||
<pre class="example">$(ldoc.escape(usage))</pre>
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
# if module.info then
|
|
||||||
<h3>Info</h3>
|
|
||||||
<ul>
|
|
||||||
# for tag, value in module.info:iter() do
|
|
||||||
<li><strong>$(tag)</strong>: $(M(value,module))</li>
|
|
||||||
# end
|
|
||||||
</ul>
|
|
||||||
# end
|
|
||||||
|
|
||||||
<hr/>
|
|
||||||
|
|
||||||
# --- currently works for both Functions and Tables. The params field either contains
|
|
||||||
# --- function parameters or table fields.
|
|
||||||
# local show_return = not ldoc.no_return_or_parms
|
|
||||||
# local show_parms = show_return
|
|
||||||
# for kind, items in module.kinds() do
|
|
||||||
# local kitem = module.kinds:get_item(kind)
|
|
||||||
# local has_description = kitem and ldoc.descript(kitem) ~= ""
|
|
||||||
# kind = kind:gsub("modules.", ""):gsub(" Functions", "")
|
|
||||||
<h2 class="section-header $(has_description and 'has-description')"><a name="$(no_spaces(kind))"></a>$(kind)</h2>
|
|
||||||
<!-- $(M(module.kinds:get_section_description(kind),nil)) -->
|
|
||||||
# if kitem then
|
|
||||||
# if has_description then
|
|
||||||
<div class="section-description">
|
|
||||||
$(M(ldoc.descript(kitem),kitem))
|
|
||||||
</div>
|
|
||||||
# end
|
|
||||||
# if kitem.usage then
|
|
||||||
<h3>Usage</h3>
|
|
||||||
<pre class="example">$(ldoc.prettify(kitem.usage[1]))</pre>
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
<dl class="function">
|
|
||||||
# for item in items() do
|
|
||||||
<dt>
|
|
||||||
<a name = "$(item.name)"></a>
|
|
||||||
<span class="item-name">$(display_name(item))<span>
|
|
||||||
# if ldoc.prettify_files and ldoc.is_file_prettified[item.module.file.filename] then
|
|
||||||
<a style="float:right;" href="$(ldoc.source_ref(item))">line $(item.lineno)</a>
|
|
||||||
# end
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
$(M(ldoc.descript(item),item))
|
|
||||||
# if ldoc.custom_tags then
|
|
||||||
# for custom in iter(ldoc.custom_tags) do
|
|
||||||
# local tag = item.tags[custom[1]]
|
|
||||||
# if tag and not custom.hidden then
|
|
||||||
# local li,il = use_li(tag)
|
|
||||||
<h3>$(custom.title or custom[1])</h3>
|
|
||||||
<ul>
|
|
||||||
# for value in iter(tag) do
|
|
||||||
$(li)$(custom.format and custom.format(value) or M(value))$(il)
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
</ul>
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
|
|
||||||
# if show_parms and item.params and #item.params > 0 then
|
|
||||||
# local subnames = module.kinds:type_of(item).subnames
|
|
||||||
# if subnames then
|
|
||||||
<h3>$(subnames)</h3>
|
|
||||||
# end
|
|
||||||
<ul class="parameters">
|
|
||||||
# for parm in iter(item.params) do
|
|
||||||
# local param,sublist = item:subparam(parm)
|
|
||||||
# if sublist then
|
|
||||||
<li><span class="parameter">$(sublist)</span>$(M(item.params.map[sublist],item))
|
|
||||||
<ul>
|
|
||||||
# end
|
|
||||||
# for p in iter(param) do
|
|
||||||
# local name,tp,def = item:display_name_of(p), ldoc.typename(item:type_of_param(p)), item:default_of_param(p)
|
|
||||||
<li><span class="parameter">$(name)</span>
|
|
||||||
# if tp ~= '' then
|
|
||||||
<span class="types">$(tp)</span>
|
|
||||||
# end
|
|
||||||
# if def == true then
|
|
||||||
<span class="optional">(optional)</span>
|
|
||||||
# elseif def then
|
|
||||||
<span class="default">= <span class="value">$(def)</span> (default)</span>
|
|
||||||
# end
|
|
||||||
# if item:readonly(p) then
|
|
||||||
<em>readonly</em>
|
|
||||||
# end
|
|
||||||
<br/>
|
|
||||||
$(M(item.params.map[p],item))
|
|
||||||
</li>
|
|
||||||
# end
|
|
||||||
# if sublist then
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
</ul>
|
|
||||||
# end
|
|
||||||
|
|
||||||
# if show_return and item.retgroups then local groups = item.retgroups
|
|
||||||
<h3>Returns</h3>
|
|
||||||
# for i,group in ldoc.ipairs(groups) do local li,il = use_li(group)
|
|
||||||
<ol>
|
|
||||||
# for r in group:iter() do local type, ctypes = item:return_type(r); local rt = ldoc.typename(type)
|
|
||||||
$(li)
|
|
||||||
# if rt ~= '' then
|
|
||||||
<span class="types">$(rt)</span>
|
|
||||||
# end
|
|
||||||
$(M(r.text,item))$(il)
|
|
||||||
# if ctypes then
|
|
||||||
<ul>
|
|
||||||
# for c in ctypes:iter() do
|
|
||||||
<li><span class="parameter">$(c.name)</span>
|
|
||||||
<span class="types">$(ldoc.typename(c.type))</span>
|
|
||||||
$(M(c.comment,item))
|
|
||||||
</li>
|
|
||||||
# end
|
|
||||||
</ul>
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
</ol>
|
|
||||||
# if i < #groups then
|
|
||||||
<h3>Or</h3>
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
|
|
||||||
# if show_return and item.raise then
|
|
||||||
<h3>Raises</h3>
|
|
||||||
$(M(item.raise,item))
|
|
||||||
# end
|
|
||||||
|
|
||||||
# if item.see then
|
|
||||||
# local li,il = use_li(item.see)
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
# for see in iter(item.see) do
|
|
||||||
$(li)<a href="$(ldoc.href(see))">$(see.label)</a>$(il)
|
|
||||||
# end
|
|
||||||
</ul>
|
|
||||||
# end
|
|
||||||
|
|
||||||
# if item.usage then
|
|
||||||
# local li,il = use_li(item.usage)
|
|
||||||
<h3>Usage</h3>
|
|
||||||
# for usage in iter(item.usage) do
|
|
||||||
<pre class="example">$(ldoc.prettify(usage))</pre>
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
# end -- for items
|
|
||||||
</dl>
|
|
||||||
# end
|
|
||||||
|
|
||||||
# else -- if module; project-level contents
|
|
||||||
|
|
||||||
# if ldoc.description then
|
|
||||||
<h2>$(M(ldoc.description,nil))</h2>
|
|
||||||
# end
|
|
||||||
# if ldoc.full_description then
|
|
||||||
<p>$(M(ldoc.full_description,nil))</p>
|
|
||||||
# end
|
|
||||||
|
|
||||||
# for kind, mods in ldoc.kinds() do
|
|
||||||
<h2>$(kind)</h2>
|
|
||||||
# kind = kind:lower()
|
|
||||||
<table class="module_list">
|
|
||||||
# for m in mods() do
|
|
||||||
<tr>
|
|
||||||
<td class="name" $(nowrap)><a href="$(no_spaces(kind))/$(m.name).html">$(m.name)</a></td>
|
|
||||||
<td class="summary">$(M(ldoc.strip_header(m.summary),m))</td>
|
|
||||||
</tr>
|
|
||||||
# end
|
|
||||||
</table>
|
|
||||||
# end
|
|
||||||
|
|
||||||
# end -- if module
|
|
||||||
|
|
||||||
</div> <!-- id="content" -->
|
|
||||||
|
|
||||||
</div> <!-- id="main" -->
|
|
||||||
|
|
||||||
<div id="about">
|
|
||||||
<span><a href="https://github.com/NobleRobot/NobleEngine">Noble Engine</a> by Mark LaCroix, <a href="https://noblerobot.com">Noble Robot</a></span>
|
|
||||||
<span style="float:right;">
|
|
||||||
Documentation created using <a href="https://github.com/stevedonovan/LDoc">LDoc $(ldoc.version)</a>.
|
|
||||||
# if not module then
|
|
||||||
Last updated $(ldoc.updatetime)
|
|
||||||
# end
|
|
||||||
</span>
|
|
||||||
</div> <!-- id="about" -->
|
|
||||||
|
|
||||||
</div> <!-- id="container" -->
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
@ -1,443 +0,0 @@
|
|||||||
@import url(https://fonts.googleapis.com/css?family=Quicksand:300,700);
|
|
||||||
@import url(https://fonts.googleapis.com/css?family=Lato);
|
|
||||||
@import url(https://fonts.googleapis.com/css2?family=Source+Code+Pro:wght@200;300;400;600;700;900&display=swap);
|
|
||||||
|
|
||||||
$red: #cf5a5a;
|
|
||||||
$redBright: #eb6e6e;
|
|
||||||
$yellow: #ffcb1f;
|
|
||||||
$blue: #056d8d;
|
|
||||||
$white:#f0ece3;
|
|
||||||
$black:#31302f;
|
|
||||||
|
|
||||||
* {
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
|
||||||
margin: 2em;
|
|
||||||
font-family: "Lato", arial, helvetica, geneva, sans-serif;
|
|
||||||
background-color: $yellow;
|
|
||||||
color: $black;
|
|
||||||
}
|
|
||||||
|
|
||||||
code,
|
|
||||||
tt {
|
|
||||||
font-family: "Source Code Pro", monospace;
|
|
||||||
font-size: 1.1em;
|
|
||||||
letter-spacing: -1px;
|
|
||||||
font-weight: 600;
|
|
||||||
color: $blue;
|
|
||||||
}
|
|
||||||
|
|
||||||
span.types:before { content:": "; }
|
|
||||||
span.types:after { content:""; }
|
|
||||||
|
|
||||||
.type,
|
|
||||||
.default,
|
|
||||||
.optional {
|
|
||||||
color: ($black * 0.65) + ($white *0.35);
|
|
||||||
}
|
|
||||||
.default .value { font-weight: bold; }
|
|
||||||
|
|
||||||
|
|
||||||
.parameters {
|
|
||||||
list-style-type: none;
|
|
||||||
li {
|
|
||||||
margin-bottom: 10px;
|
|
||||||
line-height: 1.5em;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.parameter {
|
|
||||||
font-weight: 600;
|
|
||||||
color: $blue * 0.8;
|
|
||||||
}
|
|
||||||
|
|
||||||
body, td, th { font-size: .95em; line-height: 1.2em;}
|
|
||||||
|
|
||||||
p, ul { margin: 10px 0 0 0px;}
|
|
||||||
|
|
||||||
ul {
|
|
||||||
padding-left: 25px;
|
|
||||||
}
|
|
||||||
|
|
||||||
strong { font-weight: bold;}
|
|
||||||
|
|
||||||
em { font-style: italic;}
|
|
||||||
|
|
||||||
.logo {
|
|
||||||
h1 {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
width: 100%;
|
|
||||||
background-image: url('logo.png');
|
|
||||||
background-repeat: no-repeat;
|
|
||||||
background-position: center;
|
|
||||||
height: 150px;
|
|
||||||
}
|
|
||||||
|
|
||||||
h1 {
|
|
||||||
font-family: 'Quicksand', sans-serif;
|
|
||||||
font-weight: bold;
|
|
||||||
color: $red;
|
|
||||||
font-size: 2.5em;
|
|
||||||
margin: 20px 0 30px 0;
|
|
||||||
}
|
|
||||||
h2, h3, h4 {
|
|
||||||
font-family: 'Quicksand', sans-serif;
|
|
||||||
font-weight: 700;
|
|
||||||
margin: 15px 0 10px 0; }
|
|
||||||
h2 { font-size: 1.25em; color: $red; }
|
|
||||||
h3 { font-size: 1.15em; }
|
|
||||||
h4 { font-size: 1em; }
|
|
||||||
|
|
||||||
.section-header {
|
|
||||||
margin-top: 50px;
|
|
||||||
padding: 10px;
|
|
||||||
padding-left: 15px;
|
|
||||||
margin-left: -25px;
|
|
||||||
border-radius: 50px;
|
|
||||||
border-left: 20px solid $red;
|
|
||||||
background-color: ($white * 0.8) + ($red * 0.20);
|
|
||||||
color: $black;
|
|
||||||
}
|
|
||||||
|
|
||||||
a:link { font-weight: bold; color: $red; text-decoration: none; }
|
|
||||||
a:visited { font-weight: bold; color: $red; text-decoration: none; }
|
|
||||||
a:link:hover { text-decoration: underline; }
|
|
||||||
|
|
||||||
hr {
|
|
||||||
background: $red;
|
|
||||||
border-radius: 100px;
|
|
||||||
height: 6px;
|
|
||||||
margin: 60px 20%;
|
|
||||||
border: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
blockquote { margin-left: 3em; }
|
|
||||||
|
|
||||||
ul { list-style-type: none; }
|
|
||||||
|
|
||||||
p.name {
|
|
||||||
font-family: "Andale Mono", monospace;
|
|
||||||
padding-top: 1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
span.item-name {
|
|
||||||
background-color: ($white*0.25) + ($yellow*0.75);
|
|
||||||
display: inline-block;
|
|
||||||
color: $black;
|
|
||||||
padding: 10px 20px;
|
|
||||||
border-radius: 25px;
|
|
||||||
|
|
||||||
border: 2px solid $yellow*0.75;
|
|
||||||
//border-bottom: none;
|
|
||||||
//border-bottom: 4px solid $red*0.75;
|
|
||||||
|
|
||||||
font-size: 1em;
|
|
||||||
font-family: "Source Code Pro", monospace;
|
|
||||||
font-weight: 700;
|
|
||||||
letter-spacing: -1px;
|
|
||||||
}
|
|
||||||
|
|
||||||
pre {
|
|
||||||
background-color: $blue;
|
|
||||||
border: 2px solid $blue*0.65;
|
|
||||||
box-shadow: 0 0 10px 0 rgba($black, 0.5);
|
|
||||||
border-radius: 15px;
|
|
||||||
color: $white;
|
|
||||||
padding: 15px 20px;
|
|
||||||
margin: 10px 0 10px 0;
|
|
||||||
//font-family: "Andale Mono", monospace;
|
|
||||||
font-family: "Source Code Pro", monospace;
|
|
||||||
//font-size: 20px !important;
|
|
||||||
tab-size: 4;
|
|
||||||
overflow-x: auto;
|
|
||||||
width: 100%;
|
|
||||||
font-weight: 400;
|
|
||||||
.keyword {
|
|
||||||
color: $yellow;
|
|
||||||
}
|
|
||||||
.string, .number {
|
|
||||||
color: $redBright;
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
.comment {
|
|
||||||
color: $white*0.75;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pre.example {
|
|
||||||
font-size: .85em;
|
|
||||||
}
|
|
||||||
|
|
||||||
table.index td { text-align: left; vertical-align: top; }
|
|
||||||
|
|
||||||
#container {
|
|
||||||
margin-left: auto;
|
|
||||||
margin-right: auto;
|
|
||||||
border-radius: 25px;
|
|
||||||
box-shadow: 0 0 25px 0 rgba($black, .3);
|
|
||||||
overflow: hidden;
|
|
||||||
max-width: 1600px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#product {
|
|
||||||
text-align: center;
|
|
||||||
height: 500px;
|
|
||||||
background-color: $black;
|
|
||||||
color: $white;
|
|
||||||
> :before{
|
|
||||||
content: 'Noble Engine';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#product big {
|
|
||||||
font-size: 2em;
|
|
||||||
}
|
|
||||||
|
|
||||||
#main {
|
|
||||||
background-color: $black;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
}
|
|
||||||
|
|
||||||
#navigation {
|
|
||||||
|
|
||||||
flex-grow: 1;
|
|
||||||
flex-shrink: 0;
|
|
||||||
flex-basis: auto;
|
|
||||||
width: 275px;
|
|
||||||
|
|
||||||
padding: 0 10px;
|
|
||||||
|
|
||||||
overflow: hidden;
|
|
||||||
|
|
||||||
color: $white;
|
|
||||||
|
|
||||||
a:link, a:visited {
|
|
||||||
font-weight: normal;
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav-module,
|
|
||||||
.nav-modules {
|
|
||||||
color: $black;
|
|
||||||
padding: 15px;
|
|
||||||
|
|
||||||
a:link, a:visited {
|
|
||||||
color: $black;
|
|
||||||
}
|
|
||||||
|
|
||||||
border-radius: 20px;
|
|
||||||
|
|
||||||
ul {
|
|
||||||
a:active, a:hover, .selected {
|
|
||||||
color: $white;
|
|
||||||
background-color: $red;
|
|
||||||
padding: 5px 10px;
|
|
||||||
margin-left:-10px;
|
|
||||||
border-radius: 30px;
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
.selected{
|
|
||||||
line-height: 2em;
|
|
||||||
margin-left: -28px;
|
|
||||||
padding-left: 28px;
|
|
||||||
border-radius: 0 30px 30px 0;
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.nav-module {
|
|
||||||
background-color: $redBright;
|
|
||||||
margin: 0 -10px 20px 10px;
|
|
||||||
border-radius: 20px 0 0 20px;
|
|
||||||
|
|
||||||
h2 {
|
|
||||||
background-color: $red;
|
|
||||||
color: $white;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
ul {
|
|
||||||
a:active, a:hover {
|
|
||||||
color: $black;
|
|
||||||
background-color: $yellow;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.nav-modules {
|
|
||||||
background-color: ($white*0.8) + ($yellow*0.2);
|
|
||||||
margin: 0 10px 30px 10px;
|
|
||||||
padding-top: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
h1 {
|
|
||||||
color: $redBright;
|
|
||||||
line-height: 80%;
|
|
||||||
font-family: 'Quicksand', sans-serif;
|
|
||||||
font-weight: 900;
|
|
||||||
font-size: 32px;
|
|
||||||
padding-left: 20px;
|
|
||||||
padding-bottom: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
h2 {
|
|
||||||
|
|
||||||
color: $black;
|
|
||||||
font-size:1.1em;
|
|
||||||
|
|
||||||
background-color: $white;
|
|
||||||
padding: 5px 10px;
|
|
||||||
margin-right: 20px;
|
|
||||||
border-radius: 30px;
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
ul {
|
|
||||||
font-size:1em;
|
|
||||||
list-style-type: none;
|
|
||||||
margin: 1px 1px 10px 1px;
|
|
||||||
padding-left: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
li {
|
|
||||||
//font-size: 14px;
|
|
||||||
display: block;
|
|
||||||
margin: 0px 0px 6px 12px;
|
|
||||||
padding-left: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
li li a {
|
|
||||||
margin: 0px 3px 0px -1em;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#content {
|
|
||||||
|
|
||||||
flex-grow: 1;
|
|
||||||
flex-shrink: 1;
|
|
||||||
flex-basis: auto;
|
|
||||||
min-width: 0; // For pre elements...
|
|
||||||
|
|
||||||
//margin-left: 14em;
|
|
||||||
padding: 2em;
|
|
||||||
padding-left:3.5em;
|
|
||||||
border-left: 4px solid $red;
|
|
||||||
box-shadow: inset 0 0 50px 0 rgba($red, 0.25);
|
|
||||||
background-color: $white;
|
|
||||||
}
|
|
||||||
|
|
||||||
#about {
|
|
||||||
clear: both;
|
|
||||||
padding: 20px;
|
|
||||||
border-top: 2px solid $black;
|
|
||||||
background-color: $red;
|
|
||||||
|
|
||||||
color:$white;
|
|
||||||
a:link, a:visited, a:hover, a:active {
|
|
||||||
color: $yellow;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media print {
|
|
||||||
body {
|
|
||||||
font: 12pt "Times New Roman", "TimeNR", Times, serif;
|
|
||||||
}
|
|
||||||
a { font-weight: bold; color: #1c4e68; text-decoration: underline; }
|
|
||||||
|
|
||||||
#main {
|
|
||||||
background-color: #ffffff;
|
|
||||||
border-left: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#container {
|
|
||||||
margin-left: 2%;
|
|
||||||
margin-right: 2%;
|
|
||||||
background-color: #ffffff;
|
|
||||||
}
|
|
||||||
|
|
||||||
#content {
|
|
||||||
padding: 1em;
|
|
||||||
background-color: #ffffff;
|
|
||||||
}
|
|
||||||
|
|
||||||
#navigation {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
pre.example {
|
|
||||||
font-family: "Andale Mono", monospace;
|
|
||||||
font-size: 10pt;
|
|
||||||
page-break-inside: avoid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
table.module_list {
|
|
||||||
border-width: 1px;
|
|
||||||
border-style: solid;
|
|
||||||
border-color: #b1e3fa;
|
|
||||||
border-collapse: collapse;
|
|
||||||
}
|
|
||||||
table.module_list td {
|
|
||||||
border-width: 1px;
|
|
||||||
padding: 3px;
|
|
||||||
border-style: solid;
|
|
||||||
border-color: #b1e3fa;
|
|
||||||
}
|
|
||||||
table.module_list td.name { background-color: #e0f4fc; min-width: 200px; }
|
|
||||||
table.module_list td.summary { width: 100%; }
|
|
||||||
|
|
||||||
|
|
||||||
table.function_list {
|
|
||||||
border-width: 1px;
|
|
||||||
border-style: solid;
|
|
||||||
border-color: #b1e3fa;
|
|
||||||
border-collapse: collapse;
|
|
||||||
}
|
|
||||||
table.function_list td {
|
|
||||||
border-width: 1px;
|
|
||||||
padding: 3px;
|
|
||||||
border-style: solid;
|
|
||||||
border-color: #b1e3fa;
|
|
||||||
}
|
|
||||||
table.function_list td.name { background-color: #e0f4fc; min-width: 200px; }
|
|
||||||
table.function_list td.summary { width: 100%; }
|
|
||||||
|
|
||||||
ul.nowrap {
|
|
||||||
overflow:auto;
|
|
||||||
white-space:nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
dl.table dt,
|
|
||||||
dl.function dt {
|
|
||||||
padding-top: 1em;
|
|
||||||
}
|
|
||||||
dl.table dd,
|
|
||||||
dl.function {
|
|
||||||
dd {
|
|
||||||
padding-bottom: 30px;
|
|
||||||
margin: 10px 0 10px 20px;
|
|
||||||
border-bottom: 2px dotted $blue;
|
|
||||||
}
|
|
||||||
> :last-child {
|
|
||||||
border-bottom: none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dl.table h3,
|
|
||||||
dl.function h3 {
|
|
||||||
font-size: .95em;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* stop sublists from having initial vertical space */
|
|
||||||
ul ul { margin-top: 0px; }
|
|
||||||
ol ul { margin-top: 0px; }
|
|
||||||
ol ol { margin-top: 0px; }
|
|
||||||
ul ol { margin-top: 0px; }
|
|
||||||
|
|
||||||
/* make the target distinct; helps when we're navigating to a function */
|
|
||||||
a:target + * {
|
|
||||||
border: 2px solid $black;
|
|
||||||
border-bottom: 6px solid $black;
|
|
||||||
background-color: $red;
|
|
||||||
color: $white;
|
|
||||||
}
|
|
@ -1,485 +0,0 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
||||||
<html>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
|
||||||
<head>
|
|
||||||
<title>Noble Engine API reference</title>
|
|
||||||
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
|
|
||||||
<link rel="icon" href="favicon.ico">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<div id="container">
|
|
||||||
|
|
||||||
<div id="main">
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Menu -->
|
|
||||||
|
|
||||||
<div id="navigation">
|
|
||||||
<a href="../index.html"><div class="logo">
|
|
||||||
<h1>Noble Engine</h1>
|
|
||||||
</div></a>
|
|
||||||
|
|
||||||
<div class="nav-module">
|
|
||||||
<h2>NobleScene</h2>
|
|
||||||
<ul>
|
|
||||||
<h3>Properties </h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="#noblescene.name">noblescene.name</a></li>
|
|
||||||
<li><a href="#noblescene.backgroundColor">noblescene.backgroundColor</a></li>
|
|
||||||
</ul>
|
|
||||||
<h3>Tables </h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="#noblescene.inputHandler">noblescene.inputHandler</a></li>
|
|
||||||
<li><a href="#noblescene.sprites">noblescene.sprites</a></li>
|
|
||||||
</ul>
|
|
||||||
<h3>Methods</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="#noblescene:addSprite">noblescene:addSprite</a></li>
|
|
||||||
<li><a href="#noblescene:removeSprite">noblescene:removeSprite</a></li>
|
|
||||||
</ul>
|
|
||||||
<h3>Callbacks </h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="#noblescene:init">noblescene:init</a></li>
|
|
||||||
<li><a href="#noblescene:enter">noblescene:enter</a></li>
|
|
||||||
<li><a href="#noblescene:start">noblescene:start</a></li>
|
|
||||||
<li><a href="#noblescene:update">noblescene:update</a></li>
|
|
||||||
<li><a href="#noblescene:drawBackground">noblescene:drawBackground</a></li>
|
|
||||||
<li><a href="#noblescene:exit">noblescene:exit</a></li>
|
|
||||||
<li><a href="#noblescene:finish">noblescene:finish</a></li>
|
|
||||||
<li><a href="#noblescene:pause">noblescene:pause</a></li>
|
|
||||||
<li><a href="#noblescene:resume">noblescene:resume</a></li>
|
|
||||||
</ul>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="nav-modules">
|
|
||||||
<div class="nav-kind">
|
|
||||||
<h3>Classes</h3>
|
|
||||||
<ul>
|
|
||||||
<li><span class="selected">NobleScene</span></li>
|
|
||||||
<li><a href="../classes/NobleSprite.html">NobleSprite</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="nav-kind">
|
|
||||||
<h3>Modules</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../modules/Noble.html">Noble</a></li>
|
|
||||||
<li><a href="../modules/Noble.Animation.html">Noble.Animation</a></li>
|
|
||||||
<li><a href="../modules/Noble.Bonk.html">Noble.Bonk</a></li>
|
|
||||||
<li><a href="../modules/Noble.GameData.html">Noble.GameData</a></li>
|
|
||||||
<li><a href="../modules/Noble.Input.html">Noble.Input</a></li>
|
|
||||||
<li><a href="../modules/Noble.Menu.html">Noble.Menu</a></li>
|
|
||||||
<li><a href="../modules/Noble.Settings.html">Noble.Settings</a></li>
|
|
||||||
<li><a href="../modules/Noble.Text.html">Noble.Text</a></li>
|
|
||||||
<li><a href="../modules/Noble.Transition.html">Noble.Transition</a></li>
|
|
||||||
<li><a href="../modules/Ease.html">Ease</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="nav-kind">
|
|
||||||
<h3>Examples</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../examples/SceneTemplate.lua.html">SceneTemplate.lua</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="content">
|
|
||||||
|
|
||||||
<h1>NobleScene</h1>
|
|
||||||
<p>An abstract scene class.</p>
|
|
||||||
<p> Do not copy this file as a template for your scenes. Instead, your scenes will extend this class.
|
|
||||||
See <a href="../examples/SceneTemplate.lua.html">templates/SceneTemplate.lua</a> for a blank scene that you can copy and modify for your own scenes.
|
|
||||||
If you are using <a href="http://github.com/NobleRobot/NobleEngine-ProjectTemplate">NobleEngine-ProjectTemplate</a>,
|
|
||||||
see <code>scenes/ExampleScene.lua</code> for an implementation example.</p>
|
|
||||||
<h3>Usage</h3>
|
|
||||||
<pre class="example">YourSceneName = {}
|
|
||||||
class("YourSceneName").extends(NobleScene)
|
|
||||||
local scene = YourSceneName
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<hr/>
|
|
||||||
|
|
||||||
<h2 class="section-header "><a name="Properties"></a>Properties </h2>
|
|
||||||
<!-- -->
|
|
||||||
<dl class="function">
|
|
||||||
<dt>
|
|
||||||
<a name = "noblescene.name"></a>
|
|
||||||
<span class="item-name">noblescene.name<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
The name of this scene. Optional.
|
|
||||||
If you do not set this value, it will take on the scene's <code>className</code>.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "noblescene.backgroundColor"></a>
|
|
||||||
<span class="item-name">noblescene.backgroundColor<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
This is the background color of this scene.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
<h2 class="section-header "><a name="Tables"></a>Tables </h2>
|
|
||||||
<!-- -->
|
|
||||||
<dl class="function">
|
|
||||||
<dt>
|
|
||||||
<a name = "noblescene.inputHandler"></a>
|
|
||||||
<span class="item-name">noblescene.inputHandler<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
All scenes have a default inputHandler which is made active when the scene starts.
|
|
||||||
If you do not define your scene's <a href="../classes/NobleScene.html#noblescene.inputHandler">inputHandler</a>, it is <code>nil</code> and input is disabled when this scene
|
|
||||||
starts.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<a href="../modules/Noble.Input.html#Noble.Input.setHandler">Noble.Input.setHandler</a>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3>Usage</h3>
|
|
||||||
<pre class="example">YourSceneName.inputHandler = {
|
|
||||||
AButtonDown = <span class="keyword">function</span>()
|
|
||||||
// Your code here
|
|
||||||
<span class="keyword">end</span>,
|
|
||||||
AButtonHold = <span class="keyword">function</span>()
|
|
||||||
// Your code here
|
|
||||||
<span class="keyword">end</span>,
|
|
||||||
<span class="comment">-- ...
|
|
||||||
</span> <span class="comment">-- ...
|
|
||||||
</span>}
|
|
||||||
<span class="comment">-- OR...
|
|
||||||
</span><span class="comment">-- Use a non-scene-specific inputHandler, defined elsewhere.
|
|
||||||
</span>YourSceneName.inputHandler = somePreviouslyDefinedInputHandler
|
|
||||||
<span class="comment">-- OR...
|
|
||||||
</span><span class="comment">-- Reuse another scene's inputHandler.
|
|
||||||
</span>YourSceneName.inputHandler = SomeOtherSceneName.inputHandler</pre>
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "noblescene.sprites"></a>
|
|
||||||
<span class="item-name">noblescene.sprites<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
When you add a sprite to your scene, it is put in this table so the scene can keep track of it. </p>
|
|
||||||
|
|
||||||
<p> This is intended as <code>read-only</code>. You should not modify this table directly.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<a href="../classes/NobleScene.html#noblescene:addSprite">addSprite</a>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
<h2 class="section-header "><a name="Methods"></a>Methods</h2>
|
|
||||||
<!-- -->
|
|
||||||
<dl class="function">
|
|
||||||
<dt>
|
|
||||||
<a name = "noblescene:addSprite"></a>
|
|
||||||
<span class="item-name">noblescene:addSprite(__sprite)<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Use this to add sprites to your scene instead of <code>playdate.graphics.sprite:add()</code>. </p>
|
|
||||||
|
|
||||||
<p> If your sprite is a <a href="../classes/NobleSprite.html#">NobleSprite</a>, using <code>NobleSprite:add()</code> will also call this method.</p>
|
|
||||||
|
|
||||||
<p> Sprites added with this method that are tracked by the scene. Any not manually removed before transitioning to another scene are automatically removed in <a href="../classes/NobleScene.html#noblescene:finish">finish</a>.
|
|
||||||
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<ul class="parameters">
|
|
||||||
<li><span class="parameter">__sprite</span>
|
|
||||||
<span class="types"><span class="type">playdate.graphics.sprite</span></span>
|
|
||||||
<br/>
|
|
||||||
The sprite to add to the scene.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../classes/NobleSprite.html#noblesprite:add">NobleSprite:add</a></li>
|
|
||||||
<li><a href="../classes/NobleScene.html#noblescene:removeSprite">removeSprite</a></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "noblescene:removeSprite"></a>
|
|
||||||
<span class="item-name">noblescene:removeSprite(__sprite)<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Use this to remove sprites from your scene instead of <code>playdate.graphics.sprite:remove()</code>. </p>
|
|
||||||
|
|
||||||
<p> If your sprite is a <a href="../classes/NobleSprite.html#">NobleSprite</a>, using <code>NobleSprite:remove()</code> will also call this method.</p>
|
|
||||||
|
|
||||||
<p> Sprites not manually removed before transitioning to another scene are automatically removed in <a href="../classes/NobleScene.html#noblescene:finish">finish</a>.
|
|
||||||
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<ul class="parameters">
|
|
||||||
<li><span class="parameter">__sprite</span>
|
|
||||||
<span class="types"><span class="type">playdate.graphics.sprite</span></span>
|
|
||||||
<br/>
|
|
||||||
The sprite to add to the scene.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../classes/NobleSprite.html#noblesprite:remove">NobleSprite:remove</a></li>
|
|
||||||
<li><a href="../classes/NobleScene.html#noblescene:addSprite">addSprite</a></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
<h2 class="section-header "><a name="Callbacks"></a>Callbacks </h2>
|
|
||||||
<!-- -->
|
|
||||||
<dl class="function">
|
|
||||||
<dt>
|
|
||||||
<a name = "noblescene:init"></a>
|
|
||||||
<span class="item-name">noblescene:init()<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Implement this in your scene if you have code to run when your scene's object is created.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Usage</h3>
|
|
||||||
<pre class="example"><span class="keyword">function</span> YourSceneName:<span class="function-name">init</span>()
|
|
||||||
YourSceneName.super.<span class="function-name">init</span>(self)
|
|
||||||
<span class="comment">--[Your code here]--
|
|
||||||
</span><span class="keyword">end</span></pre>
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "noblescene:enter"></a>
|
|
||||||
<span class="item-name">noblescene:enter()<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Implement if you want to run code as the transition to this scene begins, such as UI animation, triggers, etc.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Usage</h3>
|
|
||||||
<pre class="example"><span class="keyword">function</span> YourSceneName:<span class="function-name">enter</span>()
|
|
||||||
YourSceneName.super.<span class="function-name">enter</span>(self)
|
|
||||||
<span class="comment">--[Your code here]--
|
|
||||||
</span><span class="keyword">end</span></pre>
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "noblescene:start"></a>
|
|
||||||
<span class="item-name">noblescene:start()<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Implement if you have code to run once the transition to this scene is complete. This method signifies the full activation of a scene. If this scene's <a href="../classes/NobleScene.html#noblescene.inputHandler">inputHandler</a> is defined, it is enabled now.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<a href="../classes/NobleScene.html#noblescene.inputHandler">inputHandler</a>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3>Usage</h3>
|
|
||||||
<pre class="example"><span class="keyword">function</span> YourSceneName:<span class="function-name">start</span>()
|
|
||||||
YourSceneName.super.<span class="function-name">start</span>(self)
|
|
||||||
<span class="comment">--[Your code here]--
|
|
||||||
</span><span class="keyword">end</span></pre>
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "noblescene:update"></a>
|
|
||||||
<span class="item-name">noblescene:update()<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Implement to run scene-specific code on every frame while this scene is active.
|
|
||||||
<strong>NOTE:</strong> you may use coroutine.yield() here, because it only runs inside of playdate.update(), which is a coroutine.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Usage</h3>
|
|
||||||
<pre class="example"><span class="keyword">function</span> YourSceneName:<span class="function-name">update</span>()
|
|
||||||
YourSceneName.super.<span class="function-name">update</span>(self)
|
|
||||||
<span class="comment">--[Your code here]--
|
|
||||||
</span><span class="keyword">end</span></pre>
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "noblescene:drawBackground"></a>
|
|
||||||
<span class="item-name">noblescene:drawBackground(__x, __y, __width, __height)<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Implement this function to draw background visual elements in your scene.
|
|
||||||
This runs when the engine need to redraw a background area.
|
|
||||||
By default it runs every frame and fills the background with self.backgroundColor. All arguments are optional.
|
|
||||||
Use <code>Graphics.sprite.setAlwaysRedraw(false)</code> after <code>Noble.new()</code> to optimize partial redraw.
|
|
||||||
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<ul class="parameters">
|
|
||||||
<li><span class="parameter">__x</span>
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__y</span>
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__width</span>
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__height</span>
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Usage</h3>
|
|
||||||
<pre class="example"><span class="keyword">function</span> YourSceneName:<span class="function-name">drawBackground</span>(__x, __y, __width, __height)
|
|
||||||
YourSceneName.super.<span class="function-name">drawBackground</span>(self) <span class="comment">-- optional, invokes default behavior.
|
|
||||||
</span> <span class="comment">--[Your code here]--
|
|
||||||
</span><span class="keyword">end</span></pre>
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "noblescene:exit"></a>
|
|
||||||
<span class="item-name">noblescene:exit()<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Implement this in your scene if you have "goodbye" code to run when a transition to another scene
|
|
||||||
begins, such as UI animation, saving to disk, etc.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Usage</h3>
|
|
||||||
<pre class="example"><span class="keyword">function</span> YourSceneName:<span class="function-name">exit</span>()
|
|
||||||
YourSceneName.super.<span class="function-name">exit</span>(self)
|
|
||||||
<span class="comment">--[Your code here]--
|
|
||||||
</span><span class="keyword">end</span></pre>
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "noblescene:finish"></a>
|
|
||||||
<span class="item-name">noblescene:finish()<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Implement this in your scene if you have code to run when a transition to another scene
|
|
||||||
is complete, such as resetting variables.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Usage</h3>
|
|
||||||
<pre class="example"><span class="keyword">function</span> YourSceneName:<span class="function-name">finish</span>()
|
|
||||||
YourSceneName.super.<span class="function-name">finish</span>(self)
|
|
||||||
<span class="comment">--[Your code here]--
|
|
||||||
</span><span class="keyword">end</span></pre>
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "noblescene:pause"></a>
|
|
||||||
<span class="item-name">noblescene:pause()<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
<code>pause()</code> / <code>resume()</code></p>
|
|
||||||
|
|
||||||
<p> Implement one or both of these in your scene if you want something to happen when the game is paused/unpaused
|
|
||||||
by the system. The Playdate SDK does not require you to write pause logic, but these are useful if you want a
|
|
||||||
custom menu image (see Playdate SDK for more details), want to obscure game elements to prevent players from
|
|
||||||
cheating in a time-sensitive game, want to count the number of times the player pauses the game, etc.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Usage</h3>
|
|
||||||
<pre class="example"><span class="keyword">function</span> YourSceneName:<span class="function-name">pause</span>()
|
|
||||||
YourSceneName.super.<span class="function-name">pause</span>(self)
|
|
||||||
<span class="comment">--[Your code here]--
|
|
||||||
</span><span class="keyword">end</span></pre>
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "noblescene:resume"></a>
|
|
||||||
<span class="item-name">noblescene:resume()<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
<span></span>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Usage</h3>
|
|
||||||
<pre class="example"><span class="keyword">function</span> YourSceneName:<span class="function-name">resume</span>()
|
|
||||||
YourSceneName.super.<span class="function-name">resume</span>(self)
|
|
||||||
<span class="comment">--[Your code here]--
|
|
||||||
</span><span class="keyword">end</span></pre>
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
|
|
||||||
|
|
||||||
</div> <!-- id="content" -->
|
|
||||||
|
|
||||||
</div> <!-- id="main" -->
|
|
||||||
|
|
||||||
<div id="about">
|
|
||||||
<span><a href="https://github.com/NobleRobot/NobleEngine">Noble Engine</a> by Mark LaCroix, <a href="https://noblerobot.com">Noble Robot</a></span>
|
|
||||||
<span style="float:right;">
|
|
||||||
Documentation created using <a href="https://github.com/stevedonovan/LDoc">LDoc 1.5.0</a>.
|
|
||||||
</span>
|
|
||||||
</div> <!-- id="about" -->
|
|
||||||
|
|
||||||
</div> <!-- id="container" -->
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
@ -1,290 +0,0 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
||||||
<html>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
|
||||||
<head>
|
|
||||||
<title>Noble Engine API reference</title>
|
|
||||||
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
|
|
||||||
<link rel="icon" href="favicon.ico">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<div id="container">
|
|
||||||
|
|
||||||
<div id="main">
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Menu -->
|
|
||||||
|
|
||||||
<div id="navigation">
|
|
||||||
<a href="../index.html"><div class="logo">
|
|
||||||
<h1>Noble Engine</h1>
|
|
||||||
</div></a>
|
|
||||||
|
|
||||||
<div class="nav-module">
|
|
||||||
<h2>NobleSprite</h2>
|
|
||||||
<ul>
|
|
||||||
<h3>Fields</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="#self.animation">self.animation</a></li>
|
|
||||||
</ul>
|
|
||||||
<h3>Methods</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="#noblesprite:init">noblesprite:init</a></li>
|
|
||||||
<li><a href="#noblesprite:play">noblesprite:play</a></li>
|
|
||||||
<li><a href="#noblesprite:pause">noblesprite:pause</a></li>
|
|
||||||
<li><a href="#noblesprite:stop">noblesprite:stop</a></li>
|
|
||||||
<li><a href="#noblesprite:add">noblesprite:add</a></li>
|
|
||||||
<li><a href="#noblesprite:remove">noblesprite:remove</a></li>
|
|
||||||
</ul>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="nav-modules">
|
|
||||||
<div class="nav-kind">
|
|
||||||
<h3>Classes</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../classes/NobleScene.html">NobleScene</a></li>
|
|
||||||
<li><span class="selected">NobleSprite</span></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="nav-kind">
|
|
||||||
<h3>Modules</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../modules/Noble.html">Noble</a></li>
|
|
||||||
<li><a href="../modules/Noble.Animation.html">Noble.Animation</a></li>
|
|
||||||
<li><a href="../modules/Noble.Bonk.html">Noble.Bonk</a></li>
|
|
||||||
<li><a href="../modules/Noble.GameData.html">Noble.GameData</a></li>
|
|
||||||
<li><a href="../modules/Noble.Input.html">Noble.Input</a></li>
|
|
||||||
<li><a href="../modules/Noble.Menu.html">Noble.Menu</a></li>
|
|
||||||
<li><a href="../modules/Noble.Settings.html">Noble.Settings</a></li>
|
|
||||||
<li><a href="../modules/Noble.Text.html">Noble.Text</a></li>
|
|
||||||
<li><a href="../modules/Noble.Transition.html">Noble.Transition</a></li>
|
|
||||||
<li><a href="../modules/Ease.html">Ease</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="nav-kind">
|
|
||||||
<h3>Examples</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../examples/SceneTemplate.lua.html">SceneTemplate.lua</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="content">
|
|
||||||
|
|
||||||
<h1>NobleSprite</h1>
|
|
||||||
<p>An extension of Playdate's sprite object, incorporating <a href="../modules/Noble.Animation.html#">Noble.Animation</a> and other Noble Engine features.</p>
|
|
||||||
<p> Use this in place of <code>playdate.graphics.sprite</code> in most cases.</p>
|
|
||||||
|
|
||||||
<p> <a href="../classes/NobleSprite.html#">NobleSprite</a> is a child class of <code>playdate.graphics.sprite</code>, so see the Playdate SDK documentation for additional methods and properties.</p>
|
|
||||||
|
|
||||||
<hr/>
|
|
||||||
|
|
||||||
<h2 class="section-header "><a name="Fields"></a>Fields</h2>
|
|
||||||
<!-- -->
|
|
||||||
<dl class="function">
|
|
||||||
<dt>
|
|
||||||
<a name = "self.animation"></a>
|
|
||||||
<span class="item-name">self.animation<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
The animation for this NobleSprite.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<a href="../modules/Noble.Animation.html#Noble.Animation.new">Noble.Animation.new</a>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
<h2 class="section-header "><a name="Methods"></a>Methods</h2>
|
|
||||||
<!-- -->
|
|
||||||
<dl class="function">
|
|
||||||
<dt>
|
|
||||||
<a name = "noblesprite:init"></a>
|
|
||||||
<span class="item-name">noblesprite:init([__view[, __viewIsSpritesheet=false[, __singleState=false[, __singleStateLoop=true]]]])<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Do not call an "init" method directly. Use <code>NobleSprite()</code> (see usage examples).
|
|
||||||
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<ul class="parameters">
|
|
||||||
<li><span class="parameter">__view</span>
|
|
||||||
<span class="types"><span class="type">string</span></span>
|
|
||||||
<span class="optional">(optional)</span>
|
|
||||||
<br/>
|
|
||||||
This can be: the path to an image or spritesheet image file, an image object (<code>Graphics.image</code>) or an animation object (<a href="../modules/Noble.Animation.html#">Noble.Animation</a>)
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__viewIsSpritesheet</span>
|
|
||||||
<span class="types"><span class="type">boolean</span></span>
|
|
||||||
<span class="default">= <span class="value">false</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
Set this to <code>true</code> to indicate that <code>__view</code> is a spritesheet. Will only be considered if <code>__view</code> is a string path to an image.
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__singleState</span>
|
|
||||||
<span class="types"><span class="type">boolean</span></span>
|
|
||||||
<span class="default">= <span class="value">false</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
If this sprite has just one animation, set this to true. It saves you from having to use Noble.Animation.addState()
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__singleStateLoop</span>
|
|
||||||
<span class="types"><span class="type">boolean</span></span>
|
|
||||||
<span class="default">= <span class="value">true</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
If using a single state animation, should it loop?
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../modules/Noble.Animation.html#animation:addState">Noble.Animation:addState</a></li>
|
|
||||||
<li><a href="../modules/Noble.Animation.html#Noble.Animation.new">Noble.Animation.new</a></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3>Usage</h3>
|
|
||||||
<pre class="example"><span class="comment">-- Provide a spritesheet image file to create a new <a href="../modules/Noble.Animation.html#">Noble.Animation</a> for a NobleSprite's view.
|
|
||||||
</span>myNobleSprite = <span class="function-name">NobleSprite</span>(<span class="string">"path/to/spritesheet"</span>, <span class="keyword">true</span>)</pre>
|
|
||||||
<pre class="example"><span class="comment">-- Provide an image file to create a new <code>Graphics.image</code> for a NobleSprite's view.
|
|
||||||
</span>myNobleSprite = <span class="function-name">NobleSprite</span>(<span class="string">"path/to/image"</span>)</pre>
|
|
||||||
<pre class="example"><span class="comment">-- Use an existing <a href="../modules/Noble.Animation.html#">Noble.Animation</a> for a NobleSprite's view.
|
|
||||||
</span> <span class="keyword">local</span> myAnimation = Noble.Animation.<span class="function-name">new</span>(<span class="string">"path/to/spritesheet"</span>)
|
|
||||||
myAnimation:<span class="function-name">addState</span>(<span class="string">"default"</span>, <span class="number">1</span>, animation.imageTable:<span class="function-name">getLength</span>(), <span class="keyword">nil</span>, <span class="keyword">true</span>)
|
|
||||||
myNobleSprite = <span class="function-name">NobleSprite</span>(myAnimation)</pre>
|
|
||||||
<pre class="example"><span class="comment">-- Use an existing <code>Graphics.image</code> object for a NobleSprite's view.
|
|
||||||
</span> <span class="keyword">local</span> myImage = Graphics.image.<span class="function-name">new</span>(<span class="string">"path/to/image"</span>)
|
|
||||||
myNobleSprite = <span class="function-name">NobleSprite</span>(myImage)</pre>
|
|
||||||
<pre class="example"><span class="comment">-- Extending NobleSprite.
|
|
||||||
</span>
|
|
||||||
<span class="comment">-- MyCustomSprite.lua
|
|
||||||
</span>MyCustomSprite = {}
|
|
||||||
<span class="function-name">class</span>(<span class="string">"MyCustomSprite"</span>).<span class="function-name">extends</span>(NobleSprite)
|
|
||||||
|
|
||||||
<span class="keyword">function</span> MyCustomSprite:<span class="function-name">init</span>(__x, __y, __anotherFunArgument)
|
|
||||||
MyCustomSprite.super.<span class="function-name">init</span>(self, <span class="string">"path/to/spritesheet"</span>, <span class="keyword">true</span>)
|
|
||||||
<span class="comment">-- Etc. etc.
|
|
||||||
</span><span class="keyword">end</span>
|
|
||||||
|
|
||||||
<span class="comment">-- MyNobleScene.lua
|
|
||||||
</span>myNobleSprite = <span class="function-name">MyCustomSprite</span>(<span class="number">100</span>, <span class="number">100</span>, <span class="string">"Fun!"</span>)</pre>
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "noblesprite:play"></a>
|
|
||||||
<span class="item-name">noblesprite:play()<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
This will enable the update loop for this NobleSprite, which also causes its Noble.Animation to play.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "noblesprite:pause"></a>
|
|
||||||
<span class="item-name">noblesprite:pause()<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
This will disable the update loop for this NobleSprite, which also causes its Noble.Animation to pause.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "noblesprite:stop"></a>
|
|
||||||
<span class="item-name">noblesprite:stop()<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
This will disable the update loop for this NobleSprite, and also reset its Noble.Animation (if it exists) to the first frame of its current state.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "noblesprite:add"></a>
|
|
||||||
<span class="item-name">noblesprite:add(__x, __y)<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Use this to add this NobleSprite to your scene. This replaces <code>playdate.graphics.sprite:add()</code> to allow NobleSprites to be tracked by the current NobleScene.</p>
|
|
||||||
|
|
||||||
<p> To add a <code>playdate.graphics.sprite</code> to a scene, use <code>NobleScene:addSprite(__sprite)</code>.
|
|
||||||
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<ul class="parameters">
|
|
||||||
<li><span class="parameter">__x</span>
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__y</span>
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<a href="../classes/NobleScene.html#noblescene:addSprite">NobleScene:addSprite</a>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "noblesprite:remove"></a>
|
|
||||||
<span class="item-name">noblesprite:remove()<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Use this to remove this NobleSprite from your scene. This replaces <code>playdate.graphics.sprite:remove()</code> to allow NobleSprites to be tracked by the current NobleScene.</p>
|
|
||||||
|
|
||||||
<p> To remove a <code>playdate.graphics.sprite</code> from a scene, use <code>NobleScene:removeSprite(__sprite)</code>.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<a href="../classes/NobleScene.html#noblescene:removeSprite">NobleScene:removeSprite</a>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
|
|
||||||
|
|
||||||
</div> <!-- id="content" -->
|
|
||||||
|
|
||||||
</div> <!-- id="main" -->
|
|
||||||
|
|
||||||
<div id="about">
|
|
||||||
<span><a href="https://github.com/NobleRobot/NobleEngine">Noble Engine</a> by Mark LaCroix, <a href="https://noblerobot.com">Noble Robot</a></span>
|
|
||||||
<span style="float:right;">
|
|
||||||
Documentation created using <a href="https://github.com/stevedonovan/LDoc">LDoc 1.5.0</a>.
|
|
||||||
</span>
|
|
||||||
</div> <!-- id="about" -->
|
|
||||||
|
|
||||||
</div> <!-- id="container" -->
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
Before Width: | Height: | Size: 288 KiB |
@ -1,264 +0,0 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
||||||
<html>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
|
||||||
<head>
|
|
||||||
<title>Noble Engine API reference</title>
|
|
||||||
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
|
|
||||||
<link rel="icon" href="favicon.ico">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<div id="container">
|
|
||||||
|
|
||||||
<div id="main">
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Menu -->
|
|
||||||
|
|
||||||
<div id="navigation">
|
|
||||||
<a href="../index.html"><div class="logo">
|
|
||||||
<h1>Noble Engine</h1>
|
|
||||||
</div></a>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div class="nav-modules">
|
|
||||||
<div class="nav-kind">
|
|
||||||
<h3>Examples</h3>
|
|
||||||
<ul>
|
|
||||||
<li><span class="selected">SceneTemplate.lua</span></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="nav-kind">
|
|
||||||
<h3>Modules</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../modules/Noble.html">Noble</a></li>
|
|
||||||
<li><a href="../modules/Noble.Animation.html">Noble.Animation</a></li>
|
|
||||||
<li><a href="../modules/Noble.Bonk.html">Noble.Bonk</a></li>
|
|
||||||
<li><a href="../modules/Noble.GameData.html">Noble.GameData</a></li>
|
|
||||||
<li><a href="../modules/Noble.Input.html">Noble.Input</a></li>
|
|
||||||
<li><a href="../modules/Noble.Menu.html">Noble.Menu</a></li>
|
|
||||||
<li><a href="../modules/Noble.Settings.html">Noble.Settings</a></li>
|
|
||||||
<li><a href="../modules/Noble.Text.html">Noble.Text</a></li>
|
|
||||||
<li><a href="../modules/Noble.Transition.html">Noble.Transition</a></li>
|
|
||||||
<li><a href="../modules/Ease.html">Ease</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="nav-kind">
|
|
||||||
<h3>Classes</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../classes/NobleScene.html">NobleScene</a></li>
|
|
||||||
<li><a href="../classes/NobleSprite.html">NobleSprite</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="content">
|
|
||||||
|
|
||||||
<h2>SceneTemplate.lua</h2>
|
|
||||||
<pre>
|
|
||||||
<span class="comment">--
|
|
||||||
</span><span class="comment">-- SceneTemplate.lua
|
|
||||||
</span><span class="comment">--
|
|
||||||
</span><span class="comment">-- Use this as a starting point for your game's scenes.
|
|
||||||
</span><span class="comment">-- Copy this file to your root "scenes" directory,
|
|
||||||
</span><span class="comment">-- and rename it.
|
|
||||||
</span><span class="comment">--
|
|
||||||
</span>
|
|
||||||
<span class="comment">-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
||||||
</span><span class="comment">-- !!! Rename "SceneTemplate" to your scene's name in these first three lines. !!!
|
|
||||||
</span><span class="comment">-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
||||||
</span>
|
|
||||||
SceneTemplate = {}
|
|
||||||
<span class="function-name">class</span>(<span class="string">"SceneTemplate"</span>).<span class="function-name">extends</span>(NobleScene)
|
|
||||||
<span class="keyword">local</span> scene = SceneTemplate
|
|
||||||
|
|
||||||
<span class="comment">-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
||||||
</span><span class="comment">-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
||||||
</span>
|
|
||||||
<span class="comment">-- It is recommended that you declare, but don't yet define,
|
|
||||||
</span><span class="comment">-- your scene-specific varibles and methods here. Use "local" where possible.
|
|
||||||
</span><span class="comment">--
|
|
||||||
</span><span class="comment">-- local variable1 = nil -- local variable
|
|
||||||
</span><span class="comment">-- scene.variable2 = nil -- Scene variable.
|
|
||||||
</span><span class="comment">-- When accessed outside this file use <code>SceneTemplate.variable2</code>.
|
|
||||||
</span><span class="comment">-- ...
|
|
||||||
</span><span class="comment">--
|
|
||||||
</span>
|
|
||||||
<span class="comment">-- This is the background color of this scene.
|
|
||||||
</span>scene.backgroundColor = Graphics.kColorWhite
|
|
||||||
|
|
||||||
<span class="comment">-- This runs when your scene's object is created, which is the
|
|
||||||
</span><span class="comment">-- first thing that happens when transitining away from another scene.
|
|
||||||
</span><span class="keyword">function</span> scene:<span class="function-name">init</span>()
|
|
||||||
scene.super.<span class="function-name">init</span>(self)
|
|
||||||
|
|
||||||
<span class="comment">-- variable1 = 100
|
|
||||||
</span> <span class="comment">-- SceneTemplate.variable2 = "string"
|
|
||||||
</span> <span class="comment">-- ...
|
|
||||||
</span>
|
|
||||||
<span class="comment">-- Your code here
|
|
||||||
</span><span class="keyword">end</span>
|
|
||||||
|
|
||||||
<span class="comment">-- When transitioning from another scene, this runs as soon as this
|
|
||||||
</span><span class="comment">-- scene needs to be visible (this moment depends on which transition type is used).
|
|
||||||
</span><span class="keyword">function</span> scene:<span class="function-name">enter</span>()
|
|
||||||
scene.super.<span class="function-name">enter</span>(self)
|
|
||||||
<span class="comment">-- Your code here
|
|
||||||
</span><span class="keyword">end</span>
|
|
||||||
|
|
||||||
<span class="comment">-- This runs once a transition from another scene is complete.
|
|
||||||
</span><span class="keyword">function</span> scene:<span class="function-name">start</span>()
|
|
||||||
scene.super.<span class="function-name">start</span>(self)
|
|
||||||
<span class="comment">-- Your code here
|
|
||||||
</span><span class="keyword">end</span>
|
|
||||||
|
|
||||||
<span class="comment">-- This runs once per frame.
|
|
||||||
</span><span class="keyword">function</span> scene:<span class="function-name">update</span>()
|
|
||||||
scene.super.<span class="function-name">update</span>(self)
|
|
||||||
<span class="comment">-- Your code here
|
|
||||||
</span><span class="keyword">end</span>
|
|
||||||
|
|
||||||
<span class="comment">-- This runs once per frame, and is meant for drawing code.
|
|
||||||
</span><span class="keyword">function</span> scene:<span class="function-name">drawBackground</span>()
|
|
||||||
scene.super.<span class="function-name">drawBackground</span>(self)
|
|
||||||
<span class="comment">-- Your code here
|
|
||||||
</span><span class="keyword">end</span>
|
|
||||||
|
|
||||||
<span class="comment">-- This runs as as soon as a transition to another scene begins.
|
|
||||||
</span><span class="keyword">function</span> scene:<span class="function-name">exit</span>()
|
|
||||||
scene.super.<span class="function-name">exit</span>(self)
|
|
||||||
<span class="comment">-- Your code here
|
|
||||||
</span><span class="keyword">end</span>
|
|
||||||
|
|
||||||
<span class="comment">-- This runs once a transition to another scene completes.
|
|
||||||
</span><span class="keyword">function</span> scene:<span class="function-name">finish</span>()
|
|
||||||
scene.super.<span class="function-name">finish</span>(self)
|
|
||||||
<span class="comment">-- Your code here
|
|
||||||
</span><span class="keyword">end</span>
|
|
||||||
|
|
||||||
<span class="keyword">function</span> scene:<span class="function-name">pause</span>()
|
|
||||||
scene.super.<span class="function-name">pause</span>(self)
|
|
||||||
<span class="comment">-- Your code here
|
|
||||||
</span><span class="keyword">end</span>
|
|
||||||
<span class="keyword">function</span> scene:<span class="function-name">resume</span>()
|
|
||||||
scene.super.<span class="function-name">resume</span>(self)
|
|
||||||
<span class="comment">-- Your code here
|
|
||||||
</span><span class="keyword">end</span>
|
|
||||||
|
|
||||||
<span class="comment">-- Define the inputHander for this scene here, or use a previously defined inputHandler.
|
|
||||||
</span>
|
|
||||||
<span class="comment">-- scene.inputHandler = someOtherInputHandler
|
|
||||||
</span><span class="comment">-- OR
|
|
||||||
</span>scene.inputHandler = {
|
|
||||||
|
|
||||||
<span class="comment">-- A button
|
|
||||||
</span> <span class="comment">--
|
|
||||||
</span> AButtonDown = <span class="keyword">function</span>() <span class="comment">-- Runs once when button is pressed.
|
|
||||||
</span> <span class="comment">-- Your code here
|
|
||||||
</span> <span class="keyword">end</span>,
|
|
||||||
AButtonHold = <span class="keyword">function</span>() <span class="comment">-- Runs every frame while the player is holding button down.
|
|
||||||
</span> <span class="comment">-- Your code here
|
|
||||||
</span> <span class="keyword">end</span>,
|
|
||||||
AButtonHeld = <span class="keyword">function</span>() <span class="comment">-- Runs after button is held for 1 second.
|
|
||||||
</span> <span class="comment">-- Your code here
|
|
||||||
</span> <span class="keyword">end</span>,
|
|
||||||
AButtonUp = <span class="keyword">function</span>() <span class="comment">-- Runs once when button is released.
|
|
||||||
</span> <span class="comment">-- Your code here
|
|
||||||
</span> <span class="keyword">end</span>,
|
|
||||||
|
|
||||||
<span class="comment">-- B button
|
|
||||||
</span> <span class="comment">--
|
|
||||||
</span> BButtonDown = <span class="keyword">function</span>()
|
|
||||||
<span class="comment">-- Your code here
|
|
||||||
</span> <span class="keyword">end</span>,
|
|
||||||
BButtonHeld = <span class="keyword">function</span>()
|
|
||||||
<span class="comment">-- Your code here
|
|
||||||
</span> <span class="keyword">end</span>,
|
|
||||||
BButtonHold = <span class="keyword">function</span>()
|
|
||||||
<span class="comment">-- Your code here
|
|
||||||
</span> <span class="keyword">end</span>,
|
|
||||||
BButtonUp = <span class="keyword">function</span>()
|
|
||||||
<span class="comment">-- Your code here
|
|
||||||
</span> <span class="keyword">end</span>,
|
|
||||||
|
|
||||||
<span class="comment">-- D-pad left
|
|
||||||
</span> <span class="comment">--
|
|
||||||
</span> leftButtonDown = <span class="keyword">function</span>()
|
|
||||||
<span class="comment">-- Your code here
|
|
||||||
</span> <span class="keyword">end</span>,
|
|
||||||
leftButtonHold = <span class="keyword">function</span>()
|
|
||||||
<span class="comment">-- Your code here
|
|
||||||
</span> <span class="keyword">end</span>,
|
|
||||||
leftButtonUp = <span class="keyword">function</span>()
|
|
||||||
<span class="comment">-- Your code here
|
|
||||||
</span> <span class="keyword">end</span>,
|
|
||||||
|
|
||||||
<span class="comment">-- D-pad right
|
|
||||||
</span> <span class="comment">--
|
|
||||||
</span> rightButtonDown = <span class="keyword">function</span>()
|
|
||||||
<span class="comment">-- Your code here
|
|
||||||
</span> <span class="keyword">end</span>,
|
|
||||||
rightButtonHold = <span class="keyword">function</span>()
|
|
||||||
<span class="comment">-- Your code here
|
|
||||||
</span> <span class="keyword">end</span>,
|
|
||||||
rightButtonUp = <span class="keyword">function</span>()
|
|
||||||
<span class="comment">-- Your code here
|
|
||||||
</span> <span class="keyword">end</span>,
|
|
||||||
|
|
||||||
<span class="comment">-- D-pad up
|
|
||||||
</span> <span class="comment">--
|
|
||||||
</span> upButtonDown = <span class="keyword">function</span>()
|
|
||||||
<span class="comment">-- Your code here
|
|
||||||
</span> <span class="keyword">end</span>,
|
|
||||||
upButtonHold = <span class="keyword">function</span>()
|
|
||||||
<span class="comment">-- Your code here
|
|
||||||
</span> <span class="keyword">end</span>,
|
|
||||||
upButtonUp = <span class="keyword">function</span>()
|
|
||||||
<span class="comment">-- Your code here
|
|
||||||
</span> <span class="keyword">end</span>,
|
|
||||||
|
|
||||||
<span class="comment">-- D-pad down
|
|
||||||
</span> <span class="comment">--
|
|
||||||
</span> downButtonDown = <span class="keyword">function</span>()
|
|
||||||
<span class="comment">-- Your code here
|
|
||||||
</span> <span class="keyword">end</span>,
|
|
||||||
downButtonHold = <span class="keyword">function</span>()
|
|
||||||
<span class="comment">-- Your code here
|
|
||||||
</span> <span class="keyword">end</span>,
|
|
||||||
downButtonUp = <span class="keyword">function</span>()
|
|
||||||
<span class="comment">-- Your code here
|
|
||||||
</span> <span class="keyword">end</span>,
|
|
||||||
|
|
||||||
<span class="comment">-- Crank
|
|
||||||
</span> <span class="comment">--
|
|
||||||
</span> cranked = <span class="keyword">function</span>(change, acceleratedChange) <span class="comment">-- Runs when the crank is rotated. See Playdate SDK documentation for details.
|
|
||||||
</span> <span class="comment">-- Your code here
|
|
||||||
</span> <span class="keyword">end</span>,
|
|
||||||
crankDocked = <span class="keyword">function</span>() <span class="comment">-- Runs once when when crank is docked.
|
|
||||||
</span> <span class="comment">-- Your code here
|
|
||||||
</span> <span class="keyword">end</span>,
|
|
||||||
crankUndocked = <span class="keyword">function</span>() <span class="comment">-- Runs once when when crank is undocked.
|
|
||||||
</span> <span class="comment">-- Your code here
|
|
||||||
</span> <span class="keyword">end</span>
|
|
||||||
}</pre>
|
|
||||||
|
|
||||||
|
|
||||||
</div> <!-- id="content" -->
|
|
||||||
|
|
||||||
</div> <!-- id="main" -->
|
|
||||||
|
|
||||||
<div id="about">
|
|
||||||
<span><a href="https://github.com/NobleRobot/NobleEngine">Noble Engine</a> by Mark LaCroix, <a href="https://noblerobot.com">Noble Robot</a></span>
|
|
||||||
<span style="float:right;">
|
|
||||||
Documentation created using <a href="https://github.com/stevedonovan/LDoc">LDoc 1.5.0</a>.
|
|
||||||
</span>
|
|
||||||
</div> <!-- id="about" -->
|
|
||||||
|
|
||||||
</div> <!-- id="container" -->
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
Before Width: | Height: | Size: 288 KiB |
@ -1,142 +0,0 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
||||||
<html>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
|
||||||
<head>
|
|
||||||
<title>Noble Engine API reference</title>
|
|
||||||
<link rel="stylesheet" href="ldoc.css" type="text/css" />
|
|
||||||
<link rel="icon" href="favicon.ico">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<div id="container">
|
|
||||||
|
|
||||||
<div id="main">
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Menu -->
|
|
||||||
|
|
||||||
<div id="navigation">
|
|
||||||
<a href="../index.html"><div class="logo">
|
|
||||||
<h1>Noble Engine</h1>
|
|
||||||
</div></a>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div class="nav-modules">
|
|
||||||
<div class="nav-kind">
|
|
||||||
<h3>Modules</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="modules/Noble.html">Noble</a></li>
|
|
||||||
<li><a href="modules/Noble.Animation.html">Noble.Animation</a></li>
|
|
||||||
<li><a href="modules/Noble.Bonk.html">Noble.Bonk</a></li>
|
|
||||||
<li><a href="modules/Noble.GameData.html">Noble.GameData</a></li>
|
|
||||||
<li><a href="modules/Noble.Input.html">Noble.Input</a></li>
|
|
||||||
<li><a href="modules/Noble.Menu.html">Noble.Menu</a></li>
|
|
||||||
<li><a href="modules/Noble.Settings.html">Noble.Settings</a></li>
|
|
||||||
<li><a href="modules/Noble.Text.html">Noble.Text</a></li>
|
|
||||||
<li><a href="modules/Noble.Transition.html">Noble.Transition</a></li>
|
|
||||||
<li><a href="modules/Ease.html">Ease</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="nav-kind">
|
|
||||||
<h3>Classes</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="classes/NobleScene.html">NobleScene</a></li>
|
|
||||||
<li><a href="classes/NobleSprite.html">NobleSprite</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="nav-kind">
|
|
||||||
<h3>Examples</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="examples/SceneTemplate.lua.html">SceneTemplate.lua</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="content">
|
|
||||||
|
|
||||||
|
|
||||||
<h2>A li'l game engine for Playdate.</h2>
|
|
||||||
|
|
||||||
<h2>Modules</h2>
|
|
||||||
<table class="module_list">
|
|
||||||
<tr>
|
|
||||||
<td class="name" ><a href="modules/Noble.html">Noble</a></td>
|
|
||||||
<td class="summary">A li'l game engine for Playdate.</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="name" ><a href="modules/Noble.Animation.html">Noble.Animation</a></td>
|
|
||||||
<td class="summary">Animation states using a spritesheet/imagetable.</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="name" ><a href="modules/Noble.Bonk.html">Noble.Bonk</a></td>
|
|
||||||
<td class="summary">Engine-specific error handling.</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="name" ><a href="modules/Noble.GameData.html">Noble.GameData</a></td>
|
|
||||||
<td class="summary">Operations for game data / save slots.</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="name" ><a href="modules/Noble.Input.html">Noble.Input</a></td>
|
|
||||||
<td class="summary">A complete encapsulation of the Playdate's input system.</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="name" ><a href="modules/Noble.Menu.html">Noble.Menu</a></td>
|
|
||||||
<td class="summary">An extended implementation of <code>playdate.ui.gridview</code>, meant for 1-dimensional, single-screen text menus.</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="name" ><a href="modules/Noble.Settings.html">Noble.Settings</a></td>
|
|
||||||
<td class="summary">Operations for game settings / stats.</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="name" ><a href="modules/Noble.Text.html">Noble.Text</a></td>
|
|
||||||
<td class="summary">Text and font handling.</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="name" ><a href="modules/Noble.Transition.html">Noble.Transition</a></td>
|
|
||||||
<td class="summary">An abstract class from which transition types are extended.</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="name" ><a href="modules/Ease.html">Ease</a></td>
|
|
||||||
<td class="summary">Extensions to <code>playdate.easingFunctions</code>, aliased as <a href="modules/Ease.html#">Ease</a> in Noble Engine.</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<h2>Classes</h2>
|
|
||||||
<table class="module_list">
|
|
||||||
<tr>
|
|
||||||
<td class="name" ><a href="classes/NobleScene.html">NobleScene</a></td>
|
|
||||||
<td class="summary">An abstract scene class.</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="name" ><a href="classes/NobleSprite.html">NobleSprite</a></td>
|
|
||||||
<td class="summary">An extension of Playdate's sprite object, incorporating <a href="modules/Noble.Animation.html#">Noble.Animation</a> and other Noble Engine features.</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<h2>Examples</h2>
|
|
||||||
<table class="module_list">
|
|
||||||
<tr>
|
|
||||||
<td class="name" ><a href="examples/SceneTemplate.lua.html">SceneTemplate.lua</a></td>
|
|
||||||
<td class="summary"></td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
|
|
||||||
</div> <!-- id="content" -->
|
|
||||||
|
|
||||||
</div> <!-- id="main" -->
|
|
||||||
|
|
||||||
<div id="about">
|
|
||||||
<span><a href="https://github.com/NobleRobot/NobleEngine">Noble Engine</a> by Mark LaCroix, <a href="https://noblerobot.com">Noble Robot</a></span>
|
|
||||||
<span style="float:right;">
|
|
||||||
Documentation created using <a href="https://github.com/stevedonovan/LDoc">LDoc 1.5.0</a>.
|
|
||||||
Last updated 2024-04-28 21:37:43
|
|
||||||
</span>
|
|
||||||
</div> <!-- id="about" -->
|
|
||||||
|
|
||||||
</div> <!-- id="container" -->
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
@ -1,524 +0,0 @@
|
|||||||
@import url(https://fonts.googleapis.com/css?family=Quicksand:300,700);
|
|
||||||
@import url(https://fonts.googleapis.com/css?family=Lato);
|
|
||||||
@import url(https://fonts.googleapis.com/css2?family=Source+Code+Pro:wght@200;300;400;600;700;900&display=swap);
|
|
||||||
* {
|
|
||||||
-webkit-box-sizing: border-box;
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
|
||||||
margin: 2em;
|
|
||||||
font-family: "Lato", arial, helvetica, geneva, sans-serif;
|
|
||||||
background-color: #ffcb1f;
|
|
||||||
color: #31302f;
|
|
||||||
}
|
|
||||||
|
|
||||||
code,
|
|
||||||
tt {
|
|
||||||
font-family: "Source Code Pro", monospace;
|
|
||||||
font-size: 1.1em;
|
|
||||||
letter-spacing: -1px;
|
|
||||||
font-weight: 600;
|
|
||||||
color: #056d8d;
|
|
||||||
}
|
|
||||||
|
|
||||||
span.types:before {
|
|
||||||
content: ": ";
|
|
||||||
}
|
|
||||||
|
|
||||||
span.types:after {
|
|
||||||
content: "";
|
|
||||||
}
|
|
||||||
|
|
||||||
.type,
|
|
||||||
.default,
|
|
||||||
.optional {
|
|
||||||
color: #74726e;
|
|
||||||
}
|
|
||||||
|
|
||||||
.default .value {
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
.parameters {
|
|
||||||
list-style-type: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.parameters li {
|
|
||||||
margin-bottom: 10px;
|
|
||||||
line-height: 1.5em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.parameter {
|
|
||||||
font-weight: 600;
|
|
||||||
color: #045771;
|
|
||||||
}
|
|
||||||
|
|
||||||
body, td, th {
|
|
||||||
font-size: .95em;
|
|
||||||
line-height: 1.2em;
|
|
||||||
}
|
|
||||||
|
|
||||||
p, ul {
|
|
||||||
margin: 10px 0 0 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
ul {
|
|
||||||
padding-left: 25px;
|
|
||||||
}
|
|
||||||
|
|
||||||
strong {
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
em {
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
|
|
||||||
.logo {
|
|
||||||
width: 100%;
|
|
||||||
background-image: url("logo.png");
|
|
||||||
background-repeat: no-repeat;
|
|
||||||
background-position: center;
|
|
||||||
height: 150px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.logo h1 {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
h1 {
|
|
||||||
font-family: 'Quicksand', sans-serif;
|
|
||||||
font-weight: bold;
|
|
||||||
color: #cf5a5a;
|
|
||||||
font-size: 2.5em;
|
|
||||||
margin: 20px 0 30px 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
h2, h3, h4 {
|
|
||||||
font-family: 'Quicksand', sans-serif;
|
|
||||||
font-weight: 700;
|
|
||||||
margin: 15px 0 10px 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
h2 {
|
|
||||||
font-size: 1.25em;
|
|
||||||
color: #cf5a5a;
|
|
||||||
}
|
|
||||||
|
|
||||||
h3 {
|
|
||||||
font-size: 1.15em;
|
|
||||||
}
|
|
||||||
|
|
||||||
h4 {
|
|
||||||
font-size: 1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.section-header {
|
|
||||||
margin-top: 50px;
|
|
||||||
padding: 10px;
|
|
||||||
padding-left: 15px;
|
|
||||||
margin-left: -25px;
|
|
||||||
border-radius: 50px;
|
|
||||||
border-left: 20px solid #cf5a5a;
|
|
||||||
background-color: #e9cfc8;
|
|
||||||
color: #31302f;
|
|
||||||
}
|
|
||||||
|
|
||||||
a:link {
|
|
||||||
font-weight: bold;
|
|
||||||
color: #cf5a5a;
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
a:visited {
|
|
||||||
font-weight: bold;
|
|
||||||
color: #cf5a5a;
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
a:link:hover {
|
|
||||||
text-decoration: underline;
|
|
||||||
}
|
|
||||||
|
|
||||||
hr {
|
|
||||||
background: #cf5a5a;
|
|
||||||
border-radius: 100px;
|
|
||||||
height: 6px;
|
|
||||||
margin: 60px 20%;
|
|
||||||
border: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
blockquote {
|
|
||||||
margin-left: 3em;
|
|
||||||
}
|
|
||||||
|
|
||||||
ul {
|
|
||||||
list-style-type: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
p.name {
|
|
||||||
font-family: "Andale Mono", monospace;
|
|
||||||
padding-top: 1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
span.item-name {
|
|
||||||
background-color: #fbd350;
|
|
||||||
display: inline-block;
|
|
||||||
color: #31302f;
|
|
||||||
padding: 10px 20px;
|
|
||||||
border-radius: 25px;
|
|
||||||
border: 2px solid #bf9817;
|
|
||||||
font-size: 1em;
|
|
||||||
font-family: "Source Code Pro", monospace;
|
|
||||||
font-weight: 700;
|
|
||||||
letter-spacing: -1px;
|
|
||||||
}
|
|
||||||
|
|
||||||
pre {
|
|
||||||
background-color: #056d8d;
|
|
||||||
border: 2px solid #03475c;
|
|
||||||
-webkit-box-shadow: 0 0 10px 0 rgba(49, 48, 47, 0.5);
|
|
||||||
box-shadow: 0 0 10px 0 rgba(49, 48, 47, 0.5);
|
|
||||||
border-radius: 15px;
|
|
||||||
color: #f0ece3;
|
|
||||||
padding: 15px 20px;
|
|
||||||
margin: 10px 0 10px 0;
|
|
||||||
font-family: "Source Code Pro", monospace;
|
|
||||||
-moz-tab-size: 4;
|
|
||||||
-o-tab-size: 4;
|
|
||||||
tab-size: 4;
|
|
||||||
overflow-x: auto;
|
|
||||||
width: 100%;
|
|
||||||
font-weight: 400;
|
|
||||||
}
|
|
||||||
|
|
||||||
pre .keyword {
|
|
||||||
color: #ffcb1f;
|
|
||||||
}
|
|
||||||
|
|
||||||
pre .string, pre .number {
|
|
||||||
color: #eb6e6e;
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
pre .comment {
|
|
||||||
color: #b4b1aa;
|
|
||||||
}
|
|
||||||
|
|
||||||
pre.example {
|
|
||||||
font-size: .85em;
|
|
||||||
}
|
|
||||||
|
|
||||||
table.index td {
|
|
||||||
text-align: left;
|
|
||||||
vertical-align: top;
|
|
||||||
}
|
|
||||||
|
|
||||||
#container {
|
|
||||||
margin-left: auto;
|
|
||||||
margin-right: auto;
|
|
||||||
border-radius: 25px;
|
|
||||||
-webkit-box-shadow: 0 0 25px 0 rgba(49, 48, 47, 0.3);
|
|
||||||
box-shadow: 0 0 25px 0 rgba(49, 48, 47, 0.3);
|
|
||||||
overflow: hidden;
|
|
||||||
max-width: 1600px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#product {
|
|
||||||
text-align: center;
|
|
||||||
height: 500px;
|
|
||||||
background-color: #31302f;
|
|
||||||
color: #f0ece3;
|
|
||||||
}
|
|
||||||
|
|
||||||
#product > :before {
|
|
||||||
content: 'Noble Engine';
|
|
||||||
}
|
|
||||||
|
|
||||||
#product big {
|
|
||||||
font-size: 2em;
|
|
||||||
}
|
|
||||||
|
|
||||||
#main {
|
|
||||||
background-color: #31302f;
|
|
||||||
display: -webkit-box;
|
|
||||||
display: -ms-flexbox;
|
|
||||||
display: flex;
|
|
||||||
-webkit-box-orient: horizontal;
|
|
||||||
-webkit-box-direction: normal;
|
|
||||||
-ms-flex-direction: row;
|
|
||||||
flex-direction: row;
|
|
||||||
}
|
|
||||||
|
|
||||||
#navigation {
|
|
||||||
-webkit-box-flex: 1;
|
|
||||||
-ms-flex-positive: 1;
|
|
||||||
flex-grow: 1;
|
|
||||||
-ms-flex-negative: 0;
|
|
||||||
flex-shrink: 0;
|
|
||||||
-ms-flex-preferred-size: auto;
|
|
||||||
flex-basis: auto;
|
|
||||||
width: 275px;
|
|
||||||
padding: 0 10px;
|
|
||||||
overflow: hidden;
|
|
||||||
color: #f0ece3;
|
|
||||||
}
|
|
||||||
|
|
||||||
#navigation a:link, #navigation a:visited {
|
|
||||||
font-weight: normal;
|
|
||||||
}
|
|
||||||
|
|
||||||
#navigation .nav-module,
|
|
||||||
#navigation .nav-modules {
|
|
||||||
color: #31302f;
|
|
||||||
padding: 15px;
|
|
||||||
border-radius: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#navigation .nav-module a:link, #navigation .nav-module a:visited,
|
|
||||||
#navigation .nav-modules a:link,
|
|
||||||
#navigation .nav-modules a:visited {
|
|
||||||
color: #31302f;
|
|
||||||
}
|
|
||||||
|
|
||||||
#navigation .nav-module ul a:active, #navigation .nav-module ul a:hover, #navigation .nav-module ul .selected,
|
|
||||||
#navigation .nav-modules ul a:active,
|
|
||||||
#navigation .nav-modules ul a:hover,
|
|
||||||
#navigation .nav-modules ul .selected {
|
|
||||||
color: #f0ece3;
|
|
||||||
background-color: #cf5a5a;
|
|
||||||
padding: 5px 10px;
|
|
||||||
margin-left: -10px;
|
|
||||||
border-radius: 30px;
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
#navigation .nav-module ul .selected,
|
|
||||||
#navigation .nav-modules ul .selected {
|
|
||||||
line-height: 2em;
|
|
||||||
margin-left: -28px;
|
|
||||||
padding-left: 28px;
|
|
||||||
border-radius: 0 30px 30px 0;
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
#navigation .nav-module {
|
|
||||||
background-color: #eb6e6e;
|
|
||||||
margin: 0 -10px 20px 10px;
|
|
||||||
border-radius: 20px 0 0 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#navigation .nav-module h2 {
|
|
||||||
background-color: #cf5a5a;
|
|
||||||
color: #f0ece3;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#navigation .nav-module ul a:active, #navigation .nav-module ul a:hover {
|
|
||||||
color: #31302f;
|
|
||||||
background-color: #ffcb1f;
|
|
||||||
}
|
|
||||||
|
|
||||||
#navigation .nav-modules {
|
|
||||||
background-color: #f3e5bc;
|
|
||||||
margin: 0 10px 30px 10px;
|
|
||||||
padding-top: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#navigation h1 {
|
|
||||||
color: #eb6e6e;
|
|
||||||
line-height: 80%;
|
|
||||||
font-family: 'Quicksand', sans-serif;
|
|
||||||
font-weight: 900;
|
|
||||||
font-size: 32px;
|
|
||||||
padding-left: 20px;
|
|
||||||
padding-bottom: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#navigation h2 {
|
|
||||||
color: #31302f;
|
|
||||||
font-size: 1.1em;
|
|
||||||
background-color: #f0ece3;
|
|
||||||
padding: 5px 10px;
|
|
||||||
margin-right: 20px;
|
|
||||||
border-radius: 30px;
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
#navigation ul {
|
|
||||||
font-size: 1em;
|
|
||||||
list-style-type: none;
|
|
||||||
margin: 1px 1px 10px 1px;
|
|
||||||
padding-left: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#navigation li {
|
|
||||||
display: block;
|
|
||||||
margin: 0px 0px 6px 12px;
|
|
||||||
padding-left: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#navigation li li a {
|
|
||||||
margin: 0px 3px 0px -1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
#content {
|
|
||||||
-webkit-box-flex: 1;
|
|
||||||
-ms-flex-positive: 1;
|
|
||||||
flex-grow: 1;
|
|
||||||
-ms-flex-negative: 1;
|
|
||||||
flex-shrink: 1;
|
|
||||||
-ms-flex-preferred-size: auto;
|
|
||||||
flex-basis: auto;
|
|
||||||
min-width: 0;
|
|
||||||
padding: 2em;
|
|
||||||
padding-left: 3.5em;
|
|
||||||
border-left: 4px solid #cf5a5a;
|
|
||||||
-webkit-box-shadow: inset 0 0 50px 0 rgba(207, 90, 90, 0.25);
|
|
||||||
box-shadow: inset 0 0 50px 0 rgba(207, 90, 90, 0.25);
|
|
||||||
background-color: #f0ece3;
|
|
||||||
}
|
|
||||||
|
|
||||||
#about {
|
|
||||||
clear: both;
|
|
||||||
padding: 20px;
|
|
||||||
border-top: 2px solid #31302f;
|
|
||||||
background-color: #cf5a5a;
|
|
||||||
color: #f0ece3;
|
|
||||||
}
|
|
||||||
|
|
||||||
#about a:link, #about a:visited, #about a:hover, #about a:active {
|
|
||||||
color: #ffcb1f;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media print {
|
|
||||||
body {
|
|
||||||
font: 12pt "Times New Roman", "TimeNR", Times, serif;
|
|
||||||
}
|
|
||||||
a {
|
|
||||||
font-weight: bold;
|
|
||||||
color: #1c4e68;
|
|
||||||
text-decoration: underline;
|
|
||||||
}
|
|
||||||
#main {
|
|
||||||
background-color: #ffffff;
|
|
||||||
border-left: 0px;
|
|
||||||
}
|
|
||||||
#container {
|
|
||||||
margin-left: 2%;
|
|
||||||
margin-right: 2%;
|
|
||||||
background-color: #ffffff;
|
|
||||||
}
|
|
||||||
#content {
|
|
||||||
padding: 1em;
|
|
||||||
background-color: #ffffff;
|
|
||||||
}
|
|
||||||
#navigation {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
pre.example {
|
|
||||||
font-family: "Andale Mono", monospace;
|
|
||||||
font-size: 10pt;
|
|
||||||
page-break-inside: avoid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
table.module_list {
|
|
||||||
border-width: 1px;
|
|
||||||
border-style: solid;
|
|
||||||
border-color: #b1e3fa;
|
|
||||||
border-collapse: collapse;
|
|
||||||
}
|
|
||||||
|
|
||||||
table.module_list td {
|
|
||||||
border-width: 1px;
|
|
||||||
padding: 3px;
|
|
||||||
border-style: solid;
|
|
||||||
border-color: #b1e3fa;
|
|
||||||
}
|
|
||||||
|
|
||||||
table.module_list td.name {
|
|
||||||
background-color: #e0f4fc;
|
|
||||||
min-width: 200px;
|
|
||||||
}
|
|
||||||
|
|
||||||
table.module_list td.summary {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
table.function_list {
|
|
||||||
border-width: 1px;
|
|
||||||
border-style: solid;
|
|
||||||
border-color: #b1e3fa;
|
|
||||||
border-collapse: collapse;
|
|
||||||
}
|
|
||||||
|
|
||||||
table.function_list td {
|
|
||||||
border-width: 1px;
|
|
||||||
padding: 3px;
|
|
||||||
border-style: solid;
|
|
||||||
border-color: #b1e3fa;
|
|
||||||
}
|
|
||||||
|
|
||||||
table.function_list td.name {
|
|
||||||
background-color: #e0f4fc;
|
|
||||||
min-width: 200px;
|
|
||||||
}
|
|
||||||
|
|
||||||
table.function_list td.summary {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
ul.nowrap {
|
|
||||||
overflow: auto;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
dl.table dt,
|
|
||||||
dl.function dt {
|
|
||||||
padding-top: 1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
dl.table dd dd,
|
|
||||||
dl.function dd {
|
|
||||||
padding-bottom: 30px;
|
|
||||||
margin: 10px 0 10px 20px;
|
|
||||||
border-bottom: 2px dotted #056d8d;
|
|
||||||
}
|
|
||||||
|
|
||||||
dl.table dd > :last-child,
|
|
||||||
dl.function > :last-child {
|
|
||||||
border-bottom: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
dl.table h3,
|
|
||||||
dl.function h3 {
|
|
||||||
font-size: .95em;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* stop sublists from having initial vertical space */
|
|
||||||
ul ul {
|
|
||||||
margin-top: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
ol ul {
|
|
||||||
margin-top: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
ol ol {
|
|
||||||
margin-top: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
ul ol {
|
|
||||||
margin-top: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* make the target distinct; helps when we're navigating to a function */
|
|
||||||
a:target + * {
|
|
||||||
border: 2px solid #31302f;
|
|
||||||
border-bottom: 6px solid #31302f;
|
|
||||||
background-color: #cf5a5a;
|
|
||||||
color: #f0ece3;
|
|
||||||
}
|
|
||||||
/*# sourceMappingURL=ldoc.css.map */
|
|
Before Width: | Height: | Size: 1.2 KiB |
@ -1,176 +0,0 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
||||||
<html>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
|
||||||
<head>
|
|
||||||
<title>Noble Engine API reference</title>
|
|
||||||
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
|
|
||||||
<link rel="icon" href="favicon.ico">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<div id="container">
|
|
||||||
|
|
||||||
<div id="main">
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Menu -->
|
|
||||||
|
|
||||||
<div id="navigation">
|
|
||||||
<a href="../index.html"><div class="logo">
|
|
||||||
<h1>Noble Engine</h1>
|
|
||||||
</div></a>
|
|
||||||
|
|
||||||
<div class="nav-module">
|
|
||||||
<h2>Ease</h2>
|
|
||||||
<ul>
|
|
||||||
<h3>Functions</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="#enter">enter</a></li>
|
|
||||||
<li><a href="#exit">exit</a></li>
|
|
||||||
<li><a href="#reverse">reverse</a></li>
|
|
||||||
</ul>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="nav-modules">
|
|
||||||
<div class="nav-kind">
|
|
||||||
<h3>Modules</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../modules/Noble.html">Noble</a></li>
|
|
||||||
<li><a href="../modules/Noble.Animation.html">Noble.Animation</a></li>
|
|
||||||
<li><a href="../modules/Noble.Bonk.html">Noble.Bonk</a></li>
|
|
||||||
<li><a href="../modules/Noble.GameData.html">Noble.GameData</a></li>
|
|
||||||
<li><a href="../modules/Noble.Input.html">Noble.Input</a></li>
|
|
||||||
<li><a href="../modules/Noble.Menu.html">Noble.Menu</a></li>
|
|
||||||
<li><a href="../modules/Noble.Settings.html">Noble.Settings</a></li>
|
|
||||||
<li><a href="../modules/Noble.Text.html">Noble.Text</a></li>
|
|
||||||
<li><a href="../modules/Noble.Transition.html">Noble.Transition</a></li>
|
|
||||||
<li><span class="selected">Ease</span></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="nav-kind">
|
|
||||||
<h3>Classes</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../classes/NobleScene.html">NobleScene</a></li>
|
|
||||||
<li><a href="../classes/NobleSprite.html">NobleSprite</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="nav-kind">
|
|
||||||
<h3>Examples</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../examples/SceneTemplate.lua.html">SceneTemplate.lua</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="content">
|
|
||||||
|
|
||||||
<h1>Ease</h1>
|
|
||||||
<p>Extensions to <code>playdate.easingFunctions</code>, aliased as <a href="../modules/Ease.html#">Ease</a> in Noble Engine.</p>
|
|
||||||
<p> See the Playdate SDK for a list of easing functions.</p>
|
|
||||||
|
|
||||||
<hr/>
|
|
||||||
|
|
||||||
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
|
|
||||||
<!-- -->
|
|
||||||
<dl class="function">
|
|
||||||
<dt>
|
|
||||||
<a name = "enter"></a>
|
|
||||||
<span class="item-name">enter(__easingFunction)<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Returns the first half of an "inOut" or "outIn" easing function.
|
|
||||||
Returns <code>nil</code> for any easing function that isn't in the form of <code>Ease.inOutXxxx</code> or <code>Ease.outInXxxx</code>. <code>Ease.linear</code> returns itself.
|
|
||||||
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<ul class="parameters">
|
|
||||||
<li><span class="parameter">__easingFunction</span>
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Usage</h3>
|
|
||||||
<pre class="example"><span class="keyword">local</span> ease = Ease.outInQuad
|
|
||||||
<span class="keyword">local</span> easeEnter = Ease.<span class="function-name">enter</span>(ease) <span class="comment">-- Returns "Ease.outQuad"</span></pre>
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "exit"></a>
|
|
||||||
<span class="item-name">exit(__easingFunction)<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Returns the second half of an "inOut" or "outIn" easing function.
|
|
||||||
Returns <code>nil</code> for any easing function that isn't in the form of <code>Ease.inOutXxxx</code> or <code>Ease.outInXxxx</code>. <code>Ease.linear</code> returns itself.
|
|
||||||
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<ul class="parameters">
|
|
||||||
<li><span class="parameter">__easingFunction</span>
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Usage</h3>
|
|
||||||
<pre class="example"><span class="keyword">local</span> ease = Ease.outInQuad
|
|
||||||
<span class="keyword">local</span> easeExit = Ease.<span class="function-name">exit</span>(ease) <span class="comment">-- Returns "Ease.inQuad"</span></pre>
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "reverse"></a>
|
|
||||||
<span class="item-name">reverse(__easingFunction)<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Returns the reverse function of the provided function.
|
|
||||||
Returns <code>nil</code> for any easing function that isn't in the form of <code>Ease.inXxxx</code> or <code>Ease.outXxxx</code>. <code>Ease.linear</code> returns itself.
|
|
||||||
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<ul class="parameters">
|
|
||||||
<li><span class="parameter">__easingFunction</span>
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Usage</h3>
|
|
||||||
<pre class="example"><span class="keyword">local</span> ease = Ease.inQuad
|
|
||||||
<span class="keyword">local</span> reverseEase = Ease.<span class="function-name">reverse</span>(ease) <span class="comment">-- Returns "Ease.outQuad"</span></pre>
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
|
|
||||||
|
|
||||||
</div> <!-- id="content" -->
|
|
||||||
|
|
||||||
</div> <!-- id="main" -->
|
|
||||||
|
|
||||||
<div id="about">
|
|
||||||
<span><a href="https://github.com/NobleRobot/NobleEngine">Noble Engine</a> by Mark LaCroix, <a href="https://noblerobot.com">Noble Robot</a></span>
|
|
||||||
<span style="float:right;">
|
|
||||||
Documentation created using <a href="https://github.com/stevedonovan/LDoc">LDoc 1.5.0</a>.
|
|
||||||
</span>
|
|
||||||
</div> <!-- id="about" -->
|
|
||||||
|
|
||||||
</div> <!-- id="container" -->
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
@ -1,507 +0,0 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
||||||
<html>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
|
||||||
<head>
|
|
||||||
<title>Noble Engine API reference</title>
|
|
||||||
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
|
|
||||||
<link rel="icon" href="favicon.ico">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<div id="container">
|
|
||||||
|
|
||||||
<div id="main">
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Menu -->
|
|
||||||
|
|
||||||
<div id="navigation">
|
|
||||||
<a href="../index.html"><div class="logo">
|
|
||||||
<h1>Noble Engine</h1>
|
|
||||||
</div></a>
|
|
||||||
|
|
||||||
<div class="nav-module">
|
|
||||||
<h2>Noble.Animation</h2>
|
|
||||||
<ul>
|
|
||||||
<h3>Setup </h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="#Noble.Animation.new">.new</a></li>
|
|
||||||
<li><a href="#animation:addState">animation:addState</a></li>
|
|
||||||
</ul>
|
|
||||||
<h3>Properties </h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="#animation.current">animation.current</a></li>
|
|
||||||
<li><a href="#animation.currentName">animation.currentName</a></li>
|
|
||||||
<li><a href="#animation.currentFrame">animation.currentFrame</a></li>
|
|
||||||
<li><a href="#animation.direction">animation.direction</a></li>
|
|
||||||
</ul>
|
|
||||||
<h3>Methods </h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="#animation:setState">animation:setState</a></li>
|
|
||||||
<li><a href="#animation:draw">animation:draw</a></li>
|
|
||||||
<li><a href="#animation:drawFrame">animation:drawFrame</a></li>
|
|
||||||
</ul>
|
|
||||||
<h3>Constants </h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="#Noble.Animation.DIRECTION_RIGHT">.DIRECTION_RIGHT</a></li>
|
|
||||||
<li><a href="#Noble.Animation.DIRECTION_LEFT">.DIRECTION_LEFT</a></li>
|
|
||||||
</ul>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="nav-modules">
|
|
||||||
<div class="nav-kind">
|
|
||||||
<h3>Modules</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../modules/Noble.html">Noble</a></li>
|
|
||||||
<li><span class="selected">Noble.Animation</span></li>
|
|
||||||
<li><a href="../modules/Noble.Bonk.html">Noble.Bonk</a></li>
|
|
||||||
<li><a href="../modules/Noble.GameData.html">Noble.GameData</a></li>
|
|
||||||
<li><a href="../modules/Noble.Input.html">Noble.Input</a></li>
|
|
||||||
<li><a href="../modules/Noble.Menu.html">Noble.Menu</a></li>
|
|
||||||
<li><a href="../modules/Noble.Settings.html">Noble.Settings</a></li>
|
|
||||||
<li><a href="../modules/Noble.Text.html">Noble.Text</a></li>
|
|
||||||
<li><a href="../modules/Noble.Transition.html">Noble.Transition</a></li>
|
|
||||||
<li><a href="../modules/Ease.html">Ease</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="nav-kind">
|
|
||||||
<h3>Classes</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../classes/NobleScene.html">NobleScene</a></li>
|
|
||||||
<li><a href="../classes/NobleSprite.html">NobleSprite</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="nav-kind">
|
|
||||||
<h3>Examples</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../examples/SceneTemplate.lua.html">SceneTemplate.lua</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="content">
|
|
||||||
|
|
||||||
<h1>Noble.Animation</h1>
|
|
||||||
<p>Animation states using a spritesheet/imagetable.</p>
|
|
||||||
<p> Ideal for use with <a href="../classes/NobleSprite.html#">NobleSprite</a> objects. Suitable for other uses as well.</p>
|
|
||||||
|
|
||||||
<hr/>
|
|
||||||
|
|
||||||
<h2 class="section-header "><a name="Setup"></a>Setup </h2>
|
|
||||||
<!-- -->
|
|
||||||
<dl class="function">
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.Animation.new"></a>
|
|
||||||
<span class="item-name">Noble.Animation.new(__view)<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Create a new animation "state machine". This function is called automatically when creating a new <a href="../classes/NobleSprite.html#">NobleSprite</a>.
|
|
||||||
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<ul class="parameters">
|
|
||||||
<li><span class="parameter">__view</span>
|
|
||||||
<span class="types"><span class="type">string</span></span>
|
|
||||||
<br/>
|
|
||||||
This can be: the path to a spritesheet image file or an image table object (<code>Graphics.imagetable</code>). See Playdate SDK docs for imagetable file naming conventions.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3>Returns</h3>
|
|
||||||
<ol>
|
|
||||||
|
|
||||||
<code>animation</code>, a new animation object.
|
|
||||||
</ol>
|
|
||||||
|
|
||||||
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<a href="../classes/NobleSprite.html#noblesprite:init">NobleSprite:init</a>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3>Usage</h3>
|
|
||||||
<pre class="example"><span class="keyword">local</span> myHero = <span class="function-name">MyHero</span>(<span class="string">"path/to/spritesheet"</span>)</pre>
|
|
||||||
<pre class="example"><span class="comment">-- When extending NobleSprite (recommended), you don't call Noble.Animation.new(),
|
|
||||||
</span><span class="comment">-- but you do feed its __view argument into MySprite.super.init()...
|
|
||||||
</span>MyHero = {}
|
|
||||||
<span class="function-name">class</span>(<span class="string">"MyHero"</span>).<span class="function-name">extends</span>(NobleSprite)
|
|
||||||
|
|
||||||
<span class="keyword">function</span> MyHero:<span class="function-name">init</span>()
|
|
||||||
MyHero.super.<span class="function-name">init</span>(self, <span class="string">"assets/images/Hero"</span>)
|
|
||||||
<span class="comment">-- ...
|
|
||||||
</span> <span class="comment">-- A new NobleSprite creates a Noble.Animation object named "self.animation"
|
|
||||||
</span> self.animation:<span class="function-name">addState</span>(<span class="string">"idle"</span>, <span class="number">1</span>, <span class="number">30</span>)
|
|
||||||
self.animation:<span class="function-name">addState</span>(<span class="string">"jump"</span>, <span class="number">31</span>, <span class="number">34</span>, <span class="string">"float"</span>)
|
|
||||||
self.animation:<span class="function-name">addState</span>(<span class="string">"float"</span>, <span class="number">35</span>, <span class="number">45</span>)
|
|
||||||
self.animation:<span class="function-name">addState</span>(<span class="string">"turn"</span>, <span class="number">46</span>, <span class="number">55</span>, <span class="string">"idle"</span>)
|
|
||||||
self.animation:<span class="function-name">addState</span>(<span class="string">"walk"</span>, <span class="number">56</span>, <span class="number">65</span>)
|
|
||||||
<span class="comment">-- ...
|
|
||||||
</span><span class="keyword">end</span></pre>
|
|
||||||
<pre class="example"><span class="keyword">local</span> myAnimation = Noble.Animation.<span class="function-name">new</span>(<span class="string">"path/to/spritesheet"</span>)</pre>
|
|
||||||
<pre class="example"><span class="comment">-- When extending playdate.graphics.Sprite, Noble.Animation.new() must be called manually...
|
|
||||||
</span>MyHero = {}
|
|
||||||
<span class="function-name">class</span>(<span class="string">"MyHero"</span>).<span class="function-name">extends</span>(Graphics.sprite)
|
|
||||||
|
|
||||||
<span class="keyword">function</span> MyHero:<span class="function-name">init</span>()
|
|
||||||
MyHero.super.<span class="function-name">init</span>(self)
|
|
||||||
<span class="comment">-- ...
|
|
||||||
</span> self.animation = Noble.Animation.<span class="function-name">new</span>(<span class="string">"assets/images/Hero"</span>)
|
|
||||||
self.animation:<span class="function-name">addState</span>(<span class="string">"idle"</span>, <span class="number">1</span>, <span class="number">30</span>)
|
|
||||||
self.animation:<span class="function-name">addState</span>(<span class="string">"jump"</span>, <span class="number">31</span>, <span class="number">34</span>, <span class="string">"float"</span>)
|
|
||||||
self.animation:<span class="function-name">addState</span>(<span class="string">"float"</span>, <span class="number">35</span>, <span class="number">45</span>)
|
|
||||||
self.animation:<span class="function-name">addState</span>(<span class="string">"turn"</span>, <span class="number">46</span>, <span class="number">55</span>, <span class="string">"idle"</span>)
|
|
||||||
self.animation:<span class="function-name">addState</span>(<span class="string">"walk"</span>, <span class="number">56</span>, <span class="number">65</span>)
|
|
||||||
<span class="comment">-- ...
|
|
||||||
</span><span class="keyword">end</span></pre>
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "animation:addState"></a>
|
|
||||||
<span class="item-name">animation:addState(__name, __startFrame, __endFrame, __next[, __loop=true], __onComplete[, __frameDuration=1])<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Add an animation state. The first state added will be the default set for this animation.</p>
|
|
||||||
|
|
||||||
<p> <strong>NOTE:</strong> Added states are first-degree member objects of your Noble.Animation object, so do not use names of already existing methods/properties ("current", "draw", etc.).
|
|
||||||
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<ul class="parameters">
|
|
||||||
<li><span class="parameter">__name</span>
|
|
||||||
<span class="types"><span class="type">string</span></span>
|
|
||||||
<br/>
|
|
||||||
The name of the animation, this is also used as the key for the animation.
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__startFrame</span>
|
|
||||||
<span class="types"><span class="type">integer</span></span>
|
|
||||||
<br/>
|
|
||||||
This is the first frame of this animation in the imagetable/spritesheet
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__endFrame</span>
|
|
||||||
<span class="types"><span class="type">integer</span></span>
|
|
||||||
<br/>
|
|
||||||
This is the final frame of this animation in the imagetable/spritesheet
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__next</span>
|
|
||||||
<span class="types"><span class="type">string</span></span>
|
|
||||||
<br/>
|
|
||||||
By default, animation states will loop, but if you want to sequence an animation, enter the name of the next state here.
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__loop</span>
|
|
||||||
<span class="types"><span class="type">boolean</span></span>
|
|
||||||
<span class="default">= <span class="value">true</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
If you want a state to "freeze" on its final frame, instead of looping, enter <code>false</code> here.
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__onComplete</span>
|
|
||||||
<br/>
|
|
||||||
This function will run when this animation is complete. Be careful when using this on a looping animation!
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__frameDuration</span>
|
|
||||||
<span class="types"><span class="type">integer</span></span>
|
|
||||||
<span class="default">= <span class="value">1</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
This is the number of ticks between each frame in this animation. If not specified, it will be set to 1.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Usage</h3>
|
|
||||||
<pre class="example"><span class="comment">-- You can reference an animation's state's properties using bog-standard lua syntax:
|
|
||||||
</span>
|
|
||||||
animation.idle.startFrame <span class="comment">-- 30
|
|
||||||
</span>animation.walk.endFrame <span class="comment">-- 65
|
|
||||||
</span>animation.[<span class="string">"walk"</span>].endFrame <span class="comment">-- 65
|
|
||||||
</span>animation.jump.name <span class="comment">-- "jump"
|
|
||||||
</span>animation.[<span class="string">"jump"</span>].<span class="global">next</span> <span class="comment">-- "float"
|
|
||||||
</span>animation.idle.<span class="global">next</span> <span class="comment">-- nil</span></pre>
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
<h2 class="section-header "><a name="Properties"></a>Properties </h2>
|
|
||||||
<!-- -->
|
|
||||||
<dl class="function">
|
|
||||||
<dt>
|
|
||||||
<a name = "animation.current"></a>
|
|
||||||
<span class="item-name">animation.current<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
The currently set animation state. </p>
|
|
||||||
|
|
||||||
<p> This is intended as <code>read-only</code>. You should not modify this property directly.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<a href="../modules/Noble.Animation.html#animation:setState">setState</a>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "animation.currentName"></a>
|
|
||||||
<span class="item-name">animation.currentName<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
The name of the current animation state. Calling this instead of <code>animation.current.name</code> is <em>just</em> a little faster.</p>
|
|
||||||
|
|
||||||
<p> This is intended as <code>read-only</code>. You should not modify this property directly.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "animation.currentFrame"></a>
|
|
||||||
<span class="item-name">animation.currentFrame<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
The current frame of the animation. This is the index of the imagetable, not the frame of the current state.</p>
|
|
||||||
|
|
||||||
<p> Most of the time, you should not modify this directly, although you can if you're feeling saucy and are prepared for unpredictable results.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<a href="../modules/Noble.Animation.html#animation:draw">draw</a>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "animation.direction"></a>
|
|
||||||
<span class="item-name">animation.direction<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
This controls the flipping of the image when drawing. DIRECTION<em>RIGHT is unflipped, DIRECTION</em>LEFT is flipped on the X axis.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Usage</h3>
|
|
||||||
<pre class="example"><span class="keyword">function</span> MyHero:<span class="function-name">goLeft</span>()
|
|
||||||
self.animation.direction = Noble.Animation.DIRECTION_LEFT
|
|
||||||
<span class="comment">-- ...
|
|
||||||
</span><span class="keyword">end</span></pre>
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
<h2 class="section-header "><a name="Methods"></a>Methods </h2>
|
|
||||||
<!-- -->
|
|
||||||
<dl class="function">
|
|
||||||
<dt>
|
|
||||||
<a name = "animation:setState"></a>
|
|
||||||
<span class="item-name">animation:setState(__animationState[, __continuous=false], __unlessThisState)<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Sets the current animation state. This can be run in a object's <code>update</code> method because it only changes the animation state if the new state is different from the current one.
|
|
||||||
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<ul class="parameters">
|
|
||||||
<li><span class="parameter">__animationState</span>
|
|
||||||
<span class="types"><span class="type">string</span> or <span class="type">Noble.Animation</span></span>
|
|
||||||
<br/>
|
|
||||||
The name of the animation to set. You can pass the name of the state, or the object itself.
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__continuous</span>
|
|
||||||
<span class="types"><span class="type">boolean</span></span>
|
|
||||||
<span class="default">= <span class="value">false</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
Set to true if your new state's frames line up with the previous one's, i.e.: two walk cycles but one is wearing a cute hat!
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__unlessThisState</span>
|
|
||||||
<span class="types"><span class="type">string</span> or <span class="type">Noble.Animation</span></span>
|
|
||||||
<br/>
|
|
||||||
If this state is the current state, do not set the new one.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Usage</h3>
|
|
||||||
<pre class="example">animation:<span class="function-name">setState</span>(<span class="string">"walk"</span>)</pre>
|
|
||||||
<pre class="example">animation:<span class="function-name">setState</span>(animation.walk)</pre>
|
|
||||||
<pre class="example">animation:<span class="function-name">setState</span>(animation.walkNoHat)
|
|
||||||
<span class="comment">--
|
|
||||||
</span>animation:<span class="function-name">setState</span>(animation.walkYesHat, <span class="keyword">true</span>)</pre>
|
|
||||||
<pre class="example"><span class="keyword">function</span> MyHero:<span class="function-name">update</span>()
|
|
||||||
<span class="comment">-- Input
|
|
||||||
</span> <span class="comment">-- ...
|
|
||||||
</span>
|
|
||||||
<span class="comment">-- Physics/collisions
|
|
||||||
</span> <span class="comment">-- ...
|
|
||||||
</span>
|
|
||||||
<span class="comment">-- Animation states
|
|
||||||
</span> <span class="keyword">if</span> (grounded) <span class="keyword">then</span>
|
|
||||||
<span class="keyword">if</span> (turning) <span class="keyword">then</span>
|
|
||||||
self.animation:<span class="function-name">setState</span>(self.animation.turn)
|
|
||||||
<span class="keyword">elseif</span> (<span class="global">math</span>.<span class="function-name">abs</span>(self.velocity.x) > <span class="number">15</span>) <span class="keyword">then</span>
|
|
||||||
self.animation:<span class="function-name">setState</span>(self.animation.walk, <span class="keyword">false</span>, self.animation.turn)
|
|
||||||
<span class="keyword">else</span>
|
|
||||||
self.animation:<span class="function-name">setState</span>(self.animation.idle, <span class="keyword">false</span>, self.animation.turn)
|
|
||||||
<span class="keyword">end</span>
|
|
||||||
<span class="keyword">else</span>
|
|
||||||
self.animation:<span class="function-name">setState</span>(self.animation.jump, <span class="keyword">false</span>, self.animation.float)
|
|
||||||
<span class="keyword">end</span>
|
|
||||||
|
|
||||||
groundedLastFrame = grounded
|
|
||||||
<span class="keyword">end</span></pre>
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "animation:draw"></a>
|
|
||||||
<span class="item-name">animation:draw([__x=0[, __y=0[, __advance=true]]])<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Draw the current frame. </p>
|
|
||||||
|
|
||||||
<p> When attached to a NobleSprite, this is called by <code>NobleSprite:draw()</code> when added to a scene. For non-NobleSprite sprites, put this method inside your sprite's <code>draw()</code> method, or inside <a href="../classes/NobleScene.html#noblescene:update">NobleScene:update</a>.
|
|
||||||
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<ul class="parameters">
|
|
||||||
<li><span class="parameter">__x</span>
|
|
||||||
<span class="types"><span class="type">number</span></span>
|
|
||||||
<span class="default">= <span class="value">0</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__y</span>
|
|
||||||
<span class="types"><span class="type">number</span></span>
|
|
||||||
<span class="default">= <span class="value">0</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__advance</span>
|
|
||||||
<span class="types"><span class="type">boolean</span></span>
|
|
||||||
<span class="default">= <span class="value">true</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
Advances to the next frame after drawing this one. Noble.Animation is frame-based, not "delta time"-based, so its speed is dependent on your game's framerate.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Usage</h3>
|
|
||||||
<pre class="example"><span class="keyword">function</span> MySprite:<span class="function-name">draw</span>()
|
|
||||||
animation:<span class="function-name">draw</span>()
|
|
||||||
<span class="keyword">end</span></pre>
|
|
||||||
<pre class="example"><span class="keyword">function</span> MyScene:<span class="function-name">update</span>()
|
|
||||||
animation:<span class="function-name">draw</span>(<span class="number">100</span>,<span class="number">100</span>)
|
|
||||||
<span class="keyword">end</span></pre>
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "animation:drawFrame"></a>
|
|
||||||
<span class="item-name">animation:drawFrame(__frameNumber[, __stateName=self.currentName[, __x=0[, __y=0[, __direction=self.direction]]]])<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Sometimes, you just want to draw a specific frame.
|
|
||||||
Use this for objects or sprites that you want to control outside of update loops, such as score counters, flipbook-style objects that respond to player input, etc.
|
|
||||||
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<ul class="parameters">
|
|
||||||
<li><span class="parameter">__frameNumber</span>
|
|
||||||
<span class="types"><span class="type">integer</span></span>
|
|
||||||
<br/>
|
|
||||||
The frame to draw from the current state. This is not an imagetable index. Entering <code>1</code> will draw the selected state's <code>startFrame</code>.
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__stateName</span>
|
|
||||||
<span class="types"><span class="type">string</span></span>
|
|
||||||
<span class="default">= <span class="value">self.currentName</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
The specific state to pull the __frameNumber from.
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__x</span>
|
|
||||||
<span class="types"><span class="type">number</span></span>
|
|
||||||
<span class="default">= <span class="value">0</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__y</span>
|
|
||||||
<span class="types"><span class="type">number</span></span>
|
|
||||||
<span class="default">= <span class="value">0</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__direction</span>
|
|
||||||
<span class="default">= <span class="value">self.direction</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
Override the current direction.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
<h2 class="section-header "><a name="Constants"></a>Constants </h2>
|
|
||||||
<!-- -->
|
|
||||||
<dl class="function">
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.Animation.DIRECTION_RIGHT"></a>
|
|
||||||
<span class="item-name">Noble.Animation.DIRECTION_RIGHT<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
A re-contextualized instance of <code>playdate.graphics.kImageUnflipped</code>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.Animation.DIRECTION_LEFT"></a>
|
|
||||||
<span class="item-name">Noble.Animation.DIRECTION_LEFT<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
A re-contextualized instance of <code>playdate.graphics.kImageFlippedX</code>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
|
|
||||||
|
|
||||||
</div> <!-- id="content" -->
|
|
||||||
|
|
||||||
</div> <!-- id="main" -->
|
|
||||||
|
|
||||||
<div id="about">
|
|
||||||
<span><a href="https://github.com/NobleRobot/NobleEngine">Noble Engine</a> by Mark LaCroix, <a href="https://noblerobot.com">Noble Robot</a></span>
|
|
||||||
<span style="float:right;">
|
|
||||||
Documentation created using <a href="https://github.com/stevedonovan/LDoc">LDoc 1.5.0</a>.
|
|
||||||
</span>
|
|
||||||
</div> <!-- id="about" -->
|
|
||||||
|
|
||||||
</div> <!-- id="container" -->
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
@ -1,188 +0,0 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
||||||
<html>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
|
||||||
<head>
|
|
||||||
<title>Noble Engine API reference</title>
|
|
||||||
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
|
|
||||||
<link rel="icon" href="favicon.ico">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<div id="container">
|
|
||||||
|
|
||||||
<div id="main">
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Menu -->
|
|
||||||
|
|
||||||
<div id="navigation">
|
|
||||||
<a href="../index.html"><div class="logo">
|
|
||||||
<h1>Noble Engine</h1>
|
|
||||||
</div></a>
|
|
||||||
|
|
||||||
<div class="nav-module">
|
|
||||||
<h2>Noble.Bonk</h2>
|
|
||||||
<ul>
|
|
||||||
<h3>Functions</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="#Noble.Bonk.startCheckingDebugBonks">.startCheckingDebugBonks</a></li>
|
|
||||||
<li><a href="#Noble.Bonk.stopCheckingDebugBonks">.stopCheckingDebugBonks</a></li>
|
|
||||||
<li><a href="#Noble.Bonk.disableDebugBonkChecking">.disableDebugBonkChecking</a></li>
|
|
||||||
<li><a href="#Noble.Bonk.checkingDebugBonks">.checkingDebugBonks</a></li>
|
|
||||||
<li><a href="#Noble.Bonk.checkDebugBonks">.checkDebugBonks</a></li>
|
|
||||||
</ul>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="nav-modules">
|
|
||||||
<div class="nav-kind">
|
|
||||||
<h3>Modules</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../modules/Noble.html">Noble</a></li>
|
|
||||||
<li><a href="../modules/Noble.Animation.html">Noble.Animation</a></li>
|
|
||||||
<li><span class="selected">Noble.Bonk</span></li>
|
|
||||||
<li><a href="../modules/Noble.GameData.html">Noble.GameData</a></li>
|
|
||||||
<li><a href="../modules/Noble.Input.html">Noble.Input</a></li>
|
|
||||||
<li><a href="../modules/Noble.Menu.html">Noble.Menu</a></li>
|
|
||||||
<li><a href="../modules/Noble.Settings.html">Noble.Settings</a></li>
|
|
||||||
<li><a href="../modules/Noble.Text.html">Noble.Text</a></li>
|
|
||||||
<li><a href="../modules/Noble.Transition.html">Noble.Transition</a></li>
|
|
||||||
<li><a href="../modules/Ease.html">Ease</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="nav-kind">
|
|
||||||
<h3>Classes</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../classes/NobleScene.html">NobleScene</a></li>
|
|
||||||
<li><a href="../classes/NobleSprite.html">NobleSprite</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="nav-kind">
|
|
||||||
<h3>Examples</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../examples/SceneTemplate.lua.html">SceneTemplate.lua</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="content">
|
|
||||||
|
|
||||||
<h1>Noble.Bonk</h1>
|
|
||||||
<p>Engine-specific error handling.</p>
|
|
||||||
<p> Noble Engine overrides/supersedes some Playdate SDK behavior. A "bonk" is what happens when your game breaks the engine.</p>
|
|
||||||
|
|
||||||
<p> Most bonks will throw during normal operation, but others ("debug bonks") introduce some execution overhead so are not
|
|
||||||
checked by default.</p>
|
|
||||||
|
|
||||||
<hr/>
|
|
||||||
|
|
||||||
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
|
|
||||||
<!-- -->
|
|
||||||
<dl class="function">
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.Bonk.startCheckingDebugBonks"></a>
|
|
||||||
<span class="item-name">Noble.Bonk.startCheckingDebugBonks()<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Begin checking for debug bonks, <strong>on every frame</strong>. This introduces needless overhead, so don't do it in a release build.
|
|
||||||
You can only run this if you ran previously <code>Noble.new()</code> with <code>__enableDebugBonkChecking</code> as true, which you should also not do in a release build.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<a href="../modules/Noble.html#new">Noble.new</a>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.Bonk.stopCheckingDebugBonks"></a>
|
|
||||||
<span class="item-name">Noble.Bonk.stopCheckingDebugBonks()<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Stop checking for debug bonks on every frame. </p>
|
|
||||||
|
|
||||||
<p> <strong>NOTE: You can only run this if debug bonk checking is enabled.</strong>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.Bonk.disableDebugBonkChecking"></a>
|
|
||||||
<span class="item-name">Noble.Bonk.disableDebugBonkChecking()<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Disable the ability to check for debug bonks. It frees up some memory. Once you disable debug bonk checking, you cannot re-enable it.</p>
|
|
||||||
|
|
||||||
<p> <strong>NOTE: You can only run this if debug bonk checking is enabled.</strong>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.Bonk.checkingDebugBonks"></a>
|
|
||||||
<span class="item-name">Noble.Bonk.checkingDebugBonks()<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Are we debug bonk checking for debug bonks?
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Returns</h3>
|
|
||||||
<ol>
|
|
||||||
|
|
||||||
<span class="types"><span class="type">bool</span></span>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</ol>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.Bonk.checkDebugBonks"></a>
|
|
||||||
<span class="item-name">Noble.Bonk.checkDebugBonks()<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Manually check for debug bonks.
|
|
||||||
This method runs every frame when <a href="../modules/Noble.Bonk.html#Noble.Bonk.checkingDebugBonks">checkingDebugBonks</a> is true, but you may call it manually instead.</p>
|
|
||||||
|
|
||||||
<p> <strong>NOTE: You can only run this if debug bonk checking is enabled.</strong>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
|
|
||||||
|
|
||||||
</div> <!-- id="content" -->
|
|
||||||
|
|
||||||
</div> <!-- id="main" -->
|
|
||||||
|
|
||||||
<div id="about">
|
|
||||||
<span><a href="https://github.com/NobleRobot/NobleEngine">Noble Engine</a> by Mark LaCroix, <a href="https://noblerobot.com">Noble Robot</a></span>
|
|
||||||
<span style="float:right;">
|
|
||||||
Documentation created using <a href="https://github.com/stevedonovan/LDoc">LDoc 1.5.0</a>.
|
|
||||||
</span>
|
|
||||||
</div> <!-- id="about" -->
|
|
||||||
|
|
||||||
</div> <!-- id="container" -->
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
@ -1,550 +0,0 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
||||||
<html>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
|
||||||
<head>
|
|
||||||
<title>Noble Engine API reference</title>
|
|
||||||
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
|
|
||||||
<link rel="icon" href="favicon.ico">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<div id="container">
|
|
||||||
|
|
||||||
<div id="main">
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Menu -->
|
|
||||||
|
|
||||||
<div id="navigation">
|
|
||||||
<a href="../index.html"><div class="logo">
|
|
||||||
<h1>Noble Engine</h1>
|
|
||||||
</div></a>
|
|
||||||
|
|
||||||
<div class="nav-module">
|
|
||||||
<h2>Noble.GameData</h2>
|
|
||||||
<ul>
|
|
||||||
<h3>Functions</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="#Noble.GameData.setup">.setup</a></li>
|
|
||||||
<li><a href="#Noble.GameData.get">.get</a></li>
|
|
||||||
<li><a href="#Noble.GameData.set">.set</a></li>
|
|
||||||
<li><a href="#Noble.GameData.reset">.reset</a></li>
|
|
||||||
<li><a href="#Noble.GameData.resetAll">.resetAll</a></li>
|
|
||||||
<li><a href="#Noble.GameData.addSlot">.addSlot</a></li>
|
|
||||||
<li><a href="#Noble.GameData.deleteSlot">.deleteSlot</a></li>
|
|
||||||
<li><a href="#Noble.GameData.deleteAllSlots">.deleteAllSlots</a></li>
|
|
||||||
<li><a href="#Noble.GameData.getTimestamp">.getTimestamp</a></li>
|
|
||||||
<li><a href="#Noble.GameData.getNumberOfSlots">.getNumberOfSlots</a></li>
|
|
||||||
<li><a href="#Noble.GameData.getCurrentSlot">.getCurrentSlot</a></li>
|
|
||||||
<li><a href="#Noble.GameData.save">.save</a></li>
|
|
||||||
<li><a href="#Noble.GameData.saveAll">.saveAll</a></li>
|
|
||||||
</ul>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="nav-modules">
|
|
||||||
<div class="nav-kind">
|
|
||||||
<h3>Modules</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../modules/Noble.html">Noble</a></li>
|
|
||||||
<li><a href="../modules/Noble.Animation.html">Noble.Animation</a></li>
|
|
||||||
<li><a href="../modules/Noble.Bonk.html">Noble.Bonk</a></li>
|
|
||||||
<li><span class="selected">Noble.GameData</span></li>
|
|
||||||
<li><a href="../modules/Noble.Input.html">Noble.Input</a></li>
|
|
||||||
<li><a href="../modules/Noble.Menu.html">Noble.Menu</a></li>
|
|
||||||
<li><a href="../modules/Noble.Settings.html">Noble.Settings</a></li>
|
|
||||||
<li><a href="../modules/Noble.Text.html">Noble.Text</a></li>
|
|
||||||
<li><a href="../modules/Noble.Transition.html">Noble.Transition</a></li>
|
|
||||||
<li><a href="../modules/Ease.html">Ease</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="nav-kind">
|
|
||||||
<h3>Classes</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../classes/NobleScene.html">NobleScene</a></li>
|
|
||||||
<li><a href="../classes/NobleSprite.html">NobleSprite</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="nav-kind">
|
|
||||||
<h3>Examples</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../examples/SceneTemplate.lua.html">SceneTemplate.lua</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="content">
|
|
||||||
|
|
||||||
<h1>Noble.GameData</h1>
|
|
||||||
<p>Operations for game data / save slots.</p>
|
|
||||||
<p>
|
|
||||||
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<hr/>
|
|
||||||
|
|
||||||
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
|
|
||||||
<!-- -->
|
|
||||||
<dl class="function">
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.GameData.setup"></a>
|
|
||||||
<span class="item-name">Noble.GameData.setup(__keyValuePairs[, __numberOfSlots=1[, __saveToDisk=true[, __modifyExistingOnKeyChange=true]]])<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Sets up the GameDatas (save slots) for your game, and/or loads any existing GameDatas from disk.
|
|
||||||
You can only run this once, ideally in your main.lua before you load your first scene.
|
|
||||||
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<ul class="parameters">
|
|
||||||
<li><span class="parameter">__keyValuePairs</span>
|
|
||||||
<span class="types"><span class="type">table</span></span>
|
|
||||||
<br/>
|
|
||||||
All the data items for a saved game, and their default values, as key/value pairs. <strong>NOTE:</strong> Do not use "nil" as a value.
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__numberOfSlots</span>
|
|
||||||
<span class="types"><span class="type">integer</span></span>
|
|
||||||
<span class="default">= <span class="value">1</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
If you want multiple save slots, enter an integer here. You can add additional slots later.
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__saveToDisk</span>
|
|
||||||
<span class="types"><span class="type">boolean</span></span>
|
|
||||||
<span class="default">= <span class="value">true</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
Saves your default values immediately to disk.
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__modifyExistingOnKeyChange</span>
|
|
||||||
<span class="types"><span class="type">boolean</span></span>
|
|
||||||
<span class="default">= <span class="value">true</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
Updates the existing gameData objects on disk if you make changes to your keys (not values) during development or when updating your game.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../modules/Noble.GameData.html#Noble.GameData.addSlot">Noble.GameData.addSlot</a></li>
|
|
||||||
<li><a href="../modules/Noble.GameData.html#Noble.GameData.deleteSlot">Noble.GameData.deleteSlot</a></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3>Usage</h3>
|
|
||||||
<pre class="example">Noble.GameData.<span class="function-name">setup</span>(
|
|
||||||
{
|
|
||||||
name = <span class="string">""</span>,
|
|
||||||
checkpointReached = <span class="number">0</span>,
|
|
||||||
score = <span class="number">0</span>
|
|
||||||
},
|
|
||||||
<span class="number">3</span>,
|
|
||||||
<span class="keyword">true</span>,
|
|
||||||
<span class="keyword">true</span>
|
|
||||||
)
|
|
||||||
Noble.GameData.<span class="function-name">set</span>(<span class="string">"name"</span>, <span class="string">"Game A"</span>, <span class="number">1</span>)
|
|
||||||
Noble.GameData.<span class="function-name">set</span>(<span class="string">"name"</span>, <span class="string">"Game B"</span>, <span class="number">2</span>)
|
|
||||||
Noble.GameData.<span class="function-name">set</span>(<span class="string">"name"</span>, <span class="string">"Game C"</span>, <span class="number">3</span>)</pre>
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.GameData.get"></a>
|
|
||||||
<span class="item-name">Noble.GameData.get(__dataItemName[, __gameDataSlot])<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Returns the value of the requested data item.
|
|
||||||
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<ul class="parameters">
|
|
||||||
<li><span class="parameter">__dataItemName</span>
|
|
||||||
<span class="types"><span class="type">string</span></span>
|
|
||||||
<br/>
|
|
||||||
The name of the data item.
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__gameDataSlot</span>
|
|
||||||
<span class="types"><span class="type">integer</span></span>
|
|
||||||
<span class="optional">(optional)</span>
|
|
||||||
<br/>
|
|
||||||
If set, uses a specific GameData slot. If not, uses the most recently touched GameData slot.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3>Returns</h3>
|
|
||||||
<ol>
|
|
||||||
|
|
||||||
<span class="types"><span class="type">any</span></span>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</ol>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Usage</h3>
|
|
||||||
<pre class="example">Noble.GameData.<span class="function-name">get</span>(<span class="string">"equippedItem"</span>)</pre>
|
|
||||||
<pre class="example">Noble.GameData.<span class="function-name">get</span>(<span class="string">"equippedItem"</span>, <span class="number">2</span>)</pre>
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.GameData.set"></a>
|
|
||||||
<span class="item-name">Noble.GameData.set(__dataItemName, __value[, __gameDataSlot[, __saveToDisk=true[, __updateTimestamp=true]]])<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Set the value of a GameData item.
|
|
||||||
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<ul class="parameters">
|
|
||||||
<li><span class="parameter">__dataItemName</span>
|
|
||||||
<span class="types"><span class="type">string</span></span>
|
|
||||||
<br/>
|
|
||||||
The name of the data item.
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__value</span>
|
|
||||||
<span class="types"><span class="type">any</span></span>
|
|
||||||
<br/>
|
|
||||||
The data item's new value
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__gameDataSlot</span>
|
|
||||||
<span class="types"><span class="type">integer</span></span>
|
|
||||||
<span class="optional">(optional)</span>
|
|
||||||
<br/>
|
|
||||||
If set, uses a specific GameData slot. If not, uses the most recently touched GameData slot.
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__saveToDisk</span>
|
|
||||||
<span class="types"><span class="type">boolean</span></span>
|
|
||||||
<span class="default">= <span class="value">true</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
Saves to disk immediately. Set to false if you prefer to manually save (via a checkpoint or menu).
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__updateTimestamp</span>
|
|
||||||
<span class="types"><span class="type">boolean</span></span>
|
|
||||||
<span class="default">= <span class="value">true</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
Sets the timestamp of this GameData to the current time. Leave false to retain existing timestamp.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<a href="../modules/Noble.GameData.html#Noble.GameData.save">Noble.GameData.save</a>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3>Usage</h3>
|
|
||||||
<pre class="example">Noble.GameData.<span class="function-name">set</span>(<span class="string">"score"</span>, <span class="number">74205</span>)</pre>
|
|
||||||
<pre class="example">Noble.GameData.<span class="function-name">set</span>(<span class="string">"score"</span>, Noble.GameData.<span class="function-name">get</span>(<span class="string">"score"</span>) + <span class="number">100</span>)</pre>
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.GameData.reset"></a>
|
|
||||||
<span class="item-name">Noble.GameData.reset(__dataItemName[, __gameDataSlot[, __saveToDisk=true[, __updateTimestamp=true]]])<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Reset a GameData item to its default value, defined in <a href="../modules/Noble.GameData.html#Noble.GameData.setup">setup</a>.
|
|
||||||
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<ul class="parameters">
|
|
||||||
<li><span class="parameter">__dataItemName</span>
|
|
||||||
<span class="types"><span class="type">string</span></span>
|
|
||||||
<br/>
|
|
||||||
The name of the data item.
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__gameDataSlot</span>
|
|
||||||
<span class="types"><span class="type">integer</span></span>
|
|
||||||
<span class="optional">(optional)</span>
|
|
||||||
<br/>
|
|
||||||
If set, uses a specific GameData slot. If not, uses the most recently touched GameData slot.
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__saveToDisk</span>
|
|
||||||
<span class="types"><span class="type">boolean</span></span>
|
|
||||||
<span class="default">= <span class="value">true</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
Saves to disk immediately. Set to false if you prefer to manually save (via a checkpoint or menu).
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__updateTimestamp</span>
|
|
||||||
<span class="types"><span class="type">boolean</span></span>
|
|
||||||
<span class="default">= <span class="value">true</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
Resets the timestamp of this GameData to the current time. Leave false to retain existing timestamp.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<a href="../modules/Noble.GameData.html#Noble.GameData.save">Noble.GameData.save</a>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.GameData.resetAll"></a>
|
|
||||||
<span class="item-name">Noble.GameData.resetAll([__gameDataSlot[, __saveToDisk=true[, __updateTimestamp=true]]])<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Reset all values in a GameData slot to the default values, defined in <a href="../modules/Noble.GameData.html#Noble.GameData.setup">setup</a>.
|
|
||||||
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<ul class="parameters">
|
|
||||||
<li><span class="parameter">__gameDataSlot</span>
|
|
||||||
<span class="types"><span class="type">integer</span></span>
|
|
||||||
<span class="optional">(optional)</span>
|
|
||||||
<br/>
|
|
||||||
If set, uses a specific GameData slot. If not, uses the most recently touched GameData slot.
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__saveToDisk</span>
|
|
||||||
<span class="types"><span class="type">boolean</span></span>
|
|
||||||
<span class="default">= <span class="value">true</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
Saves to disk immediately. Set to false if you prefer to manually save (via a checkpoint or menu).
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__updateTimestamp</span>
|
|
||||||
<span class="types"><span class="type">boolean</span></span>
|
|
||||||
<span class="default">= <span class="value">true</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
Resets the timestamp of this GameData to the current time. Leave false to retain existing timestamp.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<a href="../modules/Noble.GameData.html#Noble.GameData.save">Noble.GameData.save</a>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.GameData.addSlot"></a>
|
|
||||||
<span class="item-name">Noble.GameData.addSlot([__numberToAdd=1[, __saveToDisk=true]])<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Add a save slot to your game. This is useful for games which have arbitrary save slots, or encourage save scumming.
|
|
||||||
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<ul class="parameters">
|
|
||||||
<li><span class="parameter">__numberToAdd</span>
|
|
||||||
<span class="types"><span class="type">integer</span></span>
|
|
||||||
<span class="default">= <span class="value">1</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
What it says on the tin.
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__saveToDisk</span>
|
|
||||||
<span class="types"><span class="type">boolean</span></span>
|
|
||||||
<span class="default">= <span class="value">true</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
Saves to disk immediately. Set to false if you prefer to manually save (via a checkpoint or menu).
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Usage</h3>
|
|
||||||
<pre class="example">Noble.GameData.<span class="function-name">addSlot</span>()</pre>
|
|
||||||
<pre class="example">Noble.GameData.<span class="function-name">addSlot</span>(<span class="number">10</span>)</pre>
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.GameData.deleteSlot"></a>
|
|
||||||
<span class="item-name">Noble.GameData.deleteSlot(__gameDataSlot[, __collapseGameDatas=true])<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Deletes a GameData from disk if its save slot is greater than the default number established in <a href="../modules/Noble.GameData.html#Noble.GameData.setup">setup</a>.
|
|
||||||
Otherwise, resets all data items to default values using <a href="../modules/Noble.GameData.html#Noble.GameData.resetAll">resetAll</a>.</p>
|
|
||||||
|
|
||||||
<p> Generally, you won't need this unless you've added save slots using <a href="../modules/Noble.GameData.html#Noble.GameData.addSlot">addSlot</a>. In other cases, use <a href="../modules/Noble.GameData.html#Noble.GameData.resetAll">resetAll</a>.
|
|
||||||
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<ul class="parameters">
|
|
||||||
<li><span class="parameter">__gameDataSlot</span>
|
|
||||||
<span class="types"><span class="type">integer</span></span>
|
|
||||||
<br/>
|
|
||||||
The slot holding the GameData to delete. Unlike other methods that take this argument, this is not optional.
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__collapseGameDatas</span>
|
|
||||||
<span class="types"><span class="type">boolean</span></span>
|
|
||||||
<span class="default">= <span class="value">true</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
Re-sorts the gameDatas table (and renames existing JSON files on disk) to fill the gap left by the deleted GameData.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../modules/Noble.GameData.html#Noble.GameData.deleteAllSlots">Noble.GameData.deleteAllSlots</a></li>
|
|
||||||
<li><a href="../modules/Noble.GameData.html#Noble.GameData.addSlot">Noble.GameData.addSlot</a></li>
|
|
||||||
<li><a href="../modules/Noble.GameData.html#Noble.GameData.resetAll">Noble.GameData.resetAll</a></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3>Usage</h3>
|
|
||||||
<pre class="example">Noble.GameData.<span class="function-name">deleteSlot</span>(<span class="number">6</span>)</pre>
|
|
||||||
<pre class="example">Noble.GameData.<span class="function-name">deleteSlot</span>(<span class="number">15</span>, <span class="keyword">false</span>)</pre>
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.GameData.deleteAllSlots"></a>
|
|
||||||
<span class="item-name">Noble.GameData.deleteAllSlots()<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Deletes all GameDatas from disk, except for the number specified in setup, which are reset to default values.
|
|
||||||
Use this to clear all data as if you were running setup again.
|
|
||||||
Generally, you don't need this unless you've added save slots using <a href="../modules/Noble.GameData.html#Noble.GameData.addSlot">addSlot</a>. In other cases, use <a href="../modules/Noble.GameData.html#Noble.GameData.resetAll">resetAll</a> on each slot.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../modules/Noble.GameData.html#Noble.GameData.deleteSlot">Noble.GameData.deleteSlot</a></li>
|
|
||||||
<li><a href="../modules/Noble.GameData.html#Noble.GameData.addSlot">Noble.GameData.addSlot</a></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.GameData.getTimestamp"></a>
|
|
||||||
<span class="item-name">Noble.GameData.getTimestamp(__gameDataSlot)<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Returns the timestamp of the requested GameData, as a tuple (local time, GMT time). The timestamp is updated
|
|
||||||
See Playdate SDK for details on how a time object is formatted. <strong>NOTE: Timestamps are stored internally in GMT.</strong>
|
|
||||||
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<ul class="parameters">
|
|
||||||
<li><span class="parameter">__gameDataSlot</span>
|
|
||||||
<span class="types"><span class="type">integer</span></span>
|
|
||||||
<br/>
|
|
||||||
The GameData slot to get the timestamp of. Unlike other methods that take this argument, this is not optional.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3>Returns</h3>
|
|
||||||
<ol>
|
|
||||||
<li>
|
|
||||||
<span class="types"><span class="type">table</span></span>
|
|
||||||
Local time</li>
|
|
||||||
<li>
|
|
||||||
<span class="types"><span class="type">table</span></span>
|
|
||||||
GMT time</li>
|
|
||||||
</ol>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Usage</h3>
|
|
||||||
<pre class="example">Noble.GameData.<span class="function-name">getTimestamp</span>(<span class="number">1</span>)</pre>
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.GameData.getNumberOfSlots"></a>
|
|
||||||
<span class="item-name">Noble.GameData.getNumberOfSlots()<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Returns the current number of GameData slots.
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Returns</h3>
|
|
||||||
<ol>
|
|
||||||
|
|
||||||
<span class="types"><span class="type">int</span></span>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</ol>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.GameData.getCurrentSlot"></a>
|
|
||||||
<span class="item-name">Noble.GameData.getCurrentSlot()<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Returns the number of the current GameData slot.
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Returns</h3>
|
|
||||||
<ol>
|
|
||||||
|
|
||||||
<span class="types"><span class="type">int</span></span>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</ol>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.GameData.save"></a>
|
|
||||||
<span class="item-name">Noble.GameData.save([__gameDataSlot])<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Saves a single GameData to disk. If you want to save all GameDatas, use <a href="../modules/Noble.GameData.html#Noble.GameData.saveAll">saveAll</a> instead.
|
|
||||||
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<ul class="parameters">
|
|
||||||
<li><span class="parameter">__gameDataSlot</span>
|
|
||||||
<span class="types"><span class="type">integer</span></span>
|
|
||||||
<span class="optional">(optional)</span>
|
|
||||||
<br/>
|
|
||||||
If set, uses a specific GameData slot. If not, uses the most recently touched GameData slot.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<a href="../modules/Noble.GameData.html#Noble.GameData.saveAll">Noble.GameData.saveAll</a>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3>Usage</h3>
|
|
||||||
<pre class="example">Noble.GameData.<span class="function-name">save</span>()</pre>
|
|
||||||
<pre class="example">Noble.GameData.<span class="function-name">save</span>(<span class="number">3</span>)</pre>
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.GameData.saveAll"></a>
|
|
||||||
<span class="item-name">Noble.GameData.saveAll()<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Save all GameDatas to disk. If you only have one, or want to save a specific one, use <a href="../modules/Noble.GameData.html#Noble.GameData.save">save</a> instead.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<a href="../modules/Noble.GameData.html#Noble.GameData.save">Noble.GameData.save</a>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
|
|
||||||
|
|
||||||
</div> <!-- id="content" -->
|
|
||||||
|
|
||||||
</div> <!-- id="main" -->
|
|
||||||
|
|
||||||
<div id="about">
|
|
||||||
<span><a href="https://github.com/NobleRobot/NobleEngine">Noble Engine</a> by Mark LaCroix, <a href="https://noblerobot.com">Noble Robot</a></span>
|
|
||||||
<span style="float:right;">
|
|
||||||
Documentation created using <a href="https://github.com/stevedonovan/LDoc">LDoc 1.5.0</a>.
|
|
||||||
</span>
|
|
||||||
</div> <!-- id="about" -->
|
|
||||||
|
|
||||||
</div> <!-- id="container" -->
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
@ -1,617 +0,0 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
||||||
<html>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
|
||||||
<head>
|
|
||||||
<title>Noble Engine API reference</title>
|
|
||||||
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
|
|
||||||
<link rel="icon" href="favicon.ico">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<div id="container">
|
|
||||||
|
|
||||||
<div id="main">
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Menu -->
|
|
||||||
|
|
||||||
<div id="navigation">
|
|
||||||
<a href="../index.html"><div class="logo">
|
|
||||||
<h1>Noble Engine</h1>
|
|
||||||
</div></a>
|
|
||||||
|
|
||||||
<div class="nav-module">
|
|
||||||
<h2>Noble.Input</h2>
|
|
||||||
<ul>
|
|
||||||
<h3>Functions</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="#Noble.Input.getHandler">.getHandler</a></li>
|
|
||||||
<li><a href="#Noble.Input.setHandler">.setHandler</a></li>
|
|
||||||
<li><a href="#Noble.Input.clearHandler">.clearHandler</a></li>
|
|
||||||
<li><a href="#Noble.Input.setEnabled">.setEnabled</a></li>
|
|
||||||
<li><a href="#Noble.Input.getEnabled">.getEnabled</a></li>
|
|
||||||
<li><a href="#Noble.Input.setCrankIndicatorStatus">.setCrankIndicatorStatus</a></li>
|
|
||||||
<li><a href="#Noble.Input.getCrankIndicatorStatus">.getCrankIndicatorStatus</a></li>
|
|
||||||
<li><a href="#Noble.Input.getOrientation">.getOrientation</a></li>
|
|
||||||
</ul>
|
|
||||||
<h3>Constants
|
|
||||||
</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="#Noble.Input.BUTTON_A">.BUTTON_A</a></li>
|
|
||||||
<li><a href="#Noble.Input.BUTTON_B">.BUTTON_B</a></li>
|
|
||||||
<li><a href="#Noble.Input.BUTTON_MENU">.BUTTON_MENU</a></li>
|
|
||||||
<li><a href="#Noble.Input.DPAD">.DPAD</a></li>
|
|
||||||
<li><a href="#Noble.Input.DPAD_HORIZONTAL">.DPAD_HORIZONTAL</a></li>
|
|
||||||
<li><a href="#Noble.Input.DPAD_VERTICAL">.DPAD_VERTICAL</a></li>
|
|
||||||
<li><a href="#Noble.Input.DPAD_UP">.DPAD_UP</a></li>
|
|
||||||
<li><a href="#Noble.Input.DPAD_DOWN">.DPAD_DOWN</a></li>
|
|
||||||
<li><a href="#Noble.Input.DPAD_LEFT">.DPAD_LEFT</a></li>
|
|
||||||
<li><a href="#Noble.Input.DPAD_RIGHT">.DPAD_RIGHT</a></li>
|
|
||||||
<li><a href="#Noble.Input.CRANK">.CRANK</a></li>
|
|
||||||
<li><a href="#Noble.Input.CRANK_FORWARD">.CRANK_FORWARD</a></li>
|
|
||||||
<li><a href="#Noble.Input.CRANK_REVERSE">.CRANK_REVERSE</a></li>
|
|
||||||
<li><a href="#Noble.Input.CRANK_DOCK">.CRANK_DOCK</a></li>
|
|
||||||
<li><a href="#Noble.Input.CRANK_UNDOCK">.CRANK_UNDOCK</a></li>
|
|
||||||
<li><a href="#Noble.Input.ORIENTATION_UP">.ORIENTATION_UP</a></li>
|
|
||||||
</ul>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="nav-modules">
|
|
||||||
<div class="nav-kind">
|
|
||||||
<h3>Modules</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../modules/Noble.html">Noble</a></li>
|
|
||||||
<li><a href="../modules/Noble.Animation.html">Noble.Animation</a></li>
|
|
||||||
<li><a href="../modules/Noble.Bonk.html">Noble.Bonk</a></li>
|
|
||||||
<li><a href="../modules/Noble.GameData.html">Noble.GameData</a></li>
|
|
||||||
<li><span class="selected">Noble.Input</span></li>
|
|
||||||
<li><a href="../modules/Noble.Menu.html">Noble.Menu</a></li>
|
|
||||||
<li><a href="../modules/Noble.Settings.html">Noble.Settings</a></li>
|
|
||||||
<li><a href="../modules/Noble.Text.html">Noble.Text</a></li>
|
|
||||||
<li><a href="../modules/Noble.Transition.html">Noble.Transition</a></li>
|
|
||||||
<li><a href="../modules/Ease.html">Ease</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="nav-kind">
|
|
||||||
<h3>Classes</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../classes/NobleScene.html">NobleScene</a></li>
|
|
||||||
<li><a href="../classes/NobleSprite.html">NobleSprite</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="nav-kind">
|
|
||||||
<h3>Examples</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../examples/SceneTemplate.lua.html">SceneTemplate.lua</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="content">
|
|
||||||
|
|
||||||
<h1>Noble.Input</h1>
|
|
||||||
<p>A complete encapsulation of the Playdate's input system.</p>
|
|
||||||
<p> The Playdate SDK gives developers multiple ways to manage input. Noble Engine's approach revolves around the SDK's "inputHandlers," extending them to include additional input methods, and pull in other hardware functions that the SDK puts elsewhere. See usage below for the full list of supported methods.
|
|
||||||
<br><br>By default, Noble Engine assumes each scene will have an inputManager assigned to it. So, for example, you can define one inputManager for menu screens and another for gameplay scenes in your <code>main.lua</code>, and then in each scene, set which one that scene uses. You can instead define a unique inputHandler in each scene.
|
|
||||||
<br><br>You may also create and manage inputManagers within and outside of scenes. When a NobleScene is loaded, its inputHandler will become active, thus, inputHandlers do not carry across scenes, and all input is suspended during scene transitions. An advanced use-case is to leave a scene's inputHandler as nil, and manage it separately.
|
|
||||||
<br><br><strong>NOTE:</strong> While the Playdate SDK allows you to stack as many inputHandlers as you want, Noble Engine assumes only one <em>active</em> inputHandler at a time. You may still manually call <code>playdate.inputHandlers.push()</code> and <code>playdate.inputHandlers.pop()</code> yourself, but Noble Engine will not know about it and it may cause unexpected behavior.
|
|
||||||
<br><br>In addition, you may directly query button status using the SDK's methods for that, but it is not advised to use that as the primary way to manage input for Noble Engine projects, because much of Noble.Input's functionality will not apply.</p>
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<a href="../classes/NobleScene.html#noblescene.inputHandler">NobleScene.inputHandler</a>
|
|
||||||
</ul>
|
|
||||||
<h3>Usage</h3>
|
|
||||||
<pre class="example">local myInputHandler = {
|
|
||||||
AButtonDown = function() end, -- Fires once when button is pressed down.
|
|
||||||
AButtonHold = function() end, -- Fires each frame while a button is held (Noble Engine implementation).
|
|
||||||
AButtonHeld = function() end, -- Fires once after button is held for 1 second (available for A and B).
|
|
||||||
AButtonUp = function() end, -- Fires once when button is released.
|
|
||||||
BButtonDown = function() end,
|
|
||||||
BButtonHold = function() end,
|
|
||||||
BButtonHeld = function() end,
|
|
||||||
BButtonUp = function() end,
|
|
||||||
downButtonDown = function() end,
|
|
||||||
downButtonHold = function() end,
|
|
||||||
downButtonUp = function() end,
|
|
||||||
leftButtonDown = function() end,
|
|
||||||
leftButtonHold = function() end,
|
|
||||||
leftButtonUp = function() end,
|
|
||||||
rightButtonDown = function() end,
|
|
||||||
rightButtonHold = function() end,
|
|
||||||
rightButtonUp = function() end,
|
|
||||||
upButtonDown = function() end,
|
|
||||||
upButtonHold = function() end
|
|
||||||
upButtonUp = function() end,
|
|
||||||
|
|
||||||
cranked = function(change, acceleratedChange) end, -- See Playdate SDK.
|
|
||||||
crankDocked = function() end, -- Noble Engine implementation.
|
|
||||||
crankUndocked = function() end, -- Noble Engine implementation.
|
|
||||||
|
|
||||||
orientationChanged = function() end -- Noble Engine implementation.
|
|
||||||
}
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<hr/>
|
|
||||||
|
|
||||||
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
|
|
||||||
<!-- -->
|
|
||||||
<dl class="function">
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.Input.getHandler"></a>
|
|
||||||
<span class="item-name">Noble.Input.getHandler()<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Get the currently active input handler. Returns nil if none are active.
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Returns</h3>
|
|
||||||
<ol>
|
|
||||||
|
|
||||||
<span class="types"><span class="type">table</span></span>
|
|
||||||
A table of callbacks which handle input events.
|
|
||||||
</ol>
|
|
||||||
|
|
||||||
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<a href="../classes/NobleScene.html#noblescene.inputHandler">NobleScene.inputHandler</a>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.Input.setHandler"></a>
|
|
||||||
<span class="item-name">Noble.Input.setHandler([__inputHandler=nil])<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Use this to change the active inputHandler.
|
|
||||||
<br><br>Enter <code>nil</code> to disable input. Use <a href="../modules/Noble.Input.html#Noble.Input.setEnabled">Noble.Input.setEnabled</a> to disable/enable input without losing track of the current inputHandler.
|
|
||||||
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<ul class="parameters">
|
|
||||||
<li><span class="parameter">__inputHandler</span>
|
|
||||||
<span class="types"><span class="type">table</span></span>
|
|
||||||
<span class="default">= <span class="value">nil</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
A table of callbacks which handle input events.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../classes/NobleScene.html#noblescene.inputHandler">NobleScene.inputHandler</a></li>
|
|
||||||
<li><a href="../modules/Noble.Input.html#Noble.Input.clearHandler">Noble.Input.clearHandler</a></li>
|
|
||||||
<li><a href="../modules/Noble.Input.html#Noble.Input.setEnabled">Noble.Input.setEnabled</a></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.Input.clearHandler"></a>
|
|
||||||
<span class="item-name">Noble.Input.clearHandler()<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
A helper function that calls Noble.Input.setHandler() with no argument.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<a href="../modules/Noble.Input.html#Noble.Input.setHandler">Noble.Input.setHandler</a>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.Input.setEnabled"></a>
|
|
||||||
<span class="item-name">Noble.Input.setEnabled(__value)<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Enable and disable user input without dealing with inputHanders.
|
|
||||||
The Playdate SDK requires removing all inputHanders to halt user input, so while the currentHandler is cleared when <code>false</code> is passed to this method,
|
|
||||||
it is cached so it can be later re-enabled by passing <code>true</code> it.
|
|
||||||
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<ul class="parameters">
|
|
||||||
<li><span class="parameter">__value</span>
|
|
||||||
<span class="types"><span class="type">boolean</span></span>
|
|
||||||
<br/>
|
|
||||||
Set to false to halt input. Set to true to resume accepting input.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../modules/Noble.Input.html#Noble.Input.getHandler">Noble.Input.getHandler</a></li>
|
|
||||||
<li><a href="../modules/Noble.Input.html#Noble.Input.clearHandler">Noble.Input.clearHandler</a></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.Input.getEnabled"></a>
|
|
||||||
<span class="item-name">Noble.Input.getEnabled()<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Checks to see that there is an active inputHandler
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Returns</h3>
|
|
||||||
<ol>
|
|
||||||
|
|
||||||
<span class="types"><span class="type">bool</span></span>
|
|
||||||
Returns true if the input system is enabled. Returns false if <code>setEnabled(false)</code> was used, or if currentHandler is <code>nil</code>.
|
|
||||||
</ol>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.Input.setCrankIndicatorStatus"></a>
|
|
||||||
<span class="item-name">Noble.Input.setCrankIndicatorStatus(__active[, __evenWhenUndocked=false])<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Enable/disable on-screen system crank indicator. </p>
|
|
||||||
|
|
||||||
<p> <strong>NOTE: The indicator will only ever show if the crank is docked, unless <code>__evenWhenUndocked</code> is true.</strong>
|
|
||||||
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<ul class="parameters">
|
|
||||||
<li><span class="parameter">__active</span>
|
|
||||||
<span class="types"><span class="type">boolean</span></span>
|
|
||||||
<br/>
|
|
||||||
Set true to start showing the on-screen crank indicator. Set false to stop showing it.
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__evenWhenUndocked</span>
|
|
||||||
<span class="types"><span class="type">boolean</span></span>
|
|
||||||
<span class="default">= <span class="value">false</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
Set true to show the crank indicator even if the crank is already undocked (<code>__active</code> must also be true).
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.Input.getCrankIndicatorStatus"></a>
|
|
||||||
<span class="item-name">Noble.Input.getCrankIndicatorStatus()<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Checks whether the system crank indicator status. Returns a tuple.
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Returns</h3>
|
|
||||||
<ol>
|
|
||||||
<li>
|
|
||||||
<span class="types"><span class="type">bool</span></span>
|
|
||||||
Is the crank indicator active?</li>
|
|
||||||
<li>
|
|
||||||
<span class="types"><span class="type">bool</span></span>
|
|
||||||
Is the crank indicator being forced when active, even when the crank is undocked?</li>
|
|
||||||
</ol>
|
|
||||||
|
|
||||||
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<a href="../modules/Noble.Input.html#Noble.Input.setCrankIndicatorStatus">Noble.Input.setCrankIndicatorStatus</a>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.Input.getOrientation"></a>
|
|
||||||
<span class="item-name">Noble.Input.getOrientation([__getStoredValues=false])<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Checks the current display orientation of the device. Returns a tuple.
|
|
||||||
If the accelerometer is not currently enabled, this method will turn it on, return current values, and then turn it off.
|
|
||||||
If you are trying to get raw accelerometer values rather than the display orientation, you may want to use <code>playdate.readAccelerometer()</code> instead.
|
|
||||||
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<ul class="parameters">
|
|
||||||
<li><span class="parameter">__getStoredValues</span>
|
|
||||||
<span class="types"><span class="type">boolean</span></span>
|
|
||||||
<span class="default">= <span class="value">false</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
If true, this method will simply return the most recently stored values, rather than use the accelerometer to check for new ones.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3>Returns</h3>
|
|
||||||
<ol>
|
|
||||||
<li>
|
|
||||||
<span class="types"><span class="type">str</span></span>
|
|
||||||
The named orientation of the device (a pseudo enum Noble.Input.ORIENTATION_XX)</li>
|
|
||||||
<li>
|
|
||||||
<span class="types"><span class="type">list</span></span>
|
|
||||||
Accelerometer values, where list[1] is x, list[2] is y and list[3] is z</li>
|
|
||||||
</ol>
|
|
||||||
|
|
||||||
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<a href="../modules/Noble.Input.html#Noble.Input.ORIENTATION_UP">Noble.Input.ORIENTATION_UP</a>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
<h2 class="section-header has-description"><a name="Constants"></a>Constants
|
|
||||||
</h2>
|
|
||||||
<!-- -->
|
|
||||||
<div class="section-description">
|
|
||||||
A set of constants referencing device inputs, stored as strings. Can be used for querying button input,
|
|
||||||
but are mainly for on-screen prompts or other elements where a string literal is useful, such as a filename, GameData value, or localization key.
|
|
||||||
For faster performance, use the ones that exist in the Playdate SDK (i.e.: <code>playdate.kButtonA</code>), which are stored as binary numbers.
|
|
||||||
</div>
|
|
||||||
<h3>Usage</h3>
|
|
||||||
<pre class="example"><span class="keyword">function</span> <span class="function-name">newPrompt</span>(__input, __promptString)
|
|
||||||
<span class="comment">-- ...
|
|
||||||
</span> <span class="keyword">local</span> icon = Graphics.image.<span class="function-name">new</span>(<span class="string">"assets/images/UI/Icon_"</span> .. __input)
|
|
||||||
<span class="comment">-- ...
|
|
||||||
</span><span class="keyword">end</span>
|
|
||||||
|
|
||||||
promptMove = <span class="function-name">newPrompt</span>(Noble.Input.DPAD_HORIZONTAL, <span class="string">"Move!"</span>) <span class="comment">-- assets/images/UI/Icon_dPadHorizontal.png"
|
|
||||||
</span>promptJump = <span class="function-name">newPrompt</span>(Noble.Input.BUTTON_A, <span class="string">"Jump!"</span>) <span class="comment">-- assets/images/UI/Icon_buttonA.png"
|
|
||||||
</span>promptCharge = <span class="function-name">newPrompt</span>(Noble.Input.CRANK_FORWARD, <span class="string">"Charge the battery!"</span>) <span class="comment">-- assets/images/UI/Icon_crankForward.png"</span></pre>
|
|
||||||
<dl class="function">
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.Input.BUTTON_A"></a>
|
|
||||||
<span class="item-name">Noble.Input.BUTTON_A<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
<code>"buttonA"</code>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.Input.BUTTON_B"></a>
|
|
||||||
<span class="item-name">Noble.Input.BUTTON_B<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
<code>"buttonB"</code>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.Input.BUTTON_MENU"></a>
|
|
||||||
<span class="item-name">Noble.Input.BUTTON_MENU<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
The system menu button. </p>
|
|
||||||
|
|
||||||
<p> <code>"buttonMenu"</code>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.Input.DPAD"></a>
|
|
||||||
<span class="item-name">Noble.Input.DPAD<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Referencing the D-pad component itself, rather than an input. </p>
|
|
||||||
|
|
||||||
<p> <code>"dPad"</code>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.Input.DPAD_HORIZONTAL"></a>
|
|
||||||
<span class="item-name">Noble.Input.DPAD_HORIZONTAL<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Referencing the left and right input D-pad inputs. </p>
|
|
||||||
|
|
||||||
<p> <code>"dPadHorizontal"</code>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.Input.DPAD_VERTICAL"></a>
|
|
||||||
<span class="item-name">Noble.Input.DPAD_VERTICAL<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Referencing the up and down input D-pad inputs. </p>
|
|
||||||
|
|
||||||
<p> <code>"dPadVertical"</code>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.Input.DPAD_UP"></a>
|
|
||||||
<span class="item-name">Noble.Input.DPAD_UP<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
<code>"dPadUp"</code>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.Input.DPAD_DOWN"></a>
|
|
||||||
<span class="item-name">Noble.Input.DPAD_DOWN<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
<code>"dPadDown"</code>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.Input.DPAD_LEFT"></a>
|
|
||||||
<span class="item-name">Noble.Input.DPAD_LEFT<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
<code>"dPadLeft"</code>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.Input.DPAD_RIGHT"></a>
|
|
||||||
<span class="item-name">Noble.Input.DPAD_RIGHT<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
<code>"dPadRight"</code>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.Input.CRANK"></a>
|
|
||||||
<span class="item-name">Noble.Input.CRANK<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Referencing the crank component itself, rather than an input. </p>
|
|
||||||
|
|
||||||
<p> <code>"crank"</code>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.Input.CRANK_FORWARD"></a>
|
|
||||||
<span class="item-name">Noble.Input.CRANK_FORWARD<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
AKA: Clockwise. See Playdate SDK.</p>
|
|
||||||
|
|
||||||
<p> <code>"crankForward"</code>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.Input.CRANK_REVERSE"></a>
|
|
||||||
<span class="item-name">Noble.Input.CRANK_REVERSE<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
AKA: Anticlockwise. See Playdate SDK.</p>
|
|
||||||
|
|
||||||
<p> <code>"crankReverse"</code>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.Input.CRANK_DOCK"></a>
|
|
||||||
<span class="item-name">Noble.Input.CRANK_DOCK<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Referencing the action of docking the crank. </p>
|
|
||||||
|
|
||||||
<p> <code>"crankDock"</code>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.Input.CRANK_UNDOCK"></a>
|
|
||||||
<span class="item-name">Noble.Input.CRANK_UNDOCK<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Referencing the action of undocking the crank. </p>
|
|
||||||
|
|
||||||
<p> <code>"crankUndock"</code>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.Input.ORIENTATION_UP"></a>
|
|
||||||
<span class="item-name">Noble.Input.ORIENTATION_UP<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Referencing the display orientations. </p>
|
|
||||||
|
|
||||||
<p> <code>"orientationUp"</code>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
|
|
||||||
|
|
||||||
</div> <!-- id="content" -->
|
|
||||||
|
|
||||||
</div> <!-- id="main" -->
|
|
||||||
|
|
||||||
<div id="about">
|
|
||||||
<span><a href="https://github.com/NobleRobot/NobleEngine">Noble Engine</a> by Mark LaCroix, <a href="https://noblerobot.com">Noble Robot</a></span>
|
|
||||||
<span style="float:right;">
|
|
||||||
Documentation created using <a href="https://github.com/stevedonovan/LDoc">LDoc 1.5.0</a>.
|
|
||||||
</span>
|
|
||||||
</div> <!-- id="about" -->
|
|
||||||
|
|
||||||
</div> <!-- id="container" -->
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
@ -1,928 +0,0 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
||||||
<html>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
|
||||||
<head>
|
|
||||||
<title>Noble Engine API reference</title>
|
|
||||||
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
|
|
||||||
<link rel="icon" href="favicon.ico">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<div id="container">
|
|
||||||
|
|
||||||
<div id="main">
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Menu -->
|
|
||||||
|
|
||||||
<div id="navigation">
|
|
||||||
<a href="../index.html"><div class="logo">
|
|
||||||
<h1>Noble Engine</h1>
|
|
||||||
</div></a>
|
|
||||||
|
|
||||||
<div class="nav-module">
|
|
||||||
<h2>Noble.Menu</h2>
|
|
||||||
<ul>
|
|
||||||
<h3>Setup </h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="#Noble.Menu.new">.new</a></li>
|
|
||||||
<li><a href="#menu:addItem">menu:addItem</a></li>
|
|
||||||
<li><a href="#menu:removeItem">menu:removeItem</a></li>
|
|
||||||
</ul>
|
|
||||||
<h3>Properties </h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="#menu.localized">menu.localized</a></li>
|
|
||||||
<li><a href="#menu.currentItemNumber">menu.currentItemNumber</a></li>
|
|
||||||
<li><a href="#menu.currentItemName">menu.currentItemName</a></li>
|
|
||||||
<li><a href="#menu.width">menu.width</a></li>
|
|
||||||
</ul>
|
|
||||||
<h3>Methods </h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="#menu:activate">menu:activate</a></li>
|
|
||||||
<li><a href="#menu:deactivate">menu:deactivate</a></li>
|
|
||||||
<li><a href="#menu:isActive">menu:isActive</a></li>
|
|
||||||
<li><a href="#menu:selectPrevious">menu:selectPrevious</a></li>
|
|
||||||
<li><a href="#menu:selectNext">menu:selectNext</a></li>
|
|
||||||
<li><a href="#menu:select">menu:select</a></li>
|
|
||||||
<li><a href="#menu:click">menu:click</a></li>
|
|
||||||
<li><a href="#menu:getItemDisplayName">menu:getItemDisplayName</a></li>
|
|
||||||
<li><a href="#menu:setItemDisplayName">menu:setItemDisplayName</a></li>
|
|
||||||
</ul>
|
|
||||||
<h3>Tables </h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="#menu.itemNames">menu.itemNames</a></li>
|
|
||||||
<li><a href="#menu.clickHandlers">menu.clickHandlers</a></li>
|
|
||||||
<li><a href="#menu.itemPositions">menu.itemPositions</a></li>
|
|
||||||
<li><a href="#menu.itemWidths">menu.itemWidths</a></li>
|
|
||||||
</ul>
|
|
||||||
<h3>Drawing </h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="#menu:draw">menu:draw</a></li>
|
|
||||||
<li><a href="#menu:drawItem">menu:drawItem</a></li>
|
|
||||||
<li><a href="#menu:drawSelectedItem">menu:drawSelectedItem</a></li>
|
|
||||||
</ul>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="nav-modules">
|
|
||||||
<div class="nav-kind">
|
|
||||||
<h3>Modules</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../modules/Noble.html">Noble</a></li>
|
|
||||||
<li><a href="../modules/Noble.Animation.html">Noble.Animation</a></li>
|
|
||||||
<li><a href="../modules/Noble.Bonk.html">Noble.Bonk</a></li>
|
|
||||||
<li><a href="../modules/Noble.GameData.html">Noble.GameData</a></li>
|
|
||||||
<li><a href="../modules/Noble.Input.html">Noble.Input</a></li>
|
|
||||||
<li><span class="selected">Noble.Menu</span></li>
|
|
||||||
<li><a href="../modules/Noble.Settings.html">Noble.Settings</a></li>
|
|
||||||
<li><a href="../modules/Noble.Text.html">Noble.Text</a></li>
|
|
||||||
<li><a href="../modules/Noble.Transition.html">Noble.Transition</a></li>
|
|
||||||
<li><a href="../modules/Ease.html">Ease</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="nav-kind">
|
|
||||||
<h3>Classes</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../classes/NobleScene.html">NobleScene</a></li>
|
|
||||||
<li><a href="../classes/NobleSprite.html">NobleSprite</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="nav-kind">
|
|
||||||
<h3>Examples</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../examples/SceneTemplate.lua.html">SceneTemplate.lua</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="content">
|
|
||||||
|
|
||||||
<h1>Noble.Menu</h1>
|
|
||||||
<p>An extended implementation of <code>playdate.ui.gridview</code>, meant for 1-dimensional, single-screen text menus.</p>
|
|
||||||
<p>
|
|
||||||
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<hr/>
|
|
||||||
|
|
||||||
<h2 class="section-header "><a name="Setup"></a>Setup </h2>
|
|
||||||
<!-- -->
|
|
||||||
<dl class="function">
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.Menu.new"></a>
|
|
||||||
<span class="item-name">Noble.Menu.new([__activate=true[, __alignment=Noble.Text.ALIGN_LEFT[, __localized=false[, __color=Graphics.kColorBlack[, __padding=2[, __horizontalPadding[, __margin=2[, __font=Noble.Text.getCurrentFont()[, __selectedCornerRadius=__font:getHeight()/4[, __selectedOutlineThickness=1]]]]]]]]]])<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Create a new menu object.
|
|
||||||
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<ul class="parameters">
|
|
||||||
<li><span class="parameter">__activate</span>
|
|
||||||
<span class="types"><span class="type">boolean</span></span>
|
|
||||||
<span class="default">= <span class="value">true</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
<a href="../modules/Noble.Menu.html#menu:activate">Activate</a> this menu upon creation.
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__alignment</span>
|
|
||||||
<span class="default">= <span class="value">Noble.Text.ALIGN_LEFT</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
The text alignment of menu items.
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__localized</span>
|
|
||||||
<span class="types"><span class="type">boolean</span></span>
|
|
||||||
<span class="default">= <span class="value">false</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
If true, menu item names are localization keys rather than display names.
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__color</span>
|
|
||||||
<span class="default">= <span class="value">Graphics.kColorBlack</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
The color of menu item text. The selected highlight will be the inverse color.
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__padding</span>
|
|
||||||
<span class="types"><span class="type">integer</span></span>
|
|
||||||
<span class="default">= <span class="value">2</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
Cell padding for menu items.
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__horizontalPadding</span>
|
|
||||||
<span class="types"><span class="type">integer</span></span>
|
|
||||||
<span class="optional">(optional)</span>
|
|
||||||
<br/>
|
|
||||||
Use this to override horizontal padding, useful for certain fonts. If nil, uses __padding.
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__margin</span>
|
|
||||||
<span class="types"><span class="type">integer</span></span>
|
|
||||||
<span class="default">= <span class="value">2</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
Spacing between menu items.
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__font</span>
|
|
||||||
<span class="default">= <span class="value">Noble.Text.getCurrentFont()</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
If nil, uses current set font.
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__selectedCornerRadius</span>
|
|
||||||
<span class="types"><span class="type">integer</span></span>
|
|
||||||
<span class="default">= <span class="value">__font:getHeight()/4</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
Sets rounded corners for a selected menu item.
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__selectedOutlineThickness</span>
|
|
||||||
<span class="types"><span class="type">integer</span></span>
|
|
||||||
<span class="default">= <span class="value">1</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
Sets the outline thickness for selected items.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3>Returns</h3>
|
|
||||||
<ol>
|
|
||||||
|
|
||||||
<code>menu</code>, a new menu item.
|
|
||||||
</ol>
|
|
||||||
|
|
||||||
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<a href="../modules/Noble.Menu.html#menu:addItem">addItem</a>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3>Usage</h3>
|
|
||||||
<pre class="example"><span class="keyword">local</span> menu = Noble.Menu.<span class="function-name">new</span>(
|
|
||||||
<span class="keyword">true</span>,
|
|
||||||
Noble.Text.ALIGN_CENTER,
|
|
||||||
<span class="keyword">false</span>,
|
|
||||||
Graphics.kColorWhite,
|
|
||||||
<span class="number">4</span>, <span class="number">6</span>,
|
|
||||||
Noble.Text.large,
|
|
||||||
<span class="keyword">nil</span>, <span class="number">3</span>
|
|
||||||
)
|
|
||||||
menu:<span class="function-name">addItem</span>(<span class="string">"Play Game"</span>, <span class="keyword">function</span>() TitleScreen:<span class="function-name">playGame</span>() <span class="keyword">end</span>)
|
|
||||||
menu:<span class="function-name">addItem</span>(<span class="string">"Options"</span>, <span class="keyword">function</span>() Noble.<span class="function-name">transition</span>(OptionsScreen) <span class="keyword">end</span>)
|
|
||||||
menu:<span class="function-name">addItem</span>(<span class="string">"Credits"</span>, <span class="keyword">function</span>() Noble.<span class="function-name">transition</span>(CreditsScreen) <span class="keyword">end</span>)</pre>
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "menu:addItem"></a>
|
|
||||||
<span class="item-name">menu:addItem(__nameOrKey[, __clickHandler[, __position[, __displayName[, __displayNameIsALocalizationKey=false]]]])<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Adds a item to this menu.
|
|
||||||
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<ul class="parameters">
|
|
||||||
<li><span class="parameter">__nameOrKey</span>
|
|
||||||
<span class="types"><span class="type">string</span></span>
|
|
||||||
<br/>
|
|
||||||
The name of this menu item. It can be a display name or a localization key. <strong>Must be unique.</strong>
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__clickHandler</span>
|
|
||||||
<span class="types"><span class="type">function</span></span>
|
|
||||||
<span class="optional">(optional)</span>
|
|
||||||
<br/>
|
|
||||||
The function that runs when this menu item is "clicked."
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__position</span>
|
|
||||||
<span class="types"><span class="type">integer</span></span>
|
|
||||||
<span class="optional">(optional)</span>
|
|
||||||
<br/>
|
|
||||||
Insert the item at a specific position. If not set, adds to the end of the list.
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__displayName</span>
|
|
||||||
<span class="types"><span class="type">string</span></span>
|
|
||||||
<span class="optional">(optional)</span>
|
|
||||||
<br/>
|
|
||||||
You can create an optional, separate display name for this item. You can add or change this at runtime via <a href="../modules/Noble.Menu.html#menu:setItemDisplayName">setItemDisplayName</a>.
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__displayNameIsALocalizationKey</span>
|
|
||||||
<span class="types"><span class="type">boolean</span></span>
|
|
||||||
<span class="default">= <span class="value">false</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
If true, will treat the <code>__displayName</code> as a localization key. This is separate from this menu's <a href="../modules/Noble.Menu.html#menu.localized">localized</a> value.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../modules/Noble.Menu.html#Noble.Menu.new">Noble.Menu.new</a></li>
|
|
||||||
<li><a href="../modules/Noble.Menu.html#menu:removeItem">removeItem</a></li>
|
|
||||||
<li><a href="../modules/Noble.Menu.html#menu:setItemDisplayName">setItemDisplayName</a></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "menu:removeItem"></a>
|
|
||||||
<span class="item-name">menu:removeItem([__menuItem=#menu.itemNames])<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Removes a item from this menu.
|
|
||||||
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<ul class="parameters">
|
|
||||||
<li><span class="parameter">__menuItem</span>
|
|
||||||
<span class="types"><span class="type">int</span> or <span class="type">string</span></span>
|
|
||||||
<span class="default">= <span class="value">#menu.itemNames</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
The menu item to remove. You can enter either the item's name/key or it's position. If left blank, removes the last item.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<a href="../modules/Noble.Menu.html#menu:addItem">addItem</a>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
<h2 class="section-header "><a name="Properties"></a>Properties </h2>
|
|
||||||
<!-- -->
|
|
||||||
<dl class="function">
|
|
||||||
<dt>
|
|
||||||
<a name = "menu.localized"></a>
|
|
||||||
<span class="item-name">menu.localized<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<ul class="parameters">
|
|
||||||
<li><span class="parameter">_</span>
|
|
||||||
<span class="types"><span class="type">boolean</span></span>
|
|
||||||
<span class="default">= <span class="value">false</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
Indicates whether this menu's item names are treated as localization keys.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "menu.currentItemNumber"></a>
|
|
||||||
<span class="item-name">menu.currentItemNumber<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<ul class="parameters">
|
|
||||||
<li><span class="parameter">_</span>
|
|
||||||
<span class="types"><span class="type">integer</span></span>
|
|
||||||
<br/>
|
|
||||||
The current menu item's index.</p>
|
|
||||||
|
|
||||||
<p> This is meant as a <strong>read-only</strong> value. Do not modify it directly.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<a href="../modules/Noble.Menu.html#menu:select">select</a>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "menu.currentItemName"></a>
|
|
||||||
<span class="item-name">menu.currentItemName<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<ul class="parameters">
|
|
||||||
<li><span class="parameter">_</span>
|
|
||||||
<span class="types"><span class="type">string</span></span>
|
|
||||||
<br/>
|
|
||||||
The current menu item's name.</p>
|
|
||||||
|
|
||||||
<p> This is meant as a <strong>read-only</strong> value. Do not modify it directly.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<a href="../modules/Noble.Menu.html#menu:select">select</a>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "menu.width"></a>
|
|
||||||
<span class="item-name">menu.width<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<ul class="parameters">
|
|
||||||
<li><span class="parameter">_</span>
|
|
||||||
<span class="types"><span class="type">integer</span></span>
|
|
||||||
<br/>
|
|
||||||
The width of the widest menu item plus the menu's horizontal padding.</p>
|
|
||||||
|
|
||||||
<p> This is meant as a <strong>read-only</strong> value. Do not modify it directly.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
<h2 class="section-header "><a name="Methods"></a>Methods </h2>
|
|
||||||
<!-- -->
|
|
||||||
<dl class="function">
|
|
||||||
<dt>
|
|
||||||
<a name = "menu:activate"></a>
|
|
||||||
<span class="item-name">menu:activate()<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Activate this menu.
|
|
||||||
This selects the most recently selected menu item (or the first item if none have been previously selected), and enables this menu's <a href="../modules/Noble.Menu.html#menu:selectPrevious">selectPrevious</a>, <a href="../modules/Noble.Menu.html#menu:selectNext">selectNext</a>, and <a href="../modules/Noble.Menu.html#menu:click">click</a> methods.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Usage</h3>
|
|
||||||
<pre class="example"><span class="keyword">local</span> menu = Noble.Menu.<span class="function-name">new</span>(<span class="keyword">false</span>)
|
|
||||||
menu:<span class="function-name">activate</span>()</pre>
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "menu:deactivate"></a>
|
|
||||||
<span class="item-name">menu:deactivate()<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Deactivate this menu.
|
|
||||||
This deselects all menu items, and disables this menu's <a href="../modules/Noble.Menu.html#menu:selectPrevious">selectPrevious</a>, <a href="../modules/Noble.Menu.html#menu:selectNext">selectNext</a>, and <a href="../modules/Noble.Menu.html#menu:click">click</a> methods.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Usage</h3>
|
|
||||||
<pre class="example"><span class="keyword">local</span> menu = Noble.Menu.<span class="function-name">new</span>(<span class="keyword">true</span>)
|
|
||||||
menu:<span class="function-name">deactivate</span>()</pre>
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "menu:isActive"></a>
|
|
||||||
<span class="item-name">menu:isActive()<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Check to see if this menu is currently active.
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Returns</h3>
|
|
||||||
<ol>
|
|
||||||
|
|
||||||
<span class="types"><span class="type">bool</span></span>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</ol>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "menu:selectPrevious"></a>
|
|
||||||
<span class="item-name">menu:selectPrevious([__force=false[, __wrapSelection=true]])<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Selects the previous item in this menu. <strong>This menu must be active.</strong>
|
|
||||||
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<ul class="parameters">
|
|
||||||
<li><span class="parameter">__force</span>
|
|
||||||
<span class="types"><span class="type">boolean</span></span>
|
|
||||||
<span class="default">= <span class="value">false</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
Force this method to run, even if this menu is not active.
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__wrapSelection</span>
|
|
||||||
<span class="types"><span class="type">boolean</span></span>
|
|
||||||
<span class="default">= <span class="value">true</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
Selects the final menu item if the first menu item is currently selected.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<a href="../modules/Noble.Menu.html#menu:activate">activate</a>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3>Usage</h3>
|
|
||||||
<pre class="example">TitleScreen.inputHandler.upButtonDown = <span class="keyword">function</span>()
|
|
||||||
menu:<span class="function-name">selectPrevious</span>()
|
|
||||||
<span class="keyword">end</span></pre>
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "menu:selectNext"></a>
|
|
||||||
<span class="item-name">menu:selectNext([__force=false[, __wrapSelection=true]])<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Selects the next previous item in this menu. <strong>This menu must be active.</strong>
|
|
||||||
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<ul class="parameters">
|
|
||||||
<li><span class="parameter">__force</span>
|
|
||||||
<span class="types"><span class="type">boolean</span></span>
|
|
||||||
<span class="default">= <span class="value">false</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
Force this method to run, even if this menu is not active.
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__wrapSelection</span>
|
|
||||||
<span class="types"><span class="type">boolean</span></span>
|
|
||||||
<span class="default">= <span class="value">true</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
Selects the first menu item if the final menu item is currently selected.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<a href="../modules/Noble.Menu.html#menu:activate">activate</a>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3>Usage</h3>
|
|
||||||
<pre class="example">TitleScreen.inputHandler.downButtonDown = <span class="keyword">function</span>()
|
|
||||||
menu:<span class="function-name">selectNext</span>()
|
|
||||||
<span class="keyword">end</span></pre>
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "menu:select"></a>
|
|
||||||
<span class="item-name">menu:select(__menuItem[, __force=false])<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Selects a specific item in this menu, either by it's index, or it's name. <strong>This menu must be active.</strong>
|
|
||||||
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<ul class="parameters">
|
|
||||||
<li><span class="parameter">__menuItem</span>
|
|
||||||
<span class="types"><span class="type">int</span> or <span class="type">string</span></span>
|
|
||||||
<br/>
|
|
||||||
The menu item to select. You can enter the item's number or it's name/key.
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__force</span>
|
|
||||||
<span class="types"><span class="type">boolean</span></span>
|
|
||||||
<span class="default">= <span class="value">false</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
Force this method to run, even if this menu is not active.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<a href="../modules/Noble.Menu.html#menu:activate">activate</a>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3>Usage</h3>
|
|
||||||
<pre class="example"><span class="keyword">function</span> <span class="function-name">resetMenu</span>()
|
|
||||||
menu:<span class="global">select</span>(<span class="number">1</span>, <span class="keyword">true</span>)
|
|
||||||
menu:<span class="function-name">deactivate</span>()
|
|
||||||
<span class="keyword">end</span></pre>
|
|
||||||
<pre class="example"><span class="keyword">function</span> <span class="function-name">resetMenu</span>()
|
|
||||||
menu:<span class="global">select</span>(<span class="string">"Play Game"</span>, <span class="keyword">true</span>)
|
|
||||||
menu:<span class="function-name">deactivate</span>()
|
|
||||||
<span class="keyword">end</span></pre>
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "menu:click"></a>
|
|
||||||
<span class="item-name">menu:click([__force=false])<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Runs the function associated with the currently selected menu item. <strong>This menu must be active.</strong>
|
|
||||||
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<ul class="parameters">
|
|
||||||
<li><span class="parameter">__force</span>
|
|
||||||
<span class="types"><span class="type">boolean</span></span>
|
|
||||||
<span class="default">= <span class="value">false</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
Force this method to run, even if this menu is not active.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<a href="../modules/Noble.Menu.html#menu:activate">activate</a>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3>Usage</h3>
|
|
||||||
<pre class="example">TitleScreen.inputHandler.AButtonDown = <span class="keyword">function</span>()
|
|
||||||
menu:<span class="function-name">click</span>()
|
|
||||||
<span class="keyword">end</span></pre>
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "menu:getItemDisplayName"></a>
|
|
||||||
<span class="item-name">menu:getItemDisplayName(__itemName)<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Gets the display name of a menu item. </p>
|
|
||||||
|
|
||||||
<p> If a menu item does not have a display name, then the <code>__nameOrKey</code> (or its localized string) will be returned instead. This method is used internally when <a href="../modules/Noble.Menu.html#menu:draw">draw</a> is called.</p>
|
|
||||||
|
|
||||||
<p> If this menu's <a href="../modules/Noble.Menu.html#menu.localized">localized</a> value is true, a returned <code>__nameOrKey</code> will always be localized, but a returned display name is only localized if the <code>__displayNameIsALocalizationKey</code> argument was set to <code>true</code> when the display name was added.
|
|
||||||
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<ul class="parameters">
|
|
||||||
<li><span class="parameter">__itemName</span>
|
|
||||||
<span class="types"><span class="type">string</span></span>
|
|
||||||
<br/>
|
|
||||||
The menu item you want the display name of.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3>Returns</h3>
|
|
||||||
<ol>
|
|
||||||
|
|
||||||
<span class="types"><span class="type">string</span></span>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</ol>
|
|
||||||
|
|
||||||
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../modules/Noble.Menu.html#menu:addItem">addItem</a></li>
|
|
||||||
<li><a href="../modules/Noble.Menu.html#menu:setItemDisplayName">setItemDisplayName</a></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "menu:setItemDisplayName"></a>
|
|
||||||
<span class="item-name">menu:setItemDisplayName(__itemName, __displayName[, __displayNameIsALocalizationKey=false])<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
When you add a menu item, you can give it a display name that's different from it's actual name. This method adds or changes the display name of a menu item.
|
|
||||||
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<ul class="parameters">
|
|
||||||
<li><span class="parameter">__itemName</span>
|
|
||||||
<span class="types"><span class="type">string</span></span>
|
|
||||||
<br/>
|
|
||||||
The menu item name (or key if this menu uses localization keys).
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__displayName</span>
|
|
||||||
<span class="types"><span class="type">string</span></span>
|
|
||||||
<br/>
|
|
||||||
The display name.
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__displayNameIsALocalizationKey</span>
|
|
||||||
<span class="types"><span class="type">boolean</span></span>
|
|
||||||
<span class="default">= <span class="value">false</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
Set to use to indicate that this display name is a localization key. This setting is separate from <a href="../modules/Noble.Menu.html#menu.localized">localized</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Usage</h3>
|
|
||||||
<pre class="example"><span class="keyword">function</span> <span class="function-name">changeDifficultyLevel</span>(__level)
|
|
||||||
menu:<span class="function-name">setItemDisplayName</span>(<span class="string">"Difficulty"</span>, <span class="string">"Difficulty: "</span> .. __level)
|
|
||||||
<span class="keyword">end</span></pre>
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
<h2 class="section-header "><a name="Tables"></a>Tables </h2>
|
|
||||||
<!-- -->
|
|
||||||
<dl class="function">
|
|
||||||
<dt>
|
|
||||||
<a name = "menu.itemNames"></a>
|
|
||||||
<span class="item-name">menu.itemNames<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
A string "array" of menu item strings/keys.
|
|
||||||
<strong>You cannot add or remove menu items by modifying this table</strong>.
|
|
||||||
It is meant as a <strong>read-only</strong> table, provided for convenience when iterating, etc. Modifying its values may break other methods.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<a href="../modules/Noble.Menu.html#menu:addItem">addItem</a>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3>Usage</h3>
|
|
||||||
<pre class="example"><span class="keyword">for</span> i = <span class="number">1</span>, #menu.itemNames, <span class="number">1</span> <span class="keyword">do</span>
|
|
||||||
menu.clickHandlers[menu.itemNames[i]] = <span class="keyword">nil</span> <span class="comment">-- Clears all click handlers, for some reason.
|
|
||||||
</span><span class="keyword">end</span></pre>
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "menu.clickHandlers"></a>
|
|
||||||
<span class="item-name">menu.clickHandlers<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
A table of functions associated with menu items. Items are a defined when calling <a href="../modules/Noble.Menu.html#menu:addItem">addItem</a>, but their associated functions may be modified afterward.</p>
|
|
||||||
|
|
||||||
<p> <strong>You cannot add or remove menu items by modifying this table</strong>.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../modules/Noble.Menu.html#menu:addItem">addItem</a></li>
|
|
||||||
<li><a href="../modules/Noble.Menu.html#menu:removeItem">removeItem</a></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3>Usage</h3>
|
|
||||||
<pre class="example"><span class="keyword">local</span> menu = Noble.Menu.<span class="function-name">new</span>(<span class="keyword">true</span>)
|
|
||||||
menu.<span class="function-name">addItem</span>(<span class="string">"Play Game"</span>)
|
|
||||||
menu.<span class="function-name">addItem</span>(<span class="string">"Options"</span>)
|
|
||||||
|
|
||||||
menu.clickHandlers[<span class="string">"Play Game"</span>] = <span class="keyword">function</span>() TitleScreen:<span class="function-name">playGame</span>() <span class="keyword">end</span>
|
|
||||||
menu.clickHandlers[<span class="string">"Options"</span>] = <span class="keyword">function</span>() Noble.<span class="function-name">transition</span>(OptionsScreen) <span class="keyword">end</span></pre>
|
|
||||||
<pre class="example"><span class="keyword">local</span> menu = Noble.Menu.<span class="function-name">new</span>(<span class="keyword">true</span>)
|
|
||||||
menu.<span class="function-name">addItem</span>(<span class="string">"Play Game"</span>)
|
|
||||||
menu.<span class="function-name">addItem</span>(<span class="string">"Options"</span>)
|
|
||||||
|
|
||||||
menu.clickHandlers = {
|
|
||||||
[<span class="string">"Play Game"</span>] = <span class="keyword">function</span> TitleScreen:<span class="function-name">playGame</span>() <span class="keyword">end</span>,
|
|
||||||
[<span class="string">"Options"</span>] = <span class="keyword">function</span>() Noble.<span class="function-name">transition</span>(OptionsScreen) <span class="keyword">end</span>
|
|
||||||
}</pre>
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "menu.itemPositions"></a>
|
|
||||||
<span class="item-name">menu.itemPositions<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
A key/value table of menu item indices. </p>
|
|
||||||
|
|
||||||
<p> This is meant as a <strong>read-only</strong> table, provided for convenience. Modifying its values will break other methods.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Usage</h3>
|
|
||||||
<pre class="example">menu.itemPositions[<span class="string">"Play Game"</span>] <span class="comment">-- 1
|
|
||||||
</span>menu.itemPositions[<span class="string">"Options"</span>] <span class="comment">-- 2</span></pre>
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "menu.itemWidths"></a>
|
|
||||||
<span class="item-name">menu.itemWidths<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
A key/value table of pixel widths for each menu item, based on its text. Useful for animation, layout, etc.</p>
|
|
||||||
|
|
||||||
<p> This is meant as a <strong>read-only</strong> table, provided for convenience. Modifying its values will break other methods.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Usage</h3>
|
|
||||||
<pre class="example"><span class="keyword">local</span> playGameMenuItemWidth = menu.itemWidths[<span class="string">"Play Game"</span>]</pre>
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
<h2 class="section-header "><a name="Drawing"></a>Drawing </h2>
|
|
||||||
<!-- -->
|
|
||||||
<dl class="function">
|
|
||||||
<dt>
|
|
||||||
<a name = "menu:draw"></a>
|
|
||||||
<span class="item-name">menu:draw(__x, __y)<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Draw's this menu to the screen. You may call this manually, but ideally, you will put it in in your scene's <a href="../classes/NobleScene.html#noblescene:update">update</a> or <a href="../classes/NobleScene.html#noblescene:drawBackground">drawBackground</a> method.
|
|
||||||
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<ul class="parameters">
|
|
||||||
<li><span class="parameter">__x</span>
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__y</span>
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Usage</h3>
|
|
||||||
<pre class="example"><span class="keyword">function</span> YourScene:<span class="function-name">update</span>()
|
|
||||||
YourScene.super.<span class="function-name">update</span>(self)
|
|
||||||
menu:<span class="function-name">draw</span>(<span class="number">50</span>, <span class="number">100</span>)
|
|
||||||
<span class="keyword">end</span></pre>
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "menu:drawItem"></a>
|
|
||||||
<span class="item-name">menu:drawItem(__x, __y, __itemIndex)<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
This method is called for every <strong>non-selected</strong> item when <a href="../modules/Noble.Menu.html#menu:draw">draw</a> is called. You shouldn't call this directly, but you may re-implement it if you wish.
|
|
||||||
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<ul class="parameters">
|
|
||||||
<li><span class="parameter">__x</span>
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__y</span>
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__itemIndex</span>
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<a href="../modules/Noble.Text.html#Noble.Text.draw">Noble.Text.draw</a>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3>Usage</h3>
|
|
||||||
<pre class="example"><span class="comment">-- This is the default implementation for this method.
|
|
||||||
</span><span class="keyword">function</span> menu:<span class="function-name">drawItem</span>(__x, __y, __itemIndex)
|
|
||||||
Graphics.<span class="function-name">setImageDrawMode</span>(self.fillMode)
|
|
||||||
<span class="keyword">local</span> xAdjustment = <span class="number">0</span>
|
|
||||||
<span class="keyword">if</span> (self.alignment == Noble.Text.ALIGN_CENTER) <span class="keyword">then</span>
|
|
||||||
xAdjustment = self.width/<span class="number">2</span> - self.horizontalPadding/<span class="number">2</span>
|
|
||||||
<span class="keyword">elseif</span> (self.alignment == Noble.Text.ALIGN_RIGHT) <span class="keyword">then</span>
|
|
||||||
xAdjustment = self.width - self.horizontalPadding
|
|
||||||
<span class="keyword">end</span>
|
|
||||||
Noble.Text.<span class="function-name">draw</span>(self.itemNames[__itemIndex], __x + self.horizontalPadding/<span class="number">2</span> + xAdjustment, __y + self.padding/<span class="number">2</span>, self.alignment, self.localized, self.font)
|
|
||||||
<span class="keyword">end</span></pre>
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "menu:drawSelectedItem"></a>
|
|
||||||
<span class="item-name">menu:drawSelectedItem(__x, __y, __itemIndex)<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
This method is called for every <strong>selected</strong> item when <a href="../modules/Noble.Menu.html#menu:draw">draw</a> is called. You shouldn't call this directly, but you may re-implement it if you wish.
|
|
||||||
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<ul class="parameters">
|
|
||||||
<li><span class="parameter">__x</span>
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__y</span>
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__itemIndex</span>
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<a href="../modules/Noble.Text.html#Noble.Text.draw">Noble.Text.draw</a>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3>Usage</h3>
|
|
||||||
<pre class="example"><span class="comment">-- This is the default implementation for this method.
|
|
||||||
</span><span class="keyword">function</span> menu:<span class="function-name">drawSelectedItem</span>(__x, __y, __itemIndex)
|
|
||||||
<span class="keyword">local</span> xAdjustmentText = <span class="number">0</span>
|
|
||||||
<span class="keyword">local</span> xAdjustmentRect = <span class="number">0</span>
|
|
||||||
<span class="keyword">if</span> (self.alignment == Noble.Text.ALIGN_CENTER) <span class="keyword">then</span>
|
|
||||||
xAdjustmentText = self.width/<span class="number">2</span> - self.horizontalPadding/<span class="number">2</span>
|
|
||||||
xAdjustmentRect = self.width/<span class="number">2</span> - self.itemWidths[self.itemNames[__itemIndex]]/<span class="number">2</span> - self.horizontalPadding/<span class="number">2</span>
|
|
||||||
<span class="keyword">elseif</span> (self.alignment == Noble.Text.ALIGN_RIGHT) <span class="keyword">then</span>
|
|
||||||
xAdjustmentText = self.width - self.horizontalPadding
|
|
||||||
xAdjustmentRect = self.width - self.itemWidths[self.itemNames[__itemIndex]] - self.horizontalPadding
|
|
||||||
<span class="keyword">end</span>
|
|
||||||
Graphics.<span class="function-name">setColor</span>(self.color)
|
|
||||||
Graphics.<span class="function-name">fillRoundRect</span>(__x + xAdjustmentRect, __y, self.itemWidths[self.itemNames[__itemIndex]]+self.horizontalPadding, self.textHeight+self.padding, self.selectedCornerRadius)
|
|
||||||
Graphics.<span class="function-name">setColor</span>(self.otherColor)
|
|
||||||
Graphics.<span class="function-name">setLineWidth</span>(self.selectedOutlineThickness)
|
|
||||||
Graphics.<span class="function-name">drawRoundRect</span>(__x + xAdjustmentRect, __y, self.itemWidths[self.itemNames[__itemIndex]]+self.horizontalPadding, self.textHeight+self.padding, self.selectedCornerRadius)
|
|
||||||
Graphics.<span class="function-name">setImageDrawMode</span>(self.otherFillMode)
|
|
||||||
Noble.Text.<span class="function-name">draw</span>(self.itemNames[__itemIndex], __x + self.horizontalPadding/<span class="number">2</span> + xAdjustmentText, __y+self.padding/<span class="number">2</span>, self.alignment, self.localized, self.font)
|
|
||||||
<span class="keyword">end</span></pre>
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
|
|
||||||
|
|
||||||
</div> <!-- id="content" -->
|
|
||||||
|
|
||||||
</div> <!-- id="main" -->
|
|
||||||
|
|
||||||
<div id="about">
|
|
||||||
<span><a href="https://github.com/NobleRobot/NobleEngine">Noble Engine</a> by Mark LaCroix, <a href="https://noblerobot.com">Noble Robot</a></span>
|
|
||||||
<span style="float:right;">
|
|
||||||
Documentation created using <a href="https://github.com/stevedonovan/LDoc">LDoc 1.5.0</a>.
|
|
||||||
</span>
|
|
||||||
</div> <!-- id="about" -->
|
|
||||||
|
|
||||||
</div> <!-- id="container" -->
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
@ -1,331 +0,0 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
||||||
<html>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
|
||||||
<head>
|
|
||||||
<title>Noble Engine API reference</title>
|
|
||||||
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
|
|
||||||
<link rel="icon" href="favicon.ico">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<div id="container">
|
|
||||||
|
|
||||||
<div id="main">
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Menu -->
|
|
||||||
|
|
||||||
<div id="navigation">
|
|
||||||
<a href="../index.html"><div class="logo">
|
|
||||||
<h1>Noble Engine</h1>
|
|
||||||
</div></a>
|
|
||||||
|
|
||||||
<div class="nav-module">
|
|
||||||
<h2>Noble.Settings</h2>
|
|
||||||
<ul>
|
|
||||||
<h3>Functions</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="#Noble.Settings.setup">.setup</a></li>
|
|
||||||
<li><a href="#Noble.Settings.get">.get</a></li>
|
|
||||||
<li><a href="#Noble.Settings.set">.set</a></li>
|
|
||||||
<li><a href="#Noble.Settings.reset">.reset</a></li>
|
|
||||||
<li><a href="#Noble.Settings.resetSome">.resetSome</a></li>
|
|
||||||
<li><a href="#Noble.Settings.resetAll">.resetAll</a></li>
|
|
||||||
<li><a href="#Noble.Settings.save">.save</a></li>
|
|
||||||
</ul>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="nav-modules">
|
|
||||||
<div class="nav-kind">
|
|
||||||
<h3>Modules</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../modules/Noble.html">Noble</a></li>
|
|
||||||
<li><a href="../modules/Noble.Animation.html">Noble.Animation</a></li>
|
|
||||||
<li><a href="../modules/Noble.Bonk.html">Noble.Bonk</a></li>
|
|
||||||
<li><a href="../modules/Noble.GameData.html">Noble.GameData</a></li>
|
|
||||||
<li><a href="../modules/Noble.Input.html">Noble.Input</a></li>
|
|
||||||
<li><a href="../modules/Noble.Menu.html">Noble.Menu</a></li>
|
|
||||||
<li><span class="selected">Noble.Settings</span></li>
|
|
||||||
<li><a href="../modules/Noble.Text.html">Noble.Text</a></li>
|
|
||||||
<li><a href="../modules/Noble.Transition.html">Noble.Transition</a></li>
|
|
||||||
<li><a href="../modules/Ease.html">Ease</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="nav-kind">
|
|
||||||
<h3>Classes</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../classes/NobleScene.html">NobleScene</a></li>
|
|
||||||
<li><a href="../classes/NobleSprite.html">NobleSprite</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="nav-kind">
|
|
||||||
<h3>Examples</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../examples/SceneTemplate.lua.html">SceneTemplate.lua</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="content">
|
|
||||||
|
|
||||||
<h1>Noble.Settings</h1>
|
|
||||||
<p>Operations for game settings / stats.</p>
|
|
||||||
<p>
|
|
||||||
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<hr/>
|
|
||||||
|
|
||||||
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
|
|
||||||
<!-- -->
|
|
||||||
<dl class="function">
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.Settings.setup"></a>
|
|
||||||
<span class="item-name">Noble.Settings.setup(__keyValuePairs[, __saveToDisk=true[, __modifyExistingOnKeyChange=true]])<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Sets up the settings for your game. You can only run this once, and you must run it before using other <a href="../modules/Noble.Settings.html#">Noble.Settings</a> functions. It is recommended to place it in your main.lua, before <code>Noble.new()</code>.</p>
|
|
||||||
|
|
||||||
<p> <strong>NOTE:</strong> You will <em>not</em> be able to add new keys via the <a href="../modules/Noble.Settings.html#Noble.Settings.set">Noble.Settings.set</a> method. This means you need to specify the keys and default values of all of the settings in your game at setup.
|
|
||||||
If you need to add keys that are not known during setup, it is probably not a setting and you should consider using <a href="../modules/Noble.GameData.html#">Noble.GameData</a> instead.
|
|
||||||
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<ul class="parameters">
|
|
||||||
<li><span class="parameter">__keyValuePairs</span>
|
|
||||||
<span class="types"><span class="type">table</span></span>
|
|
||||||
<br/>
|
|
||||||
table. Your game's settings, and thier default values, as key/value pairs. <strong>NOTE:</strong> Do not use "nil" as a value.
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__saveToDisk</span>
|
|
||||||
<span class="types"><span class="type">boolean</span></span>
|
|
||||||
<span class="default">= <span class="value">true</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
Saves your default values immediatly to disk.
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__modifyExistingOnKeyChange</span>
|
|
||||||
<span class="types"><span class="type">boolean</span></span>
|
|
||||||
<span class="default">= <span class="value">true</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
Updates the existing settings object on disk if you make changes to your settings keys (not values) during development or when updating your game.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Usage</h3>
|
|
||||||
<pre class="example">Noble.Settings.<span class="function-name">setup</span>({
|
|
||||||
difficulty = <span class="string">"normal"</span>,
|
|
||||||
music = <span class="keyword">true</span>,
|
|
||||||
sfx = <span class="keyword">true</span>,
|
|
||||||
players = <span class="number">2</span>,
|
|
||||||
highScore = <span class="number">0</span> <span class="comment">-- You can store persistant stats here, too!
|
|
||||||
</span>})</pre>
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.Settings.get"></a>
|
|
||||||
<span class="item-name">Noble.Settings.get(__settingName)<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Get the value of a setting.
|
|
||||||
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<ul class="parameters">
|
|
||||||
<li><span class="parameter">__settingName</span>
|
|
||||||
<span class="types"><span class="type">string</span></span>
|
|
||||||
<br/>
|
|
||||||
The name of the setting.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3>Returns</h3>
|
|
||||||
<ol>
|
|
||||||
|
|
||||||
<span class="types"><span class="type">any</span></span>
|
|
||||||
The value of the requested setting.
|
|
||||||
</ol>
|
|
||||||
|
|
||||||
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<a href="../modules/Noble.Settings.html#Noble.Settings.set">Noble.Settings.set</a>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.Settings.set"></a>
|
|
||||||
<span class="item-name">Noble.Settings.set(__settingName, __value[, __saveToDisk=true])<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Set the value of a setting. </p>
|
|
||||||
|
|
||||||
<p> <strong>NOTE:</strong> If __settingName is not a key in the __keyValuePairs dictionary given to the <a href="../modules/Noble.Settings.html#Noble.Settings.setup">setup</a> method it will not be added to the Settings.
|
|
||||||
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<ul class="parameters">
|
|
||||||
<li><span class="parameter">__settingName</span>
|
|
||||||
<span class="types"><span class="type">string</span></span>
|
|
||||||
<br/>
|
|
||||||
The name of the setting.
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__value</span>
|
|
||||||
<span class="types"><span class="type">any</span></span>
|
|
||||||
<br/>
|
|
||||||
The setting's new value
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__saveToDisk</span>
|
|
||||||
<span class="types"><span class="type">boolean</span></span>
|
|
||||||
<span class="default">= <span class="value">true</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
Saves to disk immediately. Set to false if you prefer to manually save (via a confirm button, etc).
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../modules/Noble.Settings.html#Noble.Settings.setup">Noble.Settings.setup</a></li>
|
|
||||||
<li><a href="../modules/Noble.Settings.html#Noble.Settings.get">Noble.Settings.get</a></li>
|
|
||||||
<li><a href="../modules/Noble.Settings.html#Noble.Settings.save">Noble.Settings.save</a></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.Settings.reset"></a>
|
|
||||||
<span class="item-name">Noble.Settings.reset(__settingName[, __saveToDisk=true])<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Resets the value of a setting to its default value defined in <code>setup()</code>.
|
|
||||||
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<ul class="parameters">
|
|
||||||
<li><span class="parameter">__settingName</span>
|
|
||||||
<span class="types"><span class="type">string</span></span>
|
|
||||||
<br/>
|
|
||||||
The name of the setting.
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__saveToDisk</span>
|
|
||||||
<span class="types"><span class="type">boolean</span></span>
|
|
||||||
<span class="default">= <span class="value">true</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
Saves to disk immediately. Set to false if you prefer to manually save (via a confirm button, etc).
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../modules/Noble.Settings.html#Noble.Settings.resetSome">Noble.Settings.resetSome</a></li>
|
|
||||||
<li><a href="../modules/Noble.Settings.html#Noble.Settings.resetAll">Noble.Settings.resetAll</a></li>
|
|
||||||
<li><a href="../modules/Noble.Settings.html#Noble.Settings.save">Noble.Settings.save</a></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.Settings.resetSome"></a>
|
|
||||||
<span class="item-name">Noble.Settings.resetSome(__settingNames[, __saveToDisk=true])<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Resets the value of multiple settings to thier default value defined in <code>setup()</code>. This is useful if you are storing persistant stats like high scores in <a href="../modules/Noble.Settings.html">Settings</a> and want the player to be able to reset them seperately.
|
|
||||||
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<ul class="parameters">
|
|
||||||
<li><span class="parameter">__settingNames</span>
|
|
||||||
<span class="types"><span class="type">table</span></span>
|
|
||||||
<br/>
|
|
||||||
The names of the settings, in an array-style table.
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__saveToDisk</span>
|
|
||||||
<span class="types"><span class="type">boolean</span></span>
|
|
||||||
<span class="default">= <span class="value">true</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
Saves to disk immediately. Set to false if you prefer to manually save (via a confirm button, etc).
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../modules/Noble.Settings.html#Noble.Settings.resetAll">Noble.Settings.resetAll</a></li>
|
|
||||||
<li><a href="../modules/Noble.Settings.html#Noble.Settings.save">Noble.Settings.save</a></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.Settings.resetAll"></a>
|
|
||||||
<span class="item-name">Noble.Settings.resetAll([__saveToDisk=true])<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Resets all settings to thier default values defined in <code>setup()</code>.
|
|
||||||
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<ul class="parameters">
|
|
||||||
<li><span class="parameter">__saveToDisk</span>
|
|
||||||
<span class="types"><span class="type">boolean</span></span>
|
|
||||||
<span class="default">= <span class="value">true</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
Saves to disk immediately. Set to false if you prefer to manually save (via a confirm button, etc).
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../modules/Noble.Settings.html#Noble.Settings.resetSome">Noble.Settings.resetSome</a></li>
|
|
||||||
<li><a href="../modules/Noble.Settings.html#Noble.Settings.save">Noble.Settings.save</a></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.Settings.save"></a>
|
|
||||||
<span class="item-name">Noble.Settings.save()<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Saves settings to disk.
|
|
||||||
You don't need to call this unless you set <code>__saveToDisk</code> as false when setting or resetting a setting (say that five times fast!).
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../modules/Noble.Settings.html#Noble.Settings.set">Noble.Settings.set</a></li>
|
|
||||||
<li><a href="../modules/Noble.Settings.html#Noble.Settings.reset">Noble.Settings.reset</a></li>
|
|
||||||
<li><a href="../modules/Noble.Settings.html#Noble.Settings.resetAll">Noble.Settings.resetAll</a></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
|
|
||||||
|
|
||||||
</div> <!-- id="content" -->
|
|
||||||
|
|
||||||
</div> <!-- id="main" -->
|
|
||||||
|
|
||||||
<div id="about">
|
|
||||||
<span><a href="https://github.com/NobleRobot/NobleEngine">Noble Engine</a> by Mark LaCroix, <a href="https://noblerobot.com">Noble Robot</a></span>
|
|
||||||
<span style="float:right;">
|
|
||||||
Documentation created using <a href="https://github.com/stevedonovan/LDoc">LDoc 1.5.0</a>.
|
|
||||||
</span>
|
|
||||||
</div> <!-- id="about" -->
|
|
||||||
|
|
||||||
</div> <!-- id="container" -->
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
@ -1,313 +0,0 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
||||||
<html>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
|
||||||
<head>
|
|
||||||
<title>Noble Engine API reference</title>
|
|
||||||
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
|
|
||||||
<link rel="icon" href="favicon.ico">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<div id="container">
|
|
||||||
|
|
||||||
<div id="main">
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Menu -->
|
|
||||||
|
|
||||||
<div id="navigation">
|
|
||||||
<a href="../index.html"><div class="logo">
|
|
||||||
<h1>Noble Engine</h1>
|
|
||||||
</div></a>
|
|
||||||
|
|
||||||
<div class="nav-module">
|
|
||||||
<h2>Noble.Text</h2>
|
|
||||||
<ul>
|
|
||||||
<h3>Constants </h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="#Noble.Text.ALIGN_LEFT">.ALIGN_LEFT</a></li>
|
|
||||||
<li><a href="#Noble.Text.ALIGN_RIGHT">.ALIGN_RIGHT</a></li>
|
|
||||||
<li><a href="#Noble.Text.ALIGN_CENTER">.ALIGN_CENTER</a></li>
|
|
||||||
</ul>
|
|
||||||
<h3>Fonts </h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="#Noble.Text.FONT_SYSTEM">.FONT_SYSTEM</a></li>
|
|
||||||
<li><a href="#Noble.Text.FONT_SMALL">.FONT_SMALL</a></li>
|
|
||||||
<li><a href="#Noble.Text.FONT_MEDIUM">.FONT_MEDIUM</a></li>
|
|
||||||
<li><a href="#Noble.Text.FONT_LARGE">.FONT_LARGE</a></li>
|
|
||||||
</ul>
|
|
||||||
<h3>Functions </h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="#Noble.Text.getCurrentFont">.getCurrentFont</a></li>
|
|
||||||
<li><a href="#Noble.Text.setFont">.setFont</a></li>
|
|
||||||
<li><a href="#Noble.Text.draw">.draw</a></li>
|
|
||||||
</ul>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="nav-modules">
|
|
||||||
<div class="nav-kind">
|
|
||||||
<h3>Modules</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../modules/Noble.html">Noble</a></li>
|
|
||||||
<li><a href="../modules/Noble.Animation.html">Noble.Animation</a></li>
|
|
||||||
<li><a href="../modules/Noble.Bonk.html">Noble.Bonk</a></li>
|
|
||||||
<li><a href="../modules/Noble.GameData.html">Noble.GameData</a></li>
|
|
||||||
<li><a href="../modules/Noble.Input.html">Noble.Input</a></li>
|
|
||||||
<li><a href="../modules/Noble.Menu.html">Noble.Menu</a></li>
|
|
||||||
<li><a href="../modules/Noble.Settings.html">Noble.Settings</a></li>
|
|
||||||
<li><span class="selected">Noble.Text</span></li>
|
|
||||||
<li><a href="../modules/Noble.Transition.html">Noble.Transition</a></li>
|
|
||||||
<li><a href="../modules/Ease.html">Ease</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="nav-kind">
|
|
||||||
<h3>Classes</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../classes/NobleScene.html">NobleScene</a></li>
|
|
||||||
<li><a href="../classes/NobleSprite.html">NobleSprite</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="nav-kind">
|
|
||||||
<h3>Examples</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../examples/SceneTemplate.lua.html">SceneTemplate.lua</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="content">
|
|
||||||
|
|
||||||
<h1>Noble.Text</h1>
|
|
||||||
<p>Text and font handling.</p>
|
|
||||||
<p>
|
|
||||||
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<hr/>
|
|
||||||
|
|
||||||
<h2 class="section-header "><a name="Constants"></a>Constants </h2>
|
|
||||||
<!-- -->
|
|
||||||
<dl class="function">
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.Text.ALIGN_LEFT"></a>
|
|
||||||
<span class="item-name">Noble.Text.ALIGN_LEFT<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
An alternate way to call Playdate SDK's <code>kTextAlignment.left</code>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.Text.ALIGN_RIGHT"></a>
|
|
||||||
<span class="item-name">Noble.Text.ALIGN_RIGHT<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
An alternate way to call Playdate SDK's <code>kTextAlignment.right</code>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.Text.ALIGN_CENTER"></a>
|
|
||||||
<span class="item-name">Noble.Text.ALIGN_CENTER<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
An alternate way to call Playdate SDK's <code>kTextAlignment.center</code>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
<h2 class="section-header has-description"><a name="Fonts"></a>Fonts </h2>
|
|
||||||
<!-- -->
|
|
||||||
<div class="section-description">
|
|
||||||
You can use these fonts in your project, or override them with your own if you wish.
|
|
||||||
</div>
|
|
||||||
<h3>Usage</h3>
|
|
||||||
<pre class="example">Noble.Text.FONT_SMALL = Graphics.font.<span class="function-name">new</span>(<span class="string">"assets/fonts/MySmallFont"</span>)
|
|
||||||
Noble.Text.<span class="function-name">setFont</span>(Noble.Text.FONT_SMALL)</pre>
|
|
||||||
<dl class="function">
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.Text.FONT_SYSTEM"></a>
|
|
||||||
<span class="item-name">Noble.Text.FONT_SYSTEM<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
The Playdate system font.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.Text.FONT_SMALL"></a>
|
|
||||||
<span class="item-name">Noble.Text.FONT_SMALL<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
<strong>Noble Sans</strong>: A sans-serif 8×9 font, with English and Japanese-Kana character sets.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.Text.FONT_MEDIUM"></a>
|
|
||||||
<span class="item-name">Noble.Text.FONT_MEDIUM<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
<strong>Noble Slab</strong>: (This font is not ready yet!)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.Text.FONT_LARGE"></a>
|
|
||||||
<span class="item-name">Noble.Text.FONT_LARGE<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
<strong>Satchel Roughed</strong>: A sans-serif 17×14 rounded font, with an English character set.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
<h2 class="section-header "><a name="Functions"></a>Functions </h2>
|
|
||||||
<!-- -->
|
|
||||||
<dl class="function">
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.Text.getCurrentFont"></a>
|
|
||||||
<span class="item-name">Noble.Text.getCurrentFont()<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Returns</h3>
|
|
||||||
<ol>
|
|
||||||
|
|
||||||
The currently set font.
|
|
||||||
</ol>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.Text.setFont"></a>
|
|
||||||
<span class="item-name">Noble.Text.setFont(__font, __variant)<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Set the current font
|
|
||||||
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<ul class="parameters">
|
|
||||||
<li><span class="parameter">__font</span>
|
|
||||||
<br/>
|
|
||||||
any
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__variant</span>
|
|
||||||
<br/>
|
|
||||||
any
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.Text.draw"></a>
|
|
||||||
<span class="item-name">Noble.Text.draw(__string, __x, __y[, __alignment=Noble.Text.ALIGN_LEFT[, __localized=false[, __font=Noble.Text.getCurrentFont()]]])<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Abstracts multiple <code>playdate.text</code> drawing functions into one.
|
|
||||||
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<ul class="parameters">
|
|
||||||
<li><span class="parameter">__string</span>
|
|
||||||
<span class="types"><span class="type">string</span></span>
|
|
||||||
<br/>
|
|
||||||
Display text or localization key.
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__x</span>
|
|
||||||
<span class="types"><span class="type">number</span></span>
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__y</span>
|
|
||||||
<span class="types"><span class="type">number</span></span>
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__alignment</span>
|
|
||||||
<span class="default">= <span class="value">Noble.Text.ALIGN_LEFT</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
Left, right, or center!
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__localized</span>
|
|
||||||
<span class="types"><span class="type">boolean</span></span>
|
|
||||||
<span class="default">= <span class="value">false</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
If true, <code>__string</code> is a localization key rather than display text.
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__font</span>
|
|
||||||
<span class="default">= <span class="value">Noble.Text.getCurrentFont()</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
A font to use. If not set, the <code>currentFont</code> is used. If set, the <code>currentFont</code> is not updated.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
|
|
||||||
|
|
||||||
</div> <!-- id="content" -->
|
|
||||||
|
|
||||||
</div> <!-- id="main" -->
|
|
||||||
|
|
||||||
<div id="about">
|
|
||||||
<span><a href="https://github.com/NobleRobot/NobleEngine">Noble Engine</a> by Mark LaCroix, <a href="https://noblerobot.com">Noble Robot</a></span>
|
|
||||||
<span style="float:right;">
|
|
||||||
Documentation created using <a href="https://github.com/stevedonovan/LDoc">LDoc 1.5.0</a>.
|
|
||||||
</span>
|
|
||||||
</div> <!-- id="about" -->
|
|
||||||
|
|
||||||
</div> <!-- id="container" -->
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
@ -1,240 +0,0 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
||||||
<html>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
|
||||||
<head>
|
|
||||||
<title>Noble Engine API reference</title>
|
|
||||||
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
|
|
||||||
<link rel="icon" href="favicon.ico">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<div id="container">
|
|
||||||
|
|
||||||
<div id="main">
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Menu -->
|
|
||||||
|
|
||||||
<div id="navigation">
|
|
||||||
<a href="../index.html"><div class="logo">
|
|
||||||
<h1>Noble Engine</h1>
|
|
||||||
</div></a>
|
|
||||||
|
|
||||||
<div class="nav-module">
|
|
||||||
<h2>Noble.TransitionType</h2>
|
|
||||||
<ul>
|
|
||||||
<h3>Constants </h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="#Noble.TransitionType.CUT">.CUT</a></li>
|
|
||||||
<li><a href="#Noble.TransitionType.CROSS_DISSOLVE">.CROSS_DISSOLVE</a></li>
|
|
||||||
<li><a href="#Noble.TransitionType.DIP_TO_BLACK">.DIP_TO_BLACK</a></li>
|
|
||||||
<li><a href="#Noble.TransitionType.DIP_TO_WHITE">.DIP_TO_WHITE</a></li>
|
|
||||||
<li><a href="#Noble.TransitionType.DIP_WIDGET_SATCHEL">.DIP_WIDGET_SATCHEL</a></li>
|
|
||||||
<li><a href="#Noble.TransitionType.DIP_METRO_NEXUS">.DIP_METRO_NEXUS</a></li>
|
|
||||||
<li><a href="#Noble.TransitionType.SLIDE_OFF_LEFT">.SLIDE_OFF_LEFT</a></li>
|
|
||||||
<li><a href="#Noble.TransitionType.SLIDE_OFF_RIGHT">.SLIDE_OFF_RIGHT</a></li>
|
|
||||||
<li><a href="#Noble.TransitionType.SLIDE_OFF_UP">.SLIDE_OFF_UP</a></li>
|
|
||||||
<li><a href="#Noble.TransitionType.SLIDE_OFF_DOWN">.SLIDE_OFF_DOWN</a></li>
|
|
||||||
</ul>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="nav-modules">
|
|
||||||
<div class="nav-kind">
|
|
||||||
<h3>Modules</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../modules/Noble.html">Noble</a></li>
|
|
||||||
<li><a href="../modules/Noble.Animation.html">Noble.Animation</a></li>
|
|
||||||
<li><a href="../modules/Noble.Bonk.html">Noble.Bonk</a></li>
|
|
||||||
<li><a href="../modules/Noble.GameData.html">Noble.GameData</a></li>
|
|
||||||
<li><a href="../modules/Noble.Input.html">Noble.Input</a></li>
|
|
||||||
<li><a href="../modules/Noble.Menu.html">Noble.Menu</a></li>
|
|
||||||
<li><a href="../modules/Noble.Settings.html">Noble.Settings</a></li>
|
|
||||||
<li><a href="../modules/Noble.Text.html">Noble.Text</a></li>
|
|
||||||
<li><span class="selected">Noble.TransitionType</span></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="nav-kind">
|
|
||||||
<h3>Classes</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../classes/NobleScene.html">NobleScene</a></li>
|
|
||||||
<li><a href="../classes/NobleSprite.html">NobleSprite</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="nav-kind">
|
|
||||||
<h3>Examples</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../examples/SceneTemplate.lua.html">SceneTemplate.lua</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="content">
|
|
||||||
|
|
||||||
<h1>Noble.TransitionType</h1>
|
|
||||||
<p>A set of constants for scene transition animations.</p>
|
|
||||||
<p>
|
|
||||||
|
|
||||||
</p>
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<a href="../modules/Noble.html#transition">Noble.transition</a>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<hr/>
|
|
||||||
|
|
||||||
<h2 class="section-header "><a name="Constants"></a>Constants </h2>
|
|
||||||
<!-- -->
|
|
||||||
<dl class="function">
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.TransitionType.CUT"></a>
|
|
||||||
<span class="item-name">Noble.TransitionType.CUT<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
An all-time classic.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.TransitionType.CROSS_DISSOLVE"></a>
|
|
||||||
<span class="item-name">Noble.TransitionType.CROSS_DISSOLVE<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
A simple cross-fade.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.TransitionType.DIP_TO_BLACK"></a>
|
|
||||||
<span class="item-name">Noble.TransitionType.DIP_TO_BLACK<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Fade to black, then to the next scene.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.TransitionType.DIP_TO_WHITE"></a>
|
|
||||||
<span class="item-name">Noble.TransitionType.DIP_TO_WHITE<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Fade to white, then to the next scene.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.TransitionType.DIP_WIDGET_SATCHEL"></a>
|
|
||||||
<span class="item-name">Noble.TransitionType.DIP_WIDGET_SATCHEL<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
An "accordion" transition, from "Widget Satchel" by Noble Robot.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.TransitionType.DIP_METRO_NEXUS"></a>
|
|
||||||
<span class="item-name">Noble.TransitionType.DIP_METRO_NEXUS<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
A "cascade" transition, from "Metro Nexus" by Noble Robot.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.TransitionType.SLIDE_OFF_LEFT"></a>
|
|
||||||
<span class="item-name">Noble.TransitionType.SLIDE_OFF_LEFT<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
The existing scene slides off the left side of the screen, revealing the next scene.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.TransitionType.SLIDE_OFF_RIGHT"></a>
|
|
||||||
<span class="item-name">Noble.TransitionType.SLIDE_OFF_RIGHT<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
The existing scene slides off the right side of the screen, revealing the next scene.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.TransitionType.SLIDE_OFF_UP"></a>
|
|
||||||
<span class="item-name">Noble.TransitionType.SLIDE_OFF_UP<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
The existing scene slides off the top of the screen.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "Noble.TransitionType.SLIDE_OFF_DOWN"></a>
|
|
||||||
<span class="item-name">Noble.TransitionType.SLIDE_OFF_DOWN<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
The existing scene slides off the bottom of the screen, revealing the next scene.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
|
|
||||||
|
|
||||||
</div> <!-- id="content" -->
|
|
||||||
|
|
||||||
</div> <!-- id="main" -->
|
|
||||||
|
|
||||||
<div id="about">
|
|
||||||
<span><a href="https://github.com/NobleRobot/NobleEngine">Noble Engine</a> by Mark LaCroix, <a href="https://noblerobot.com">Noble Robot</a></span>
|
|
||||||
<span style="float:right;">
|
|
||||||
Documentation created using <a href="https://github.com/stevedonovan/LDoc">LDoc 1.5.0</a>.
|
|
||||||
</span>
|
|
||||||
</div> <!-- id="about" -->
|
|
||||||
|
|
||||||
</div> <!-- id="container" -->
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
@ -1,476 +0,0 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
||||||
<html>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
|
||||||
<head>
|
|
||||||
<title>Noble Engine API reference</title>
|
|
||||||
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
|
|
||||||
<link rel="icon" href="favicon.ico">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<div id="container">
|
|
||||||
|
|
||||||
<div id="main">
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Menu -->
|
|
||||||
|
|
||||||
<div id="navigation">
|
|
||||||
<a href="../index.html"><div class="logo">
|
|
||||||
<h1>Noble Engine</h1>
|
|
||||||
</div></a>
|
|
||||||
|
|
||||||
<div class="nav-module">
|
|
||||||
<h2>Noble</h2>
|
|
||||||
<ul>
|
|
||||||
<h3>Functions</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="#new">.new</a></li>
|
|
||||||
<li><a href="#engineInitialized">.engineInitialized</a></li>
|
|
||||||
<li><a href="#getConfig">.getConfig</a></li>
|
|
||||||
<li><a href="#setConfig">.setConfig</a></li>
|
|
||||||
<li><a href="#resetConfig">.resetConfig</a></li>
|
|
||||||
<li><a href="#transition">.transition</a></li>
|
|
||||||
<li><a href="#currentScene">.currentScene</a></li>
|
|
||||||
<li><a href="#currentSceneName">.currentSceneName</a></li>
|
|
||||||
<li><a href="#isTransitioning">.isTransitioning</a></li>
|
|
||||||
</ul>
|
|
||||||
<h3>Tables</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="#configuration">.configuration</a></li>
|
|
||||||
</ul>
|
|
||||||
<h3>Fields</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="#showFPS">.showFPS</a></li>
|
|
||||||
</ul>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="nav-modules">
|
|
||||||
<div class="nav-kind">
|
|
||||||
<h3>Modules</h3>
|
|
||||||
<ul>
|
|
||||||
<li><span class="selected">Noble</span></li>
|
|
||||||
<li><a href="../modules/Noble.Animation.html">Noble.Animation</a></li>
|
|
||||||
<li><a href="../modules/Noble.Bonk.html">Noble.Bonk</a></li>
|
|
||||||
<li><a href="../modules/Noble.GameData.html">Noble.GameData</a></li>
|
|
||||||
<li><a href="../modules/Noble.Input.html">Noble.Input</a></li>
|
|
||||||
<li><a href="../modules/Noble.Menu.html">Noble.Menu</a></li>
|
|
||||||
<li><a href="../modules/Noble.Settings.html">Noble.Settings</a></li>
|
|
||||||
<li><a href="../modules/Noble.Text.html">Noble.Text</a></li>
|
|
||||||
<li><a href="../modules/Noble.Transition.html">Noble.Transition</a></li>
|
|
||||||
<li><a href="../modules/Ease.html">Ease</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="nav-kind">
|
|
||||||
<h3>Classes</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../classes/NobleScene.html">NobleScene</a></li>
|
|
||||||
<li><a href="../classes/NobleSprite.html">NobleSprite</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="nav-kind">
|
|
||||||
<h3>Examples</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../examples/SceneTemplate.lua.html">SceneTemplate.lua</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="content">
|
|
||||||
|
|
||||||
<h1>Noble</h1>
|
|
||||||
<p>A li'l game engine for Playdate.</p>
|
|
||||||
<p>
|
|
||||||
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<hr/>
|
|
||||||
|
|
||||||
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
|
|
||||||
<!-- -->
|
|
||||||
<dl class="function">
|
|
||||||
<dt>
|
|
||||||
<a name = "new"></a>
|
|
||||||
<span class="item-name">new(StartingScene[, __launcherTransitionDuration=0[, __launcherTransition=Noble.Transition.DipToBlack[, __launcherTransitionProperties={}[, __configuration={}]]]])<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Engine initialization. Run this once in your main.lua file to begin your game.
|
|
||||||
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<ul class="parameters">
|
|
||||||
<li><span class="parameter">StartingScene</span>
|
|
||||||
<span class="types"><a class="type" href="../classes/NobleScene.html#">NobleScene</a></span>
|
|
||||||
<br/>
|
|
||||||
This is the scene your game begins with, such as a title screen, loading screen, splash screen, etc. <strong>NOTE: Pass the scene's class name, not an instance of the scene.</strong>
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__launcherTransitionDuration</span>
|
|
||||||
<span class="types"><span class="type">number</span></span>
|
|
||||||
<span class="default">= <span class="value">0</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
If you want to transition from the final frame of your launch image sequence, enter a duration in seconds here.
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__launcherTransition</span>
|
|
||||||
<span class="types"><span class="type">Noble.Transition</span></span>
|
|
||||||
<span class="default">= <span class="value">Noble.Transition.DipToBlack</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
If a transition duration is set, use this transition type.
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__launcherTransitionProperties</span>
|
|
||||||
<span class="types"><span class="type">table</span></span>
|
|
||||||
<span class="default">= <span class="value">{}</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
Provide a table of properties to apply to the launcher transition. See the documentation for the transition you're using for a list of available properties.
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__configuration</span>
|
|
||||||
<span class="types"><span class="type">table</span></span>
|
|
||||||
<span class="default">= <span class="value">{}</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
Provide a table of Noble Engine configuration values. This will run <a href="../modules/Noble.html#setConfig">Noble.setConfig</a> for you at launch.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../classes/NobleScene.html#">NobleScene</a></li>
|
|
||||||
<li><a href="../modules/Noble.Transition.html#">Noble.Transition</a></li>
|
|
||||||
<li><a href="../modules/Noble.html#setConfig">setConfig</a></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3>Usage</h3>
|
|
||||||
<pre class="example">Noble.<span class="function-name">new</span>(
|
|
||||||
TitleScreen,
|
|
||||||
<span class="number">2</span>,
|
|
||||||
Noble.Transition.DipToWhite,
|
|
||||||
{
|
|
||||||
holdTime = <span class="number">0</span>,
|
|
||||||
ease = Ease.outInQuad
|
|
||||||
},
|
|
||||||
{
|
|
||||||
defaultTransition = Noble.Transition.Imagetable,
|
|
||||||
defaultTransitionDuration = <span class="number">1.75</span>,
|
|
||||||
enableDebugBonkChecking = <span class="keyword">true</span>,
|
|
||||||
}
|
|
||||||
)</pre>
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "engineInitialized"></a>
|
|
||||||
<span class="item-name">engineInitialized()<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
This checks to see if <a href="../modules/Noble.html#new">Noble.new</a> has been run. It is used internally to ward off bonks.
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Returns</h3>
|
|
||||||
<ol>
|
|
||||||
|
|
||||||
<span class="types"><span class="type">bool</span></span>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</ol>
|
|
||||||
|
|
||||||
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<a href="../modules/Noble.Bonk.html#">Noble.Bonk</a>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "getConfig"></a>
|
|
||||||
<span class="item-name">getConfig()<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Retrieve miscellaneous Noble Engine configuration options / default values
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Returns</h3>
|
|
||||||
<ol>
|
|
||||||
|
|
||||||
A table of all configuration values
|
|
||||||
</ol>
|
|
||||||
|
|
||||||
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../modules/Noble.html#configuration">configuration</a></li>
|
|
||||||
<li><a href="../modules/Noble.html#setConfig">setConfig</a></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "setConfig"></a>
|
|
||||||
<span class="item-name">setConfig(__configuration)<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Optionally customize miscellaneous Noble Engine configuration options / default values. You may run this method to change these values during runtime.
|
|
||||||
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<ul class="parameters">
|
|
||||||
<li><span class="parameter">__configuration</span>
|
|
||||||
<span class="types"><span class="type">table</span></span>
|
|
||||||
<br/>
|
|
||||||
This is a table with your configuration values in it.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../modules/Noble.html#configuration">configuration</a></li>
|
|
||||||
<li><a href="../modules/Noble.html#getConfig">getConfig</a></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "resetConfig"></a>
|
|
||||||
<span class="item-name">resetConfig()<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Reset miscellaneous Noble Engine configuration values to their defaults.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../modules/Noble.html#getConfig">getConfig</a></li>
|
|
||||||
<li><a href="../modules/Noble.html#setConfig">setConfig</a></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "transition"></a>
|
|
||||||
<span class="item-name">transition(NewScene[, __duration=1.5[, __transition=Noble.TransitionType.DIP_TO_BLACK[, __transitionProperties={}]]])<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Transition to a new scene (at the end of this frame).
|
|
||||||
This method will create a new scene, mark the previous one for garbage collection, and animate between them.
|
|
||||||
Additional calls to this method within the same frame (before the already-called transition begins), will override previous calls. Any calls to this method once a transition begins will be ignored until the transition completes.
|
|
||||||
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<ul class="parameters">
|
|
||||||
<li><span class="parameter">NewScene</span>
|
|
||||||
<span class="types"><a class="type" href="../classes/NobleScene.html#">NobleScene</a></span>
|
|
||||||
<br/>
|
|
||||||
The scene to transition to. Pass the scene's class, not an instance of the scene. You always transition from <a href="../modules/Noble.html#currentScene">Noble.currentScene</a>
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__duration</span>
|
|
||||||
<span class="types"><span class="type">number</span></span>
|
|
||||||
<span class="default">= <span class="value">1.5</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
The length of the transition, in seconds.
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__transition</span>
|
|
||||||
<span class="types"><span class="type">Noble.Transition</span></span>
|
|
||||||
<span class="default">= <span class="value">Noble.TransitionType.DIP_TO_BLACK</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
If a transition duration is set, use this transition type. If not set, it will use the value of <code>configuration.defaultTransition</code>.
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">__transitionProperties</span>
|
|
||||||
<span class="types"><span class="type">table</span></span>
|
|
||||||
<span class="default">= <span class="value">{}</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
A table consisting of properties for this transition. Properties not set here will use values that transition's <code>defaultProperties</code> table.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../modules/Noble.html#isTransitioning">Noble.isTransitioning</a></li>
|
|
||||||
<li><a href="../classes/NobleScene.html#">NobleScene</a></li>
|
|
||||||
<li><a href="../modules/Noble.Transition.html#">Noble.Transition</a></li>
|
|
||||||
<li><a href="../modules/Noble.Transition.html#Noble.Transition.SpotlightMask.defaultProperties">Noble.Transition.defaultProperties</a></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3>Usage</h3>
|
|
||||||
<pre class="example">Noble.<span class="function-name">transition</span>(Level2, <span class="number">1</span>, Noble.Transition.CrossDissolve, {
|
|
||||||
dither = Graphics.image.kDitherTypeDiagonalLine
|
|
||||||
ease = Ease.outQuint
|
|
||||||
})
|
|
||||||
<span class="comment">--
|
|
||||||
</span>Noble.<span class="function-name">transition</span>(Level2, <span class="number">1</span>, Noble.Transition.DipToBlack, {
|
|
||||||
holdTime = <span class="number">0.5</span>,
|
|
||||||
ease = Ease.outInElastic
|
|
||||||
})
|
|
||||||
<span class="comment">--
|
|
||||||
</span>Noble.<span class="function-name">transition</span>(Level2, <span class="number">1</span>, Noble.Transition.SlideOff, {
|
|
||||||
x = <span class="number">400</span>,
|
|
||||||
y = <span class="number">150</span>
|
|
||||||
rotation = <span class="number">45</span>
|
|
||||||
})</pre>
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "currentScene"></a>
|
|
||||||
<span class="item-name">currentScene()<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Get the current scene object
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Returns</h3>
|
|
||||||
<ol>
|
|
||||||
|
|
||||||
<span class="types"><a class="type" href="../classes/NobleScene.html#">NobleScene</a></span>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</ol>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "currentSceneName"></a>
|
|
||||||
<span class="item-name">currentSceneName()<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Get the name of the current scene
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Returns</h3>
|
|
||||||
<ol>
|
|
||||||
|
|
||||||
<span class="types"><span class="type">string</span></span>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</ol>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "isTransitioning"></a>
|
|
||||||
<span class="item-name">isTransitioning()<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Check to see if the game is transitioning between scenes.
|
|
||||||
Useful to control game logic that lives outside of a scene's <code>update()</code> method.
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Returns</h3>
|
|
||||||
<ol>
|
|
||||||
|
|
||||||
<span class="types"><span class="type">bool</span></span>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</ol>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
<h2 class="section-header "><a name="Tables"></a>Tables</h2>
|
|
||||||
<!-- -->
|
|
||||||
<dl class="function">
|
|
||||||
<dt>
|
|
||||||
<a name = "configuration"></a>
|
|
||||||
<span class="item-name">configuration<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Miscellaneous Noble Engine configuration options / default values.
|
|
||||||
This table cannot be edited directly. Use <a href="../modules/Noble.html#getConfig">Noble.getConfig</a> and <a href="../modules/Noble.html#setConfig">Noble.setConfig</a>.
|
|
||||||
|
|
||||||
<h3>Fields</h3>
|
|
||||||
<ul class="parameters">
|
|
||||||
<li><span class="parameter">defaultTransition</span>
|
|
||||||
<span class="types"><span class="type">Noble.Transition</span></span>
|
|
||||||
<span class="default">= <span class="value">Noble.Transition.DipToBlack</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
When running <a href="../modules/Noble.html#transition">Noble.transition</a> if the transition is unspecified, it will use this one.
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">defaultTransitionDuration</span>
|
|
||||||
<span class="types"><span class="type">number</span></span>
|
|
||||||
<span class="default">= <span class="value">1.5</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
When running <a href="../modules/Noble.html#transition">Noble.transition</a> if the scene transition duration is unspecified, it will take this long in seconds.
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">enableDebugBonkChecking</span>
|
|
||||||
<span class="types"><span class="type">boolean</span></span>
|
|
||||||
<span class="default">= <span class="value">false</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
Noble Engine-specific errors are called "Bonks." You can set this to true during development in order to check for more of them. However, it uses resources, so you will probably want to turn it off before release.
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">alwaysRedraw</span>
|
|
||||||
<span class="types"><span class="type">boolean</span></span>
|
|
||||||
<span class="default">= <span class="value">true</span> (default)</span>
|
|
||||||
<br/>
|
|
||||||
This sets the Playdate SDK method <code>playdate.graphics.sprite.setAlwaysRedraw</code>. See the Playdate SDK for details on how this function works, and the reasons you might want to set it as true or false for your project.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../modules/Noble.html#getConfig">Noble.getConfig</a></li>
|
|
||||||
<li><a href="../modules/Noble.html#setConfig">Noble.setConfig</a></li>
|
|
||||||
<li><a href="../modules/Noble.Bonk.html#Noble.Bonk.startCheckingDebugBonks">Noble.Bonk.startCheckingDebugBonks</a></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
<h2 class="section-header "><a name="Fields"></a>Fields</h2>
|
|
||||||
<!-- -->
|
|
||||||
<dl class="function">
|
|
||||||
<dt>
|
|
||||||
<a name = "showFPS"></a>
|
|
||||||
<span class="item-name">showFPS<span>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Show/hide the Playdate SDK's FPS counter.
|
|
||||||
|
|
||||||
<ul class="parameters">
|
|
||||||
<li><span class="parameter">bool</span>
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
|
|
||||||
|
|
||||||
</div> <!-- id="content" -->
|
|
||||||
|
|
||||||
</div> <!-- id="main" -->
|
|
||||||
|
|
||||||
<div id="about">
|
|
||||||
<span><a href="https://github.com/NobleRobot/NobleEngine">Noble Engine</a> by Mark LaCroix, <a href="https://noblerobot.com">Noble Robot</a></span>
|
|
||||||
<span style="float:right;">
|
|
||||||
Documentation created using <a href="https://github.com/stevedonovan/LDoc">LDoc 1.5.0</a>.
|
|
||||||
</span>
|
|
||||||
</div> <!-- id="about" -->
|
|
||||||
|
|
||||||
</div> <!-- id="container" -->
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
Before Width: | Height: | Size: 288 KiB |
@ -1,92 +0,0 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
||||||
<html>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
|
||||||
<head>
|
|
||||||
<title>Noble Engine API reference</title>
|
|
||||||
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
|
|
||||||
<link rel="icon" href="favicon.ico">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<div id="container">
|
|
||||||
|
|
||||||
<div id="main">
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Menu -->
|
|
||||||
|
|
||||||
<div id="navigation">
|
|
||||||
<a href="../index.html"><div class="logo">
|
|
||||||
<h1>Noble Engine</h1>
|
|
||||||
</div></a>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div class="nav-modules">
|
|
||||||
<div class="nav-kind">
|
|
||||||
<h3>Modules</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../modules/Noble.html">Noble</a></li>
|
|
||||||
<li><a href="../modules/Noble.Animation.html">Noble.Animation</a></li>
|
|
||||||
<li><a href="../modules/Noble.Bonk.html">Noble.Bonk</a></li>
|
|
||||||
<li><a href="../modules/Noble.GameData.html">Noble.GameData</a></li>
|
|
||||||
<li><a href="../modules/Noble.Input.html">Noble.Input</a></li>
|
|
||||||
<li><a href="../modules/Noble.Menu.html">Noble.Menu</a></li>
|
|
||||||
<li><a href="../modules/Noble.Settings.html">Noble.Settings</a></li>
|
|
||||||
<li><a href="../modules/Noble.Text.html">Noble.Text</a></li>
|
|
||||||
<li><a href="../modules/Noble.Transition.html">Noble.Transition</a></li>
|
|
||||||
<li><span class="selected">modules.Noble.Transition.Imagetable</span></li>
|
|
||||||
<li><a href="../modules/modules.Noble.Transition.ImagetableMask.html">modules.Noble.Transition.ImagetableMask</a></li>
|
|
||||||
<li><a href="../modules/Ease.html">Ease</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="nav-kind">
|
|
||||||
<h3>Classes</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../classes/NobleScene.html">NobleScene</a></li>
|
|
||||||
<li><a href="../classes/NobleSprite.html">NobleSprite</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="nav-kind">
|
|
||||||
<h3>Examples</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../examples/SceneTemplate.lua.html">SceneTemplate.lua</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="content">
|
|
||||||
|
|
||||||
<h1>modules.Noble.Transition.Imagetable</h1>
|
|
||||||
<p>Transition properties.</p>
|
|
||||||
<p>
|
|
||||||
|
|
||||||
</p>
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../modules/Noble.html#transition">Noble.transition</a></li>
|
|
||||||
<li><a href="../modules/Noble.Transition.html#Noble.Transition.setDefaultProperties">Noble.Transition.setDefaultProperties</a></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<hr/>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div> <!-- id="content" -->
|
|
||||||
|
|
||||||
</div> <!-- id="main" -->
|
|
||||||
|
|
||||||
<div id="about">
|
|
||||||
<span><a href="https://github.com/NobleRobot/NobleEngine">Noble Engine</a> by Mark LaCroix, <a href="https://noblerobot.com">Noble Robot</a></span>
|
|
||||||
<span style="float:right;">
|
|
||||||
Documentation created using <a href="https://github.com/stevedonovan/LDoc">LDoc 1.5.0</a>.
|
|
||||||
</span>
|
|
||||||
</div> <!-- id="about" -->
|
|
||||||
|
|
||||||
</div> <!-- id="container" -->
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
@ -1,92 +0,0 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
||||||
<html>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
|
||||||
<head>
|
|
||||||
<title>Noble Engine API reference</title>
|
|
||||||
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
|
|
||||||
<link rel="icon" href="favicon.ico">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<div id="container">
|
|
||||||
|
|
||||||
<div id="main">
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Menu -->
|
|
||||||
|
|
||||||
<div id="navigation">
|
|
||||||
<a href="../index.html"><div class="logo">
|
|
||||||
<h1>Noble Engine</h1>
|
|
||||||
</div></a>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div class="nav-modules">
|
|
||||||
<div class="nav-kind">
|
|
||||||
<h3>Modules</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../modules/Noble.html">Noble</a></li>
|
|
||||||
<li><a href="../modules/Noble.Animation.html">Noble.Animation</a></li>
|
|
||||||
<li><a href="../modules/Noble.Bonk.html">Noble.Bonk</a></li>
|
|
||||||
<li><a href="../modules/Noble.GameData.html">Noble.GameData</a></li>
|
|
||||||
<li><a href="../modules/Noble.Input.html">Noble.Input</a></li>
|
|
||||||
<li><a href="../modules/Noble.Menu.html">Noble.Menu</a></li>
|
|
||||||
<li><a href="../modules/Noble.Settings.html">Noble.Settings</a></li>
|
|
||||||
<li><a href="../modules/Noble.Text.html">Noble.Text</a></li>
|
|
||||||
<li><a href="../modules/Noble.Transition.html">Noble.Transition</a></li>
|
|
||||||
<li><a href="../modules/modules.Noble.Transition.Imagetable.html">modules.Noble.Transition.Imagetable</a></li>
|
|
||||||
<li><span class="selected">modules.Noble.Transition.ImagetableMask</span></li>
|
|
||||||
<li><a href="../modules/Ease.html">Ease</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="nav-kind">
|
|
||||||
<h3>Classes</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../classes/NobleScene.html">NobleScene</a></li>
|
|
||||||
<li><a href="../classes/NobleSprite.html">NobleSprite</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="nav-kind">
|
|
||||||
<h3>Examples</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../examples/SceneTemplate.lua.html">SceneTemplate.lua</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="content">
|
|
||||||
|
|
||||||
<h1>modules.Noble.Transition.ImagetableMask</h1>
|
|
||||||
<p>Transition properties.</p>
|
|
||||||
<p>
|
|
||||||
|
|
||||||
</p>
|
|
||||||
<h3>See</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../modules/Noble.html#transition">Noble.transition</a></li>
|
|
||||||
<li><a href="../modules/Noble.Transition.html#Noble.Transition.setDefaultProperties">Noble.Transition.setDefaultProperties</a></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<hr/>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div> <!-- id="content" -->
|
|
||||||
|
|
||||||
</div> <!-- id="main" -->
|
|
||||||
|
|
||||||
<div id="about">
|
|
||||||
<span><a href="https://github.com/NobleRobot/NobleEngine">Noble Engine</a> by Mark LaCroix, <a href="https://noblerobot.com">Noble Robot</a></span>
|
|
||||||
<span style="float:right;">
|
|
||||||
Documentation created using <a href="https://github.com/stevedonovan/LDoc">LDoc 1.5.0</a>.
|
|
||||||
</span>
|
|
||||||
</div> <!-- id="about" -->
|
|
||||||
|
|
||||||
</div> <!-- id="container" -->
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
1
source/libraries/noble/.gitattributes
vendored
@ -1 +0,0 @@
|
|||||||
.docs/** linguist-documentation
|
|
13
source/libraries/noble/.github/FUNDING.yml
vendored
@ -1,13 +0,0 @@
|
|||||||
# These are supported funding model platforms
|
|
||||||
|
|
||||||
github: NobleRobot
|
|
||||||
#patreon: # Replace with a single Patreon username
|
|
||||||
#open_collective: # Replace with a single Open Collective username
|
|
||||||
ko_fi: NobleRobot
|
|
||||||
#tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
|
||||||
#community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
|
||||||
#liberapay: # Replace with a single Liberapay username
|
|
||||||
#issuehunt: # Replace with a single IssueHunt username
|
|
||||||
#otechie: # Replace with a single Otechie username
|
|
||||||
#lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
|
|
||||||
#custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
|
@ -1,23 +0,0 @@
|
|||||||
---
|
|
||||||
name: Bug report
|
|
||||||
about: Help track problems in the project
|
|
||||||
title: ''
|
|
||||||
labels: bug
|
|
||||||
assignees: ''
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**Describe the bug**
|
|
||||||
(A clear and concise description of what the bug is.)
|
|
||||||
|
|
||||||
**To reproduce**
|
|
||||||
(Steps to reproduce the behavior:)
|
|
||||||
|
|
||||||
**Expected behavior**
|
|
||||||
(A clear and concise description of what you expected to happen.)
|
|
||||||
|
|
||||||
**Screenshots/Code snippets**
|
|
||||||
(If applicable, add screenshots or code snippets to help explain your problem.)
|
|
||||||
|
|
||||||
**Additional context**
|
|
||||||
(Add any other context about the problem here.)
|
|
@ -1,23 +0,0 @@
|
|||||||
---
|
|
||||||
name: Feature request
|
|
||||||
about: Suggest an idea for this project
|
|
||||||
title: ''
|
|
||||||
labels: enhancement
|
|
||||||
assignees: ''
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**Describe the feature**
|
|
||||||
(A clear and concise description of your proposal.)
|
|
||||||
|
|
||||||
|
|
||||||
**Describe alternatives you've considered**
|
|
||||||
(A clear and concise description of any alternative solutions or features you've considered.)
|
|
||||||
|
|
||||||
|
|
||||||
**What problems would this solve or help prevent, if any**
|
|
||||||
(OPTIONAL: If this feature is related to a bug or other problem, describe it here.)
|
|
||||||
|
|
||||||
|
|
||||||
**Additional context**
|
|
||||||
(Add any other context or screenshots about the feature request here.)
|
|
@ -1,60 +0,0 @@
|
|||||||
name: Update documentation
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- 'main'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
generate-docs:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
|
|
||||||
- name: Check out main branch
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: Install Lua
|
|
||||||
uses: leafo/gh-actions-lua@v10.0.0
|
|
||||||
with:
|
|
||||||
luaVersion: "5.4"
|
|
||||||
|
|
||||||
- name: Install Luarocks package manager
|
|
||||||
uses: leafo/gh-actions-luarocks@v4.3.0
|
|
||||||
|
|
||||||
- name: Install LDoc (with dependencies)
|
|
||||||
run: |
|
|
||||||
luarocks install ldoc
|
|
||||||
|
|
||||||
- name: Generate HTML documentation using LDoc
|
|
||||||
run: |
|
|
||||||
ldoc -c .docs/.ldoc/config.ldoc .
|
|
||||||
|
|
||||||
- name: Commit any changes made inside the .docs folder
|
|
||||||
uses: EndBug/add-and-commit@v9.1.1
|
|
||||||
with:
|
|
||||||
add: '.docs'
|
|
||||||
remove: '.lua'
|
|
||||||
default_author: github_actions
|
|
||||||
author_name: Noble Robot
|
|
||||||
author_email: contact@noblerobot.com
|
|
||||||
message: '(Documentation updates)'
|
|
||||||
push: true
|
|
||||||
|
|
||||||
- name: Remove .lua
|
|
||||||
uses: JesseTG/rm@v1.0.3
|
|
||||||
with:
|
|
||||||
path: .lua
|
|
||||||
|
|
||||||
- name: Remove .luarocks
|
|
||||||
uses: JesseTG/rm@v1.0.3
|
|
||||||
with:
|
|
||||||
path: .luarocks
|
|
||||||
|
|
||||||
- uses: numtide/clean-git-action@v1
|
|
||||||
|
|
||||||
- name: GitHub Pages Overwriter
|
|
||||||
uses: rayluo/github-pages-overwriter@v1.3
|
|
||||||
|
|
||||||
with:
|
|
||||||
source-directory: .docs
|
|
||||||
target-branch: gh_pages
|
|
46
source/libraries/noble/.gitignore
vendored
@ -1,46 +0,0 @@
|
|||||||
# Compiled Lua sources
|
|
||||||
luac.out
|
|
||||||
|
|
||||||
# luarocks build files
|
|
||||||
*.src.rock
|
|
||||||
*.zip
|
|
||||||
*.tar.gz
|
|
||||||
|
|
||||||
# Object files
|
|
||||||
*.o
|
|
||||||
*.os
|
|
||||||
*.ko
|
|
||||||
*.obj
|
|
||||||
*.elf
|
|
||||||
|
|
||||||
# Precompiled Headers
|
|
||||||
*.gch
|
|
||||||
*.pch
|
|
||||||
|
|
||||||
# Libraries
|
|
||||||
*.lib
|
|
||||||
*.a
|
|
||||||
*.la
|
|
||||||
*.lo
|
|
||||||
*.def
|
|
||||||
*.exp
|
|
||||||
|
|
||||||
# Shared objects (inc. Windows DLLs)
|
|
||||||
*.dll
|
|
||||||
*.so
|
|
||||||
*.so.*
|
|
||||||
*.dylib
|
|
||||||
|
|
||||||
# Executables
|
|
||||||
*.exe
|
|
||||||
*.out
|
|
||||||
*.app
|
|
||||||
*.i*86
|
|
||||||
*.x86_64
|
|
||||||
*.hex
|
|
||||||
|
|
||||||
.vscode
|
|
||||||
|
|
||||||
# LDoc config files
|
|
||||||
config.ld
|
|
||||||
.docs_templates/
|
|
@ -1,43 +0,0 @@
|
|||||||
# Contributor Code of Conduct
|
|
||||||
|
|
||||||
## Pledge
|
|
||||||
|
|
||||||
This project pledges to make participation a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
|
||||||
|
|
||||||
The project's leaders pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
|
||||||
|
|
||||||
## Standards
|
|
||||||
|
|
||||||
Examples of behavior that contributes to a positive environment include:
|
|
||||||
|
|
||||||
* Demonstrating empathy and kindness toward other people.
|
|
||||||
* Being respectful of differing opinions, viewpoints, and experiences.
|
|
||||||
* Giving and gracefully accepting constructive feedback.
|
|
||||||
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience.
|
|
||||||
* Valuing the contributions of others, in effort but also time.
|
|
||||||
* Focusing on what is best not just for us as individuals, but for others as well.
|
|
||||||
|
|
||||||
Examples of unacceptable behavior include:
|
|
||||||
|
|
||||||
* The use of sexualized language or imagery, and sexual attention or advances of any kind.
|
|
||||||
* Trolling, insulting, or derogatory comments.
|
|
||||||
* Personal or political attacks.
|
|
||||||
* Public or private harassment.
|
|
||||||
* Publishing others' private information, such as a physical or email address, without their explicit permission.
|
|
||||||
* Other conduct which could reasonably be considered inappropriate in a professional setting.
|
|
||||||
|
|
||||||
## Enforcement
|
|
||||||
|
|
||||||
Project leaders are responsible for clarifying and enforcing standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
|
||||||
|
|
||||||
Project leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
|
||||||
|
|
||||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at contact@noblerobot.com. All complaints will be reviewed and investigated promptly and fairly.
|
|
||||||
|
|
||||||
All project leaders are obligated to respect the privacy and security of the reporter of any incident.
|
|
||||||
|
|
||||||
## Attribution
|
|
||||||
|
|
||||||
This Code of Conduct is adapted and simplified from Contributor Covenant version 2.0, which is available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
|
||||||
|
|
||||||
For answers to common questions about the originating document, see the FAQ at https://www.contributor-covenant.org/faq.
|
|
@ -1,51 +0,0 @@
|
|||||||
Licenses
|
|
||||||
|
|
||||||
--
|
|
||||||
|
|
||||||
"assets/images/NobleRobotLogo.png"
|
|
||||||
|
|
||||||
© 2021 Mark LaCroix, Noble Robot
|
|
||||||
|
|
||||||
You are granted a non-exclusive license to this version of the Noble Robot
|
|
||||||
logo, solely for the purposes of providing credit, if you choose, in a
|
|
||||||
resulting product which uses this software. You may not sell or create
|
|
||||||
commercial derivative works from this asset, or use it in any other context.
|
|
||||||
|
|
||||||
Where appropriate, and at your discretion, include the logo unmodified against
|
|
||||||
a black background, or inverted against a white background, with a version of
|
|
||||||
the following message:
|
|
||||||
|
|
||||||
"Created with Noble Engine, by Noble Robot. https://noblerobot.com"
|
|
||||||
|
|
||||||
--
|
|
||||||
|
|
||||||
"libraries/"
|
|
||||||
|
|
||||||
Sequence library by Nic Magnier
|
|
||||||
Signal library by Dustin Mierau
|
|
||||||
|
|
||||||
--
|
|
||||||
|
|
||||||
All other assets
|
|
||||||
|
|
||||||
MIT License
|
|
||||||
|
|
||||||
© 2021 Mark LaCroix, Noble Robot
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
@ -1,375 +0,0 @@
|
|||||||
--- A li'l game engine for Playdate.
|
|
||||||
-- @module Noble
|
|
||||||
|
|
||||||
--
|
|
||||||
-- https://noblerobot.com/
|
|
||||||
--
|
|
||||||
|
|
||||||
-- Playdate libraries
|
|
||||||
import "CoreLibs/graphics"
|
|
||||||
import "CoreLibs/sprites"
|
|
||||||
import "CoreLibs/animation"
|
|
||||||
import "CoreLibs/animator"
|
|
||||||
import "CoreLibs/object"
|
|
||||||
import "CoreLibs/ui"
|
|
||||||
import "CoreLibs/math"
|
|
||||||
import "CoreLibs/timer"
|
|
||||||
import "CoreLibs/frameTimer"
|
|
||||||
import "CoreLibs/crank"
|
|
||||||
|
|
||||||
-- We create aliases for both fun and performance reasons.
|
|
||||||
Graphics = playdate.graphics
|
|
||||||
Display = playdate.display
|
|
||||||
Geometry = playdate.geometry
|
|
||||||
Ease = playdate.easingFunctions
|
|
||||||
UI = playdate.ui
|
|
||||||
File = playdate.file
|
|
||||||
Datastore = playdate.datastore
|
|
||||||
Timer = playdate.timer
|
|
||||||
FrameTimer = playdate.frameTimer
|
|
||||||
|
|
||||||
-- In lua, variables are global by default, but having a "Global" object to put
|
|
||||||
-- variables into is useful for maintaining sanity if you're coming from an OOP language.
|
|
||||||
-- It's included here for basically no reason at all. Noble Engine doesn't use it. (◔◡◔)
|
|
||||||
Global = {}
|
|
||||||
|
|
||||||
-- It all fits inside this table, oooo!
|
|
||||||
Noble = {}
|
|
||||||
|
|
||||||
-- Third-party libraries
|
|
||||||
import 'libraries/noble/libraries/Signal'
|
|
||||||
import 'libraries/noble/libraries/Sequence'
|
|
||||||
|
|
||||||
-- Noble libraries, modules, and classes.
|
|
||||||
import 'libraries/noble/utilities/Utilities.lua'
|
|
||||||
import 'libraries/noble/utilities/Ease.lua' -- Extensions to the Ease library
|
|
||||||
import 'libraries/noble/modules/Noble.Animation.lua'
|
|
||||||
import 'libraries/noble/modules/Noble.Bonk.lua'
|
|
||||||
import 'libraries/noble/modules/Noble.GameData.lua'
|
|
||||||
import 'libraries/noble/modules/Noble.Input.lua'
|
|
||||||
import 'libraries/noble/modules/Noble.Settings.lua'
|
|
||||||
import 'libraries/noble/modules/Noble.Transition.lua'
|
|
||||||
import 'libraries/noble/modules/Noble.Text.lua'
|
|
||||||
import 'libraries/noble/modules/Noble.Menu.lua'
|
|
||||||
import 'libraries/noble/modules/NobleScene.lua'
|
|
||||||
import 'libraries/noble/modules/NobleSprite.lua'
|
|
||||||
|
|
||||||
local isTransitioning = false
|
|
||||||
local currentScene = nil
|
|
||||||
local engineInitialized = false
|
|
||||||
|
|
||||||
-- configuration
|
|
||||||
--
|
|
||||||
|
|
||||||
local defaultConfiguration = {
|
|
||||||
defaultTransition = Noble.Transition.DipToBlack,
|
|
||||||
defaultTransitionDuration = 1.5,
|
|
||||||
defaultTransitionHoldTime = 0.25,
|
|
||||||
transitionDurationIncludesHoldTime = true,
|
|
||||||
enableDebugBonkChecking = false,
|
|
||||||
alwaysRedraw = true,
|
|
||||||
}
|
|
||||||
local configuration = Utilities.copy(defaultConfiguration)
|
|
||||||
|
|
||||||
--- Engine initialization. Run this once in your main.lua file to begin your game.
|
|
||||||
-- @tparam NobleScene StartingScene This is the scene your game begins with, such as a title screen, loading screen, splash screen, etc. **NOTE: Pass the scene's class name, not an instance of the scene.**
|
|
||||||
-- @number[opt=0] __launcherTransitionDuration If you want to transition from the final frame of your launch image sequence, enter a duration in seconds here.
|
|
||||||
-- @tparam[opt=Noble.Transition.DipToBlack] Noble.Transition __launcherTransition If a transition duration is set, use this transition type.
|
|
||||||
-- @tparam[opt={}] table __launcherTransitionProperties Provide a table of properties to apply to the launcher transition. See the documentation for the transition you're using for a list of available properties.
|
|
||||||
-- @tparam[opt={}] table __configuration Provide a table of Noble Engine configuration values. This will run `Noble.setConfig` for you at launch.
|
|
||||||
-- @usage
|
|
||||||
-- Noble.new(
|
|
||||||
-- TitleScreen,
|
|
||||||
-- 2,
|
|
||||||
-- Noble.Transition.DipToWhite,
|
|
||||||
-- {
|
|
||||||
-- holdTime = 0,
|
|
||||||
-- ease = Ease.outInQuad
|
|
||||||
-- },
|
|
||||||
-- {
|
|
||||||
-- defaultTransition = Noble.Transition.Imagetable,
|
|
||||||
-- defaultTransitionDuration = 1.75,
|
|
||||||
-- enableDebugBonkChecking = true,
|
|
||||||
-- }
|
|
||||||
-- )
|
|
||||||
-- @see NobleScene
|
|
||||||
-- @see Noble.Transition
|
|
||||||
-- @see setConfig
|
|
||||||
function Noble.new(StartingScene, __launcherTransitionDuration, __launcherTransition, __launcherTransitionProperties, __configuration)
|
|
||||||
|
|
||||||
math.randomseed(playdate.getSecondsSinceEpoch()) -- Set a new random seed at runtime.
|
|
||||||
|
|
||||||
if (engineInitialized) then
|
|
||||||
error("BONK: You can only run Noble.new() once.")
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
-- If the user supplies a config object, we use it, otherwise, we set default values.
|
|
||||||
if (__configuration ~= nil) then
|
|
||||||
Noble.setConfig(__configuration)
|
|
||||||
else
|
|
||||||
Noble.resetConfig()
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Screen drawing: see the Playdate SDK for details on these methods.
|
|
||||||
Graphics.sprite.setBackgroundDrawingCallback(
|
|
||||||
function (x, y, width, height)
|
|
||||||
if (currentScene ~= nil) then
|
|
||||||
-- Each scene has its own method for this. We only want to run one at a time.
|
|
||||||
currentScene:drawBackground(x, y, width, height)
|
|
||||||
else
|
|
||||||
Graphics.clear(Graphics.kColorBlack)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
)
|
|
||||||
-- Override this Playdate method that we've used already and don't want to be used again!
|
|
||||||
Graphics.sprite.setBackgroundDrawingCallback = function(callback)
|
|
||||||
error("BONK: Don't call Graphics.sprite.setBackgroundDrawingCallback() directly. Put background drawing code in your scenes' drawBackground() methods instead.")
|
|
||||||
end
|
|
||||||
|
|
||||||
-- These values are used if not set.
|
|
||||||
local launcherTransition = __launcherTransition or defaultConfiguration.defaultTransition
|
|
||||||
local launcherTransitionDuration = __launcherTransitionDuration or 1.5
|
|
||||||
local launcherTransitionProperties =__launcherTransitionProperties or {}
|
|
||||||
|
|
||||||
-- Now that everything is set, let's-a go!
|
|
||||||
engineInitialized = true
|
|
||||||
Noble.transition(StartingScene, launcherTransitionDuration, launcherTransition, launcherTransitionProperties)
|
|
||||||
end
|
|
||||||
|
|
||||||
--- This checks to see if `Noble.new` has been run. It is used internally to ward off bonks.
|
|
||||||
-- @treturn bool
|
|
||||||
-- @see Noble.Bonk
|
|
||||||
function Noble.engineInitialized()
|
|
||||||
return engineInitialized
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Miscellaneous Noble Engine configuration options / default values.
|
|
||||||
-- This table cannot be edited directly. Use `Noble.getConfig` and `Noble.setConfig`.
|
|
||||||
-- @table configuration
|
|
||||||
-- @tparam[opt=Noble.Transition.DipToBlack] Noble.Transition defaultTransition When running `Noble.transition` if the transition is unspecified, it will use this one.
|
|
||||||
-- @number[opt=1.5] defaultTransitionDuration When running `Noble.transition` if the scene transition duration is unspecified, it will take this long in seconds.
|
|
||||||
-- @bool[opt=false] enableDebugBonkChecking Noble Engine-specific errors are called "Bonks." You can set this to true during development in order to check for more of them. However, it uses resources, so you will probably want to turn it off before release.
|
|
||||||
-- @bool[opt=true] alwaysRedraw This sets the Playdate SDK method `playdate.graphics.sprite.setAlwaysRedraw`. See the Playdate SDK for details on how this function works, and the reasons you might want to set it as true or false for your project.
|
|
||||||
-- @see Noble.getConfig
|
|
||||||
-- @see Noble.setConfig
|
|
||||||
-- @see Noble.Bonk.startCheckingDebugBonks
|
|
||||||
|
|
||||||
--- Retrieve miscellaneous Noble Engine configuration options / default values
|
|
||||||
-- @return A table of all configuration values
|
|
||||||
-- @see configuration
|
|
||||||
-- @see setConfig
|
|
||||||
function Noble.getConfig()
|
|
||||||
return configuration
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Optionally customize miscellaneous Noble Engine configuration options / default values. You may run this method to change these values during runtime.
|
|
||||||
-- @tparam table __configuration This is a table with your configuration values in it.
|
|
||||||
-- @see configuration
|
|
||||||
-- @see getConfig
|
|
||||||
function Noble.setConfig(__configuration)
|
|
||||||
|
|
||||||
if (__configuration == nil) then
|
|
||||||
error("BONK: You cannot pass a nil value to Noble.setConfig(). If you want to reset to default values, use Noble.resetConfig().")
|
|
||||||
end
|
|
||||||
|
|
||||||
if (__configuration.defaultTransition ~= nil) then configuration.defaultTransition = __configuration.defaultTransition end
|
|
||||||
if (__configuration.defaultTransitionDuration ~= nil) then configuration.defaultTransitionDuration = __configuration.defaultTransitionDuration end
|
|
||||||
if (__configuration.defaultTransitionHoldTime ~= nil) then configuration.defaultTransitionHoldTime = __configuration.defaultTransitionHoldTime end
|
|
||||||
if (__transitionDurationIncludesHoldTime ~= nil) then configuration.transitionDurationIncludesHoldTime = __configuration.transitionDurationIncludesHoldTime end
|
|
||||||
|
|
||||||
if (__configuration.enableDebugBonkChecking ~= nil) then
|
|
||||||
configuration.enableDebugBonkChecking = __configuration.enableDebugBonkChecking
|
|
||||||
if (configuration.enableDebugBonkChecking == true) then Noble.Bonk.enableDebugBonkChecking() end
|
|
||||||
end
|
|
||||||
|
|
||||||
if (__configuration.alwaysRedraw ~= nil) then
|
|
||||||
configuration.alwaysRedraw = __configuration.alwaysRedraw
|
|
||||||
Graphics.sprite.setAlwaysRedraw(configuration.alwaysRedraw)
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Reset miscellaneous Noble Engine configuration values to their defaults.
|
|
||||||
-- @see getConfig
|
|
||||||
-- @see setConfig
|
|
||||||
function Noble.resetConfig()
|
|
||||||
Noble.setConfig(Utilities.copy(defaultConfiguration))
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Transition stuff
|
|
||||||
--
|
|
||||||
local currentTransition = nil
|
|
||||||
local queuedScene = nil
|
|
||||||
|
|
||||||
--- Transition to a new scene (at the end of this frame).
|
|
||||||
--- This method will create a new scene, mark the previous one for garbage collection, and animate between them.
|
|
||||||
--- Additional calls to this method within the same frame (before the already-called transition begins), will override previous calls. Any calls to this method once a transition begins will be ignored until the transition completes.
|
|
||||||
-- @tparam NobleScene NewScene The scene to transition to. Pass the scene's class, not an instance of the scene. You always transition from `Noble.currentScene`
|
|
||||||
-- @number[opt=1.5] __duration The length of the transition, in seconds.
|
|
||||||
-- @tparam[opt=Noble.TransitionType.DIP_TO_BLACK] Noble.Transition __transition If a transition duration is set, use this transition type. If not set, it will use the value of `configuration.defaultTransition`.
|
|
||||||
-- @tparam[opt={}] table __transitionProperties A table consisting of properties for this transition. Properties not set here will use values that transition's `defaultProperties` table.
|
|
||||||
-- @usage
|
|
||||||
-- Noble.transition(Level2, 1, Noble.Transition.CrossDissolve, {
|
|
||||||
-- dither = Graphics.image.kDitherTypeDiagonalLine
|
|
||||||
-- ease = Ease.outQuint
|
|
||||||
-- })
|
|
||||||
-- --
|
|
||||||
-- Noble.transition(Level2, 1, Noble.Transition.DipToBlack, {
|
|
||||||
-- holdTime = 0.5,
|
|
||||||
-- ease = Ease.outInElastic
|
|
||||||
-- })
|
|
||||||
-- --
|
|
||||||
-- Noble.transition(Level2, 1, Noble.Transition.SlideOff, {
|
|
||||||
-- x = 400,
|
|
||||||
-- y = 150
|
|
||||||
-- rotation = 45
|
|
||||||
-- })
|
|
||||||
-- @see Noble.isTransitioning
|
|
||||||
-- @see NobleScene
|
|
||||||
-- @see Noble.Transition
|
|
||||||
-- @see Noble.Transition.defaultProperties
|
|
||||||
function Noble.transition(NewScene, __duration, __transition, __transitionProperties)
|
|
||||||
if (isTransitioning) then
|
|
||||||
-- This bonk no longer throws an error (compared to previous versions of Noble Engine), but maybe it still should?
|
|
||||||
warn("BONK: You can't start a transition in the middle of another transition, silly!")
|
|
||||||
return -- Let's get otta here!
|
|
||||||
elseif (queuedScene ~= nil) then
|
|
||||||
-- Calling this method multiple times between Noble.update() calls is probably not intentional behavior.
|
|
||||||
warn("Soft-BONK: You are calling Noble.transition() multiple times within the same frame. Did you mean to do that?")
|
|
||||||
-- We don't return here because maybe the developer *did* intend to override a previous call to Noble.transition().
|
|
||||||
end
|
|
||||||
|
|
||||||
queuedScene = NewScene() -- Creates new scene object. Its init() function runs now.
|
|
||||||
|
|
||||||
currentTransition = (__transition or configuration.defaultTransition)(
|
|
||||||
__duration or configuration.defaultTransitionDuration,
|
|
||||||
__transitionProperties or {}
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
-- These methods are triggered during an transition
|
|
||||||
|
|
||||||
function Noble.transitionStartHandler()
|
|
||||||
isTransitioning = true
|
|
||||||
if (currentScene ~= nil) then
|
|
||||||
currentScene:exit() -- The current scene runs its "goodbye" code. Sprites are taken out of the simulation.
|
|
||||||
end
|
|
||||||
Noble.Input.setHandler(nil) -- Disable user input.
|
|
||||||
end
|
|
||||||
|
|
||||||
function Noble.transitionMidpointHandler()
|
|
||||||
if (currentScene ~= nil) then
|
|
||||||
currentScene:finish()
|
|
||||||
currentScene = nil -- Allows current scene to be garbage collected.
|
|
||||||
end
|
|
||||||
currentScene = queuedScene -- New scene's update loop begins.
|
|
||||||
queuedScene = nil
|
|
||||||
currentScene:enter() -- The new scene runs its "hello" code.
|
|
||||||
end
|
|
||||||
|
|
||||||
function Noble.transitionCompleteHandler()
|
|
||||||
isTransitioning = false -- Reset
|
|
||||||
currentTransition = nil -- Clear the transition variable.
|
|
||||||
currentScene:start() -- The new scene is now active.
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Get the current scene object
|
|
||||||
-- @treturn NobleScene
|
|
||||||
function Noble.currentScene()
|
|
||||||
return currentScene
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Get the name of the current scene
|
|
||||||
-- @treturn string
|
|
||||||
function Noble.currentSceneName()
|
|
||||||
return currentScene.name
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Check to see if the game is transitioning between scenes.
|
|
||||||
-- Useful to control game logic that lives outside of a scene's `update()` method.
|
|
||||||
-- @treturn bool
|
|
||||||
function Noble.isTransitioning()
|
|
||||||
return isTransitioning
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Show/hide the Playdate SDK's FPS counter.
|
|
||||||
-- @field bool
|
|
||||||
Noble.showFPS = false;
|
|
||||||
|
|
||||||
local crankIndicatorActive = false
|
|
||||||
local crankIndicatorForced = false
|
|
||||||
|
|
||||||
local transitionCanvas = Graphics.image.new(400, 240)
|
|
||||||
|
|
||||||
-- Game loop
|
|
||||||
--
|
|
||||||
function playdate.update()
|
|
||||||
Noble.Input.update() -- Check for Noble Engine-specific input methods.
|
|
||||||
|
|
||||||
Sequence.update() -- Update all animations that use the Sequence library.
|
|
||||||
|
|
||||||
-- Here we check to see if a transition currently in progress needs screenshots of the new scene.
|
|
||||||
-- If so, we route drawing for this frame into a new context.
|
|
||||||
if (isTransitioning and currentTransition._captureScreenshotsDuringTransition) then
|
|
||||||
currentTransition.newSceneScreenshot = Graphics.image.new(400, 240)
|
|
||||||
Graphics.pushContext(currentTransition.newSceneScreenshot)
|
|
||||||
end
|
|
||||||
|
|
||||||
Graphics.sprite.update() -- Let's draw our sprites (and backgrounds).
|
|
||||||
|
|
||||||
if (currentScene ~= nil) then
|
|
||||||
currentScene:update() -- Scene-specific update code.
|
|
||||||
end
|
|
||||||
|
|
||||||
if (isTransitioning) then
|
|
||||||
if (currentTransition._captureScreenshotsDuringTransition) then
|
|
||||||
Graphics.popContext()
|
|
||||||
end
|
|
||||||
transitionCanvas:clear(Graphics.kColorClear)
|
|
||||||
|
|
||||||
Graphics.pushContext(transitionCanvas)
|
|
||||||
currentTransition:draw()
|
|
||||||
Graphics.popContext()
|
|
||||||
|
|
||||||
Graphics.setImageDrawMode(currentTransition.drawMode)
|
|
||||||
transitionCanvas:drawIgnoringOffset(0, 0)
|
|
||||||
Graphics.setImageDrawMode(Graphics.kDrawModeCopy)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- We want to draw the crank indicator and FPS display last
|
|
||||||
crankIndicatorActive, crankIndicatorForced = Noble.Input.getCrankIndicatorStatus()
|
|
||||||
if (crankIndicatorActive) then
|
|
||||||
if (playdate.isCrankDocked() or crankIndicatorForced) then
|
|
||||||
UI.crankIndicator:update() -- Draw crank indicator (if requested).
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if (Noble.showFPS) then
|
|
||||||
playdate.drawFPS(4, 4)
|
|
||||||
end
|
|
||||||
|
|
||||||
Timer.updateTimers() -- Finally, update all SDK timers.
|
|
||||||
FrameTimer.updateTimers() -- Update all frame timers
|
|
||||||
|
|
||||||
if (Noble.Bonk.checkingDebugBonks()) then -- Checks for code that breaks the engine.
|
|
||||||
Noble.Bonk.checkDebugBonks()
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Once this frame is complete, we can check to see if it's time to start transitioning to a new scene.
|
|
||||||
if (not isTransitioning and currentTransition ~= nil) then
|
|
||||||
currentTransition:execute()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function playdate.gameWillPause()
|
|
||||||
if (currentScene ~= nil) then
|
|
||||||
currentScene:pause()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function playdate.gameWillResume()
|
|
||||||
if (currentScene ~= nil) then
|
|
||||||
currentScene:resume()
|
|
||||||
end
|
|
||||||
end
|
|
Before Width: | Height: | Size: 220 KiB |
@ -1,66 +0,0 @@
|
|||||||
Noble Engine
|
|
||||||
============
|
|
||||||
### A li'l game engine for Playdate.
|
|
||||||
|
|
||||||
![](README.gif)
|
|
||||||
|
|
||||||
The Playdate SDK is probably the most user-friendly console SDK ever made, but if you're familiar with state/scene-based game engine frameworks like Unity, Flixel, Citrus, or others, you may be looking for a library that can get your game "on its feet,” extend existing APIs, offer new features, or provide more intuative ways to leverage the SDK in your game.
|
|
||||||
|
|
||||||
If so, you're looking for Noble Engine!
|
|
||||||
|
|
||||||
Features
|
|
||||||
--------
|
|
||||||
- Complete scene lifecycle management. Handle update loops, sprites, input, and initialization steps on a per scene basis.
|
|
||||||
- Scene transition API and animation library with over a dozen transition types (cross dissolve, dip-to-black, and more).
|
|
||||||
- Settings/SaveGame API, supporting up to 1000 save slots and automatic updating of on disk files when you inevitably muck around with your data structure in development.
|
|
||||||
- Boilerplate menu object, with simple way to add/remove items and manage “click” handlers.
|
|
||||||
- Additional input methods, and per-scene \`inputHandler\` logic.
|
|
||||||
- Full state manager for sprite animations.
|
|
||||||
- New fonts! Including full Japanese katakana character set.
|
|
||||||
- Fully documented code, explaining methods and architecture, and LDoc-generated [documentation pages](https://noblerobot.github.io/NobleEngine).
|
|
||||||
- Full project template, with example scenes and launcher assets, to help beginners get started with Playdate development.
|
|
||||||
- Random goodies, like a unified text drawing method for normal/aligned/localized text, one-line methods for showing/hiding the crank indicator and the FPS counter, and more.
|
|
||||||
|
|
||||||
Setup
|
|
||||||
-----
|
|
||||||
|
|
||||||
### Via Template
|
|
||||||
The recommended setup procedure is to clone the [Noble Engine Project Template repository](https://github.com/NobleRobot/NobleEngine-ProjectTemplate) instead of this one. That project is available as a [GitHub Template](https://github.blog/2019-06-06-generate-new-repositories-with-repository-templates/), which you can use to start your own project if you're hosting it on GitHub, or you can clone or download it manually.
|
|
||||||
|
|
||||||
The template repository includes this one as a [git submodule](https://www.atlassian.com/git/tutorials/git-submodule). This way, you can mange your use of Noble Engine independently from your own code.
|
|
||||||
|
|
||||||
The project template also includes some usage examples to help you get up to speed on how Noble Engine works.
|
|
||||||
|
|
||||||
### Manual setup
|
|
||||||
If, instead, you want to download or clone this repository directly in to a new or existing project, simply place it into `libraries/noble/` relative to your `main.lua` file.
|
|
||||||
|
|
||||||
Once you’ve done that, using Noble Engine can be quickly wired up in your `main.lua` file:
|
|
||||||
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
import libraries/noble/Noble
|
|
||||||
import scenes/MyStartingScene -- Or whatever your game's first scene is.
|
|
||||||
|
|
||||||
Noble.new(MyStartingScene)
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
**Note:** If you are adding Noble Engine to an existing project, it is still recommended to either start with the project template and bring your existing code in, or reorganize your project to mimic the structure of the template. The project template defines a folder layout and has some additional flotsam that reflects the “opinion” of Noble Engine, which is useful if you want to have the best experience using it.
|
|
||||||
|
|
||||||
Documentation
|
|
||||||
-------------
|
|
||||||
Noble Engine is fully documented in code, and has a full set of html pages generated with [LDoc](https://github.com/lunarmodules/LDoc) and styled for legibility, ease-of-use, and playful charm if I do say so myself.
|
|
||||||
|
|
||||||
These pages are included in the repository at `docs/index.html` and on [GitHub Pages](https://noblerobot.github.io/NobleEngine).
|
|
||||||
|
|
||||||
Notes on Style
|
|
||||||
--------------
|
|
||||||
Noble Engine was originally developed for _Widget Satchel II: Return of Sprocket_, by Mark LaCroix, who never wrote a line of Lua in his life before starting this project.
|
|
||||||
|
|
||||||
In general, Lua best-practices are followed, but in some cases code style and naming conventions are more likely to follow those found in “C-like” languages such as Haxe, C\#, Java, ActionScript, etc.
|
|
||||||
|
|
||||||
- Methods and variables are **camelCase**.
|
|
||||||
- “Class” names are **TitleCase**, and Lua “modules” are treated as nested classes, thus `Noble.Text` instead of `noble.text`.
|
|
||||||
- Constants, such as `Noble.TransitionType.DIP_TO_BLACK`, are **ALL_CAPS_SNAKE_CASE**
|
|
||||||
- Argument names are prefixed with a **double-underscore**, as in `__displayName`. This mostly impacts documentation legibility. I’m very sorry but it couldn’t be helped. 😆
|
|
||||||
- Names are verbose by default; no abbreviations. This includes aliases for Playdate packages, so `playdate.graphics` is aliased as `Graphics`, instead of `gfx`.
|
|
||||||
|
|
||||||
Some of these conventions run counter to those seen in the Playdate SDK. In places where there’s a potential conflict, either an alias is created for Noble Engine’s version to match the engine’s code style, or the Playdate SDK item is given preference and Noble Engine stays out of its way.
|
|
Before Width: | Height: | Size: 7.2 KiB |
@ -1,296 +0,0 @@
|
|||||||
tracking=1
|
|
||||||
|
|
||||||
space 2
|
|
||||||
A 7
|
|
||||||
B 6
|
|
||||||
C 6
|
|
||||||
D 6
|
|
||||||
E 5
|
|
||||||
F 5
|
|
||||||
G 6
|
|
||||||
H 6
|
|
||||||
I 3
|
|
||||||
J 6
|
|
||||||
K 6
|
|
||||||
L 5
|
|
||||||
M 7
|
|
||||||
N 7
|
|
||||||
O 7
|
|
||||||
P 6
|
|
||||||
Q 7
|
|
||||||
R 6
|
|
||||||
S 6
|
|
||||||
T 5
|
|
||||||
U 6
|
|
||||||
V 6
|
|
||||||
W 8
|
|
||||||
X 7
|
|
||||||
Y 7
|
|
||||||
Z 7
|
|
||||||
. 3
|
|
||||||
: 4
|
|
||||||
0 6
|
|
||||||
1 6
|
|
||||||
2 6
|
|
||||||
3 6
|
|
||||||
4 6
|
|
||||||
5 6
|
|
||||||
6 6
|
|
||||||
7 6
|
|
||||||
8 6
|
|
||||||
9 6
|
|
||||||
- 6
|
|
||||||
! 4
|
|
||||||
" 5
|
|
||||||
% 7
|
|
||||||
' 2
|
|
||||||
( 5
|
|
||||||
) 5
|
|
||||||
+ 8
|
|
||||||
, 3
|
|
||||||
? 4
|
|
||||||
/ 5
|
|
||||||
< 5
|
|
||||||
> 5
|
|
||||||
[ 3
|
|
||||||
\ 5
|
|
||||||
] 3
|
|
||||||
{ 5
|
|
||||||
} 5
|
|
||||||
_ 6
|
|
||||||
~ 7
|
|
||||||
= 7
|
|
||||||
* 8
|
|
||||||
ラ 6
|
|
||||||
リ 6
|
|
||||||
ル 8
|
|
||||||
レ 5
|
|
||||||
ロ 7
|
|
||||||
ヮ 6
|
|
||||||
ワ 6
|
|
||||||
ョ 6
|
|
||||||
ヨ 6
|
|
||||||
゠ 6
|
|
||||||
ァ 7
|
|
||||||
ア 7
|
|
||||||
ィ 6
|
|
||||||
イ 6
|
|
||||||
ニ 7
|
|
||||||
ユ 7
|
|
||||||
ゥ 6
|
|
||||||
ウ 6
|
|
||||||
ェ 6
|
|
||||||
エ 6
|
|
||||||
ォ 6
|
|
||||||
オ 6
|
|
||||||
カ 6
|
|
||||||
ガ 7
|
|
||||||
キ 6
|
|
||||||
ギ 6
|
|
||||||
ク 6
|
|
||||||
グ 6
|
|
||||||
ケ 7
|
|
||||||
ゲ 6
|
|
||||||
コ 6
|
|
||||||
ゴ 6
|
|
||||||
サ 6
|
|
||||||
ザ 6
|
|
||||||
シ 7
|
|
||||||
ジ 7
|
|
||||||
ス 6
|
|
||||||
ズ 6
|
|
||||||
セ 7
|
|
||||||
ゼ 7
|
|
||||||
ソ 6
|
|
||||||
ゾ 6
|
|
||||||
ツ 6
|
|
||||||
ヅ 6
|
|
||||||
ッ 6
|
|
||||||
タ 6
|
|
||||||
ダ 6
|
|
||||||
チ 6
|
|
||||||
ヂ 6
|
|
||||||
テ 6
|
|
||||||
デ 6
|
|
||||||
ナ 6
|
|
||||||
ト 6
|
|
||||||
ド 6
|
|
||||||
・ 6
|
|
||||||
ー 7
|
|
||||||
ノ 5
|
|
||||||
ヌ 6
|
|
||||||
ネ 6
|
|
||||||
マ 6
|
|
||||||
ハ 7
|
|
||||||
バ 7
|
|
||||||
パ 7
|
|
||||||
ヒ 6
|
|
||||||
ビ 6
|
|
||||||
ピ 6
|
|
||||||
フ 6
|
|
||||||
ブ 6
|
|
||||||
プ 6
|
|
||||||
ヘ 7
|
|
||||||
ベ 7
|
|
||||||
ペ 7
|
|
||||||
ホ 7
|
|
||||||
ボ 7
|
|
||||||
ポ 7
|
|
||||||
ミ 6
|
|
||||||
ム 6
|
|
||||||
メ 6
|
|
||||||
モ 6
|
|
||||||
ャ 7
|
|
||||||
ヤ 7
|
|
||||||
ュ 7
|
|
||||||
ヱ 7
|
|
||||||
ヲ 6
|
|
||||||
ン 7
|
|
||||||
ヰ 7
|
|
||||||
ヴ 6
|
|
||||||
ヵ 6
|
|
||||||
ヶ 6
|
|
||||||
ヷ 6
|
|
||||||
ヸ 7
|
|
||||||
ヹ 7
|
|
||||||
ヺ 6
|
|
||||||
ヽ 5
|
|
||||||
ヾ 5
|
|
||||||
ヿ 5
|
|
||||||
「 6
|
|
||||||
」 6
|
|
||||||
。 7
|
|
||||||
、 7
|
|
||||||
ぁ 6
|
|
||||||
あ 7
|
|
||||||
ぃ 6
|
|
||||||
い 7
|
|
||||||
ぅ 5
|
|
||||||
う 6
|
|
||||||
え 6
|
|
||||||
ぇ 5
|
|
||||||
お 7
|
|
||||||
ぉ 7
|
|
||||||
か 7
|
|
||||||
が 7
|
|
||||||
き 6
|
|
||||||
ぎ 7
|
|
||||||
く 6
|
|
||||||
ぐ 6
|
|
||||||
げ 7
|
|
||||||
け 7
|
|
||||||
こ 7
|
|
||||||
ご 7
|
|
||||||
さ 6
|
|
||||||
ざ 7
|
|
||||||
じ 6
|
|
||||||
し 6
|
|
||||||
す 7
|
|
||||||
ず 7
|
|
||||||
せ 7
|
|
||||||
ぜ 7
|
|
||||||
そ 5
|
|
||||||
ぞ 6
|
|
||||||
た 7
|
|
||||||
だ 7
|
|
||||||
ち 6
|
|
||||||
ぢ 7
|
|
||||||
つ 7
|
|
||||||
づ 7
|
|
||||||
っ 7
|
|
||||||
て 7
|
|
||||||
で 7
|
|
||||||
と 7
|
|
||||||
ど 7
|
|
||||||
に 7
|
|
||||||
な 7
|
|
||||||
ぬ 7
|
|
||||||
ね 7
|
|
||||||
の 7
|
|
||||||
は 8
|
|
||||||
ば 8
|
|
||||||
ぱ 8
|
|
||||||
ひ 8
|
|
||||||
び 8
|
|
||||||
ぴ 8
|
|
||||||
ふ 8
|
|
||||||
ぶ 8
|
|
||||||
ぷ 8
|
|
||||||
へ 7
|
|
||||||
べ 7
|
|
||||||
ぺ 7
|
|
||||||
ほ 8
|
|
||||||
ぼ 8
|
|
||||||
ぽ 8
|
|
||||||
ま 6
|
|
||||||
み 7
|
|
||||||
む 8
|
|
||||||
め 7
|
|
||||||
も 6
|
|
||||||
ゃ 6
|
|
||||||
や 7
|
|
||||||
ゅ 7
|
|
||||||
ゆ 8
|
|
||||||
ょ 6
|
|
||||||
よ 6
|
|
||||||
ら 6
|
|
||||||
り 6
|
|
||||||
る 7
|
|
||||||
ろ 7
|
|
||||||
円 8
|
|
||||||
れ 8
|
|
||||||
ゎ 7
|
|
||||||
わ 8
|
|
||||||
ゐ 7
|
|
||||||
ゑ 7
|
|
||||||
を 7
|
|
||||||
ん 7
|
|
||||||
ゔ 7
|
|
||||||
ゕ 7
|
|
||||||
ゖ 6
|
|
||||||
ゝ 5
|
|
||||||
ゞ 5
|
|
||||||
゛ 6
|
|
||||||
゜ 6
|
|
||||||
ゟ 6
|
|
||||||
a 6
|
|
||||||
b 6
|
|
||||||
c 6
|
|
||||||
d 6
|
|
||||||
e 6
|
|
||||||
f 5
|
|
||||||
g 6
|
|
||||||
h 6
|
|
||||||
i 3
|
|
||||||
j 5
|
|
||||||
k 6
|
|
||||||
l 3
|
|
||||||
m 7
|
|
||||||
n 6
|
|
||||||
o 6
|
|
||||||
p 6
|
|
||||||
q 6
|
|
||||||
r 5
|
|
||||||
s 6
|
|
||||||
t 5
|
|
||||||
u 6
|
|
||||||
v 6
|
|
||||||
w 8
|
|
||||||
| 4
|
|
||||||
x 6
|
|
||||||
y 6
|
|
||||||
` 3
|
|
||||||
z 6
|
|
||||||
# 7
|
|
||||||
$ 6
|
|
||||||
& 8
|
|
||||||
™ 8
|
|
||||||
© 6
|
|
||||||
® 6
|
|
||||||
‼ 6
|
|
||||||
<EFBFBD> 8
|
|
||||||
… 8
|
|
||||||
@ 8
|
|
||||||
; 4
|
|
||||||
^ 7
|
|
||||||
¥ 8
|
|
Before Width: | Height: | Size: 4.7 KiB |
@ -1,97 +0,0 @@
|
|||||||
tracking=1
|
|
||||||
|
|
||||||
space 6
|
|
||||||
! 9
|
|
||||||
" 8
|
|
||||||
# 14
|
|
||||||
$ 11
|
|
||||||
% 17
|
|
||||||
& 13
|
|
||||||
' 4
|
|
||||||
( 8
|
|
||||||
) 8
|
|
||||||
* 9
|
|
||||||
+ 11
|
|
||||||
, 5
|
|
||||||
- 9
|
|
||||||
. 5
|
|
||||||
/ 11
|
|
||||||
0 11
|
|
||||||
1 9
|
|
||||||
2 11
|
|
||||||
3 11
|
|
||||||
4 12
|
|
||||||
5 11
|
|
||||||
6 11
|
|
||||||
7 12
|
|
||||||
8 11
|
|
||||||
9 11
|
|
||||||
: 5
|
|
||||||
; 5
|
|
||||||
< 10
|
|
||||||
= 11
|
|
||||||
> 10
|
|
||||||
? 10
|
|
||||||
@ 14
|
|
||||||
A 13
|
|
||||||
B 11
|
|
||||||
C 13
|
|
||||||
D 13
|
|
||||||
E 11
|
|
||||||
F 11
|
|
||||||
G 13
|
|
||||||
H 11
|
|
||||||
I 5
|
|
||||||
J 11
|
|
||||||
K 13
|
|
||||||
L 10
|
|
||||||
M 16
|
|
||||||
N 13
|
|
||||||
O 14
|
|
||||||
P 11
|
|
||||||
Q 14
|
|
||||||
R 12
|
|
||||||
S 11
|
|
||||||
T 11
|
|
||||||
U 12
|
|
||||||
V 13
|
|
||||||
W 17
|
|
||||||
X 12
|
|
||||||
Y 11
|
|
||||||
Z 12
|
|
||||||
[ 9
|
|
||||||
\ 12
|
|
||||||
] 9
|
|
||||||
^ 10
|
|
||||||
_ 15
|
|
||||||
` 8
|
|
||||||
a 13
|
|
||||||
b 11
|
|
||||||
c 13
|
|
||||||
d 13
|
|
||||||
e 11
|
|
||||||
f 11
|
|
||||||
g 13
|
|
||||||
h 11
|
|
||||||
i 5
|
|
||||||
j 11
|
|
||||||
k 13
|
|
||||||
l 10
|
|
||||||
m 16
|
|
||||||
n 13
|
|
||||||
o 14
|
|
||||||
p 11
|
|
||||||
q 14
|
|
||||||
r 12
|
|
||||||
s 11
|
|
||||||
t 11
|
|
||||||
u 12
|
|
||||||
v 13
|
|
||||||
w 17
|
|
||||||
x 12
|
|
||||||
y 11
|
|
||||||
z 12
|
|
||||||
{ 9
|
|
||||||
| 6
|
|
||||||
} 8
|
|
||||||
¥ 12
|
|
Before Width: | Height: | Size: 55 KiB |
Before Width: | Height: | Size: 63 KiB |
Before Width: | Height: | Size: 136 KiB |
Before Width: | Height: | Size: 366 B |
@ -1,489 +0,0 @@
|
|||||||
--
|
|
||||||
-- Sequence library by Nic Magnier
|
|
||||||
--
|
|
||||||
|
|
||||||
--[[
|
|
||||||
class to create simple animations using easing as building blocks
|
|
||||||
|
|
||||||
To create a simple sequence:
|
|
||||||
animation = sequence.new():from(0):to(1,2.0,"outQuad"):mirror()
|
|
||||||
|
|
||||||
In your game loop
|
|
||||||
sequence.update()
|
|
||||||
currentValue = animation:get()
|
|
||||||
|
|
||||||
Add hooks or callback
|
|
||||||
animation = sequence.new():from(0):to(1,2.0,"outQuad"):callback(function() print("end animation") end):mirror()
|
|
||||||
]]--
|
|
||||||
import 'CoreLibs/easing'
|
|
||||||
|
|
||||||
Sequence = {}
|
|
||||||
Sequence.__index = Sequence
|
|
||||||
|
|
||||||
-- private member
|
|
||||||
local _easings = playdate.easingFunctions
|
|
||||||
if not _easings then
|
|
||||||
print("Sequence warning: easing function not found. Don't forget to call import 'CoreLibs/easing'")
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local _runningSequences = table.create(32,0)
|
|
||||||
local _previousUpdateTime = playdate.getCurrentTimeMilliseconds()
|
|
||||||
|
|
||||||
-- This can be useful when you want your Sequence to continue in realtime
|
|
||||||
-- when using playdate.stop() / .wait(milliseconds) / .start().
|
|
||||||
--
|
|
||||||
-- If you don't set __currentTime, it defaults to playdate.getCurrentTimeMilliseconds()
|
|
||||||
-- Examples:
|
|
||||||
-- Use Sequence.setPreviousUpdateTime() before you call playdate.start().
|
|
||||||
-- Use Sequence.setPreviousUpdateTime(playdate.getCurrentTimeMilliseconds() + milliseconds)
|
|
||||||
-- before using playdate.wait(milliseconds).
|
|
||||||
function Sequence.setPreviousUpdateTime(currentTime)
|
|
||||||
if (currentTime == nil) then
|
|
||||||
currentTime = playdate.getCurrentTimeMilliseconds()
|
|
||||||
end
|
|
||||||
|
|
||||||
_previousUpdateTime = currentTime
|
|
||||||
end
|
|
||||||
|
|
||||||
-- create a new sequence
|
|
||||||
|
|
||||||
function Sequence.new()
|
|
||||||
local new_sequence = {
|
|
||||||
-- runtime values
|
|
||||||
time = 0,
|
|
||||||
cachedResultTimestamp = nil,
|
|
||||||
cachedResult = 0,
|
|
||||||
previousUpdateEasingIndex = nil,
|
|
||||||
isRunning = false,
|
|
||||||
|
|
||||||
duration = 0,
|
|
||||||
loopType = false,
|
|
||||||
easings = table.create(4, 0),
|
|
||||||
easingCount = 0,
|
|
||||||
callbacks = nil,
|
|
||||||
}
|
|
||||||
|
|
||||||
return setmetatable(new_sequence, Sequence)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- put a low pacing to slow down all animations, great for tweaking
|
|
||||||
function Sequence.update( pacing )
|
|
||||||
pacing = pacing or 1
|
|
||||||
|
|
||||||
local currentTime = playdate.getCurrentTimeMilliseconds()
|
|
||||||
local deltaTime = ((currentTime-_previousUpdateTime) / 1000) * pacing
|
|
||||||
_previousUpdateTime = currentTime
|
|
||||||
|
|
||||||
for index = #_runningSequences, 1, -1 do
|
|
||||||
local seq = _runningSequences[index]
|
|
||||||
|
|
||||||
seq:updateCallbacks( deltaTime )
|
|
||||||
|
|
||||||
seq.time = seq.time + deltaTime
|
|
||||||
seq.cachedResultTimestamp = nil
|
|
||||||
|
|
||||||
if seq:isDone() then
|
|
||||||
table.remove(_runningSequences, index)
|
|
||||||
seq.isRunning = false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function Sequence.print()
|
|
||||||
print("Sequences running:", #_runningSequences)
|
|
||||||
for index, seq in pairs(_runningSequences) do
|
|
||||||
print(" Sequence", index, seq)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function Sequence:clear()
|
|
||||||
self:stop()
|
|
||||||
self.time = 0
|
|
||||||
self.duration = 0
|
|
||||||
self.loopType = false
|
|
||||||
self.easingCount = 0
|
|
||||||
self.cachedResultTimestamp = nil
|
|
||||||
self.cachedResult = 0
|
|
||||||
self.previousUpdateEasingIndex = nil
|
|
||||||
self.callbacks = {}
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Reinitialize the sequence
|
|
||||||
function Sequence:from( from )
|
|
||||||
from = from or 0
|
|
||||||
|
|
||||||
-- release all easings
|
|
||||||
self:clear()
|
|
||||||
|
|
||||||
-- setup first empty easing at the beginning of the sequence
|
|
||||||
local newEasing = self:newEasing()
|
|
||||||
newEasing.timestamp = 0
|
|
||||||
newEasing.from = from
|
|
||||||
newEasing.to = from
|
|
||||||
newEasing.duration = 0
|
|
||||||
newEasing.fn = _easings.flat
|
|
||||||
|
|
||||||
return self
|
|
||||||
end
|
|
||||||
|
|
||||||
function Sequence:to( to, duration, easingFunction, ... )
|
|
||||||
if not self then return end
|
|
||||||
|
|
||||||
-- default parameters
|
|
||||||
to = to or 0
|
|
||||||
duration = duration or 0.3
|
|
||||||
easingFunction = easingFunction or _easings.inOutQuad
|
|
||||||
if type(easingFunction)=="string" then
|
|
||||||
easingFunction = _easings[easingFunction] or _easings.inOutQuad
|
|
||||||
end
|
|
||||||
|
|
||||||
local lastEasing = self.easings[self.easingCount]
|
|
||||||
local newEasing = self:newEasing()
|
|
||||||
|
|
||||||
-- setup first empty easing at the beginning of the sequence
|
|
||||||
newEasing.timestamp = lastEasing.timestamp + lastEasing.duration
|
|
||||||
newEasing.from = lastEasing.to
|
|
||||||
newEasing.to = to
|
|
||||||
newEasing.duration = duration
|
|
||||||
newEasing.fn = easingFunction
|
|
||||||
newEasing.params = {...}
|
|
||||||
|
|
||||||
-- update overall sequence infos
|
|
||||||
self.duration = self.duration + duration
|
|
||||||
|
|
||||||
return self
|
|
||||||
end
|
|
||||||
|
|
||||||
function Sequence:set( value )
|
|
||||||
if not self then return end
|
|
||||||
|
|
||||||
local lastEasing = self.easings[self.easingCount]
|
|
||||||
local newEasing = self:newEasing()
|
|
||||||
|
|
||||||
-- setup first empty easing at the beginning of the sequence
|
|
||||||
newEasing.timestamp = lastEasing.timestamp + lastEasing.duration
|
|
||||||
newEasing.from = value
|
|
||||||
newEasing.to = value
|
|
||||||
newEasing.duration = 0
|
|
||||||
newEasing.fn = _easings.flat
|
|
||||||
|
|
||||||
return self
|
|
||||||
end
|
|
||||||
|
|
||||||
-- @repeatCount: number of times the last easing as to be duplicated
|
|
||||||
-- @mirror: bool, does the repeating easings have to be mirrored (yoyo effect)
|
|
||||||
function Sequence:again( repeatCount, mirror )
|
|
||||||
if not self then return end
|
|
||||||
|
|
||||||
repeatCount = repeatCount or 1
|
|
||||||
|
|
||||||
local previousEasing = self.easings[self.easingCount]
|
|
||||||
|
|
||||||
for i = 1, repeatCount do
|
|
||||||
local newEasing = self:newEasing()
|
|
||||||
|
|
||||||
-- setup first empty easing at the beginning of the sequence
|
|
||||||
newEasing.timestamp = previousEasing.timestamp + previousEasing.duration
|
|
||||||
newEasing.duration = previousEasing.duration
|
|
||||||
newEasing.fn = previousEasing.fn
|
|
||||||
newEasing.params = previousEasing.params
|
|
||||||
|
|
||||||
if mirror then
|
|
||||||
newEasing.from = previousEasing.to
|
|
||||||
newEasing.to = previousEasing.from
|
|
||||||
else
|
|
||||||
newEasing.from = previousEasing.from
|
|
||||||
newEasing.to = previousEasing.to
|
|
||||||
end
|
|
||||||
|
|
||||||
-- update overall sequence infos
|
|
||||||
self.duration = self.duration + newEasing.duration
|
|
||||||
|
|
||||||
previousEasing = newEasing
|
|
||||||
end
|
|
||||||
|
|
||||||
return self
|
|
||||||
end
|
|
||||||
|
|
||||||
function Sequence:sleep( duration )
|
|
||||||
if not self then return end
|
|
||||||
|
|
||||||
duration = duration or 0.5
|
|
||||||
if duration==0 then
|
|
||||||
return self
|
|
||||||
end
|
|
||||||
|
|
||||||
local lastEasing = self.easings[self.easingCount]
|
|
||||||
local new_easing = self:newEasing()
|
|
||||||
|
|
||||||
-- setup first empty easing at the beginning of the sequence
|
|
||||||
new_easing.timestamp = lastEasing.timestamp + lastEasing.duration
|
|
||||||
new_easing.from = lastEasing.to
|
|
||||||
new_easing.to = lastEasing.to
|
|
||||||
new_easing.duration = duration
|
|
||||||
new_easing.fn = _easings.flat
|
|
||||||
|
|
||||||
-- update overall sequence infos
|
|
||||||
self.duration = self.duration + duration
|
|
||||||
|
|
||||||
return self
|
|
||||||
end
|
|
||||||
|
|
||||||
function Sequence:callback( fn, timeOffset )
|
|
||||||
if not self then return end
|
|
||||||
|
|
||||||
timeOffset = timeOffset or 0
|
|
||||||
|
|
||||||
local lastEasing = self.easings[self.easingCount]
|
|
||||||
|
|
||||||
local cb = self:newCallback()
|
|
||||||
cb.timestamp = lastEasing.timestamp + lastEasing.duration + timeOffset
|
|
||||||
cb.fn = fn
|
|
||||||
|
|
||||||
return self
|
|
||||||
end
|
|
||||||
|
|
||||||
function Sequence:loop()
|
|
||||||
self.loopType = "loop"
|
|
||||||
return self
|
|
||||||
end
|
|
||||||
|
|
||||||
function Sequence:mirror()
|
|
||||||
self.loopType = "mirror"
|
|
||||||
return self
|
|
||||||
end
|
|
||||||
|
|
||||||
function Sequence:newEasing()
|
|
||||||
self.easingCount = self.easingCount + 1
|
|
||||||
return self:getEasingByIndex(self.easingCount)
|
|
||||||
end
|
|
||||||
|
|
||||||
function Sequence:newCallback()
|
|
||||||
local newCallback = {
|
|
||||||
fn = nil,
|
|
||||||
timestamp = nil,
|
|
||||||
}
|
|
||||||
table.insert( self.callbacks, newCallback)
|
|
||||||
return newCallback
|
|
||||||
end
|
|
||||||
|
|
||||||
function Sequence:getEasingByIndex( index )
|
|
||||||
|
|
||||||
local easing = self.easings[index]
|
|
||||||
if type(easing)=="table" then
|
|
||||||
easing.params = nil
|
|
||||||
easing.callback = nil
|
|
||||||
return easing
|
|
||||||
end
|
|
||||||
|
|
||||||
local new_easing = {
|
|
||||||
timestamp = 0,
|
|
||||||
from = 0,
|
|
||||||
to = 0,
|
|
||||||
duration = 0,
|
|
||||||
params = nil,
|
|
||||||
fn = _easings.flat
|
|
||||||
}
|
|
||||||
|
|
||||||
self.easings[index] = new_easing
|
|
||||||
|
|
||||||
return new_easing
|
|
||||||
end
|
|
||||||
|
|
||||||
function Sequence:getEasingByTime( clampedTime )
|
|
||||||
if self:isEmpty() then
|
|
||||||
print("Sequence warning: empty animation")
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
|
|
||||||
local easingIndex = self.previousUpdateEasingIndex or 1
|
|
||||||
|
|
||||||
while easingIndex>=1 and easingIndex<=self.easingCount do
|
|
||||||
local easing = self.easings[easingIndex]
|
|
||||||
|
|
||||||
if clampedTime < easing.timestamp then
|
|
||||||
easingIndex = easingIndex - 1
|
|
||||||
elseif clampedTime > (easing.timestamp+easing.duration) then
|
|
||||||
easingIndex = easingIndex + 1
|
|
||||||
else
|
|
||||||
self.previousUpdateEasingIndex = easingIndex
|
|
||||||
return easing, easingIndex
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- we didn't the correct part
|
|
||||||
print("Sequence warning: couldn't find sequence part. clampedTime probably out of bound.", clampedTime, self.duration)
|
|
||||||
return self.easings[1]
|
|
||||||
end
|
|
||||||
|
|
||||||
function Sequence:get( time )
|
|
||||||
if not self then return nil end
|
|
||||||
|
|
||||||
if self:isEmpty() then
|
|
||||||
return 0
|
|
||||||
end
|
|
||||||
|
|
||||||
time = time or self.time
|
|
||||||
|
|
||||||
-- try to get cached result
|
|
||||||
if self.cachedResultTimestamp==time then
|
|
||||||
return self.cachedResult
|
|
||||||
end
|
|
||||||
|
|
||||||
-- we calculate and cache the result
|
|
||||||
local clampedTime = self:getClampedTime(time)
|
|
||||||
local easing = self:getEasingByTime(clampedTime)
|
|
||||||
local result = easing.fn(clampedTime-easing.timestamp, easing.from, easing.to-easing.from, easing.duration, table.unpack(easing.params or {}))
|
|
||||||
|
|
||||||
-- cache
|
|
||||||
self.cachedResultTimestamp = clampedTime
|
|
||||||
self.cachedResult = result
|
|
||||||
|
|
||||||
return result
|
|
||||||
end
|
|
||||||
|
|
||||||
function Sequence:updateCallbacks( dt )
|
|
||||||
if #self.callbacks==0 then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local callTimeRange = function( clampedStart, clampedEnd)
|
|
||||||
if clampedStart>clampedEnd then
|
|
||||||
clampedStart, clampedEnd = clampedEnd, clampedStart
|
|
||||||
end
|
|
||||||
|
|
||||||
for index, cbObject in pairs(self.callbacks) do
|
|
||||||
if cbObject.timestamp>=clampedStart and cbObject.timestamp<=clampedEnd then
|
|
||||||
if type(cbObject.fn)=="function" then
|
|
||||||
cbObject.fn()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- most straightforward case: no loop
|
|
||||||
if not self.loopType then
|
|
||||||
local clampedTime = self:getClampedTime( self.time )
|
|
||||||
callTimeRange(clampedTime, clampedTime+dt)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
--
|
|
||||||
-- now we handle loops
|
|
||||||
|
|
||||||
-- probably rare case but we have to handle it
|
|
||||||
if dt>self.duration then
|
|
||||||
callTimeRange(0, self.duration)
|
|
||||||
end
|
|
||||||
|
|
||||||
local clampedTime, isForward = self:getClampedTime( self.time )
|
|
||||||
local endTime = clampedTime
|
|
||||||
if isForward then
|
|
||||||
endTime = endTime + dt
|
|
||||||
else
|
|
||||||
endTime = endTime - dt
|
|
||||||
end
|
|
||||||
|
|
||||||
if endTime<0 then
|
|
||||||
callTimeRange(0, math.max(clampedTime, self:getClampedTime( endTime )))
|
|
||||||
elseif endTime>self.duration then
|
|
||||||
if self.loopType=="loop" then
|
|
||||||
callTimeRange(clampedTime, self.duration)
|
|
||||||
callTimeRange(0, self:getClampedTime( endTime ))
|
|
||||||
else
|
|
||||||
callTimeRange(math.min(clampedTime, self:getClampedTime( endTime )), self.duration)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
callTimeRange(clampedTime, endTime)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- get the time clamped in the sequence duration
|
|
||||||
-- manage time using loop setting
|
|
||||||
function Sequence:getClampedTime( time )
|
|
||||||
time = time or self.time
|
|
||||||
|
|
||||||
local isForward = true
|
|
||||||
|
|
||||||
-- time is looped
|
|
||||||
if self.loopType=="loop" then
|
|
||||||
return time%self.duration, isForward
|
|
||||||
|
|
||||||
-- time is mirrored / yoyo
|
|
||||||
elseif self.loopType=="mirror" then
|
|
||||||
time = time%(self.duration*2)
|
|
||||||
if time>self.duration then
|
|
||||||
isForward = false
|
|
||||||
time = self.duration + self.duration - time
|
|
||||||
end
|
|
||||||
|
|
||||||
return time, isForward
|
|
||||||
end
|
|
||||||
|
|
||||||
-- time is normally clamped
|
|
||||||
return math.clamp(time, 0, self.duration), isForward
|
|
||||||
end
|
|
||||||
|
|
||||||
function Sequence:addRunning()
|
|
||||||
if self:isEmpty() or self.isRunning then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
table.insert(_runningSequences, self)
|
|
||||||
self.isRunning = true
|
|
||||||
end
|
|
||||||
|
|
||||||
function Sequence:removeRunning()
|
|
||||||
local indexInRunningTable = table.indexOfElement(_runningSequences, self)
|
|
||||||
if indexInRunningTable then
|
|
||||||
table.remove(_runningSequences, indexInRunningTable)
|
|
||||||
end
|
|
||||||
self.isRunning = false
|
|
||||||
end
|
|
||||||
|
|
||||||
function Sequence:start()
|
|
||||||
self:addRunning()
|
|
||||||
return self
|
|
||||||
end
|
|
||||||
|
|
||||||
function Sequence:stop()
|
|
||||||
self:removeRunning()
|
|
||||||
self.time = 0
|
|
||||||
self.cachedResultTimestamp = nil
|
|
||||||
self.previousUpdateEasingIndex = nil
|
|
||||||
return self
|
|
||||||
end
|
|
||||||
|
|
||||||
function Sequence:pause()
|
|
||||||
self:removeRunning()
|
|
||||||
return self
|
|
||||||
end
|
|
||||||
|
|
||||||
function Sequence:restart()
|
|
||||||
self.time = 0
|
|
||||||
self.cachedResultTimestamp = nil
|
|
||||||
self.previousUpdateEasingIndex = nil
|
|
||||||
self:start()
|
|
||||||
return self
|
|
||||||
end
|
|
||||||
|
|
||||||
function Sequence:isDone()
|
|
||||||
return self.time>=self.duration and (not self.loopType)
|
|
||||||
end
|
|
||||||
|
|
||||||
function Sequence:isEmpty()
|
|
||||||
return self.easingCount==0
|
|
||||||
end
|
|
||||||
|
|
||||||
-- new easing function
|
|
||||||
function _easings.flat(t, b, c, d)
|
|
||||||
return b
|
|
||||||
end
|
|
||||||
|
|
||||||
math.clamp = math.clamp or function(a, min, max)
|
|
||||||
if min > max then
|
|
||||||
min, max = max, min
|
|
||||||
end
|
|
||||||
return math.max(min, math.min(max, a))
|
|
||||||
end
|
|
@ -1,47 +0,0 @@
|
|||||||
--
|
|
||||||
-- Signal library by Dustin Mierau
|
|
||||||
--
|
|
||||||
|
|
||||||
import "CoreLibs/object"
|
|
||||||
|
|
||||||
class("Signal").extends()
|
|
||||||
|
|
||||||
function Signal:init()
|
|
||||||
self.listeners = {}
|
|
||||||
end
|
|
||||||
|
|
||||||
function Signal:add(key, bind, fn)
|
|
||||||
local t = self.listeners[key]
|
|
||||||
local v = {fn = fn, bind = bind}
|
|
||||||
if not t then
|
|
||||||
self.listeners[key] = {v}
|
|
||||||
else
|
|
||||||
t[#t + 1] = v
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function Signal:remove(key, fn)
|
|
||||||
local t = self.listeners[key]
|
|
||||||
if t then
|
|
||||||
for i, v in ipairs(t) do
|
|
||||||
if v.fn == fn then
|
|
||||||
table.remove(t, i)
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if #t == 0 then
|
|
||||||
self.listeners[key] = nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function Signal:dispatch(key, ...)
|
|
||||||
local t = self.listeners[key]
|
|
||||||
if t then
|
|
||||||
for _, v in ipairs(t) do
|
|
||||||
v.fn(v.bind, key, ...)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
Signal = Signal()
|
|
@ -1,293 +0,0 @@
|
|||||||
--- Animation states using a spritesheet/imagetable. Ideal for use with `NobleSprite` objects. Suitable for other uses as well.
|
|
||||||
-- @module Noble.Animation
|
|
||||||
--
|
|
||||||
|
|
||||||
Noble.Animation = {}
|
|
||||||
|
|
||||||
--- Setup
|
|
||||||
-- @section setup
|
|
||||||
|
|
||||||
--- Create a new animation "state machine". This function is called automatically when creating a new `NobleSprite`.
|
|
||||||
-- @string __view This can be: the path to a spritesheet image file or an image table object (`Graphics.imagetable`). See Playdate SDK docs for imagetable file naming conventions.
|
|
||||||
-- @return `animation`, a new animation object.
|
|
||||||
-- @usage
|
|
||||||
-- local myHero = MyHero("path/to/spritesheet")
|
|
||||||
-- @usage
|
|
||||||
-- -- When extending NobleSprite (recommended), you don't call Noble.Animation.new(),
|
|
||||||
-- -- but you do feed its __view argument into MySprite.super.init()...
|
|
||||||
-- MyHero = {}
|
|
||||||
-- class("MyHero").extends(NobleSprite)
|
|
||||||
--
|
|
||||||
-- function MyHero:init()
|
|
||||||
-- MyHero.super.init(self, "assets/images/Hero")
|
|
||||||
-- -- ...
|
|
||||||
-- -- A new NobleSprite creates a Noble.Animation object named "self.animation"
|
|
||||||
-- self.animation:addState("idle", 1, 30)
|
|
||||||
-- self.animation:addState("jump", 31, 34, "float")
|
|
||||||
-- self.animation:addState("float", 35, 45)
|
|
||||||
-- self.animation:addState("turn", 46, 55, "idle")
|
|
||||||
-- self.animation:addState("walk", 56, 65)
|
|
||||||
-- -- ...
|
|
||||||
-- end
|
|
||||||
-- @usage
|
|
||||||
-- local myAnimation = Noble.Animation.new("path/to/spritesheet")
|
|
||||||
-- @usage
|
|
||||||
-- -- When extending playdate.graphics.Sprite, Noble.Animation.new() must be called manually...
|
|
||||||
-- MyHero = {}
|
|
||||||
-- class("MyHero").extends(Graphics.sprite)
|
|
||||||
--
|
|
||||||
-- function MyHero:init()
|
|
||||||
-- MyHero.super.init(self)
|
|
||||||
-- -- ...
|
|
||||||
-- self.animation = Noble.Animation.new("assets/images/Hero")
|
|
||||||
-- self.animation:addState("idle", 1, 30)
|
|
||||||
-- self.animation:addState("jump", 31, 34, "float")
|
|
||||||
-- self.animation:addState("float", 35, 45)
|
|
||||||
-- self.animation:addState("turn", 46, 55, "idle")
|
|
||||||
-- self.animation:addState("walk", 56, 65)
|
|
||||||
-- -- ...
|
|
||||||
-- end
|
|
||||||
-- @see NobleSprite:init
|
|
||||||
function Noble.Animation.new(__view)
|
|
||||||
local animation = {}
|
|
||||||
|
|
||||||
--- Properties
|
|
||||||
-- @section properties
|
|
||||||
|
|
||||||
--- The currently set animation state.
|
|
||||||
--
|
|
||||||
-- This is intended as `read-only`. You should not modify this property directly.
|
|
||||||
-- @see setState
|
|
||||||
animation.current = nil
|
|
||||||
|
|
||||||
--- The name of the current animation state. Calling this instead of `animation.current.name` is <em>just</em> a little faster.
|
|
||||||
--
|
|
||||||
-- This is intended as `read-only`. You should not modify this property directly.
|
|
||||||
animation.currentName = nil
|
|
||||||
|
|
||||||
--- The current frame of the animation. This is the index of the imagetable, not the frame of the current state.
|
|
||||||
--
|
|
||||||
-- Most of the time, you should not modify this directly, although you can if you're feeling saucy and are prepared for unpredictable results.
|
|
||||||
-- @see draw
|
|
||||||
animation.currentFrame = 1
|
|
||||||
|
|
||||||
--- This controls the flipping of the image when drawing. DIRECTION_RIGHT is unflipped, DIRECTION_LEFT is flipped on the X axis.
|
|
||||||
-- @usage
|
|
||||||
-- function MyHero:goLeft()
|
|
||||||
-- self.animation.direction = Noble.Animation.DIRECTION_LEFT
|
|
||||||
-- -- ...
|
|
||||||
-- end
|
|
||||||
animation.direction = Noble.Animation.DIRECTION_RIGHT
|
|
||||||
|
|
||||||
--- This animation's spritesheet. You can replace this with another `playdate.graphics.imagetable` object, but generally you would not want to.
|
|
||||||
-- @see new
|
|
||||||
if (type(__view) == "userdata") then
|
|
||||||
animation.imageTable = __view
|
|
||||||
else
|
|
||||||
animation.imageTable = Graphics.imagetable.new(__view)
|
|
||||||
end
|
|
||||||
-- The current count of frame durations. This is used to determine when to advance to the next frame.
|
|
||||||
animation.frameDurationCount = 1
|
|
||||||
-- The previous number of frame durations in the animation
|
|
||||||
animation.previousFrameDurationCount = 1
|
|
||||||
|
|
||||||
local empty = true
|
|
||||||
|
|
||||||
--- Setup
|
|
||||||
-- @section setup
|
|
||||||
|
|
||||||
--- Add an animation state. The first state added will be the default set for this animation.
|
|
||||||
--
|
|
||||||
-- <strong>NOTE:</strong> Added states are first-degree member objects of your Noble.Animation object, so do not use names of already existing methods/properties ("current", "draw", etc.).
|
|
||||||
-- @string __name The name of the animation, this is also used as the key for the animation.
|
|
||||||
-- @int __startFrame This is the first frame of this animation in the imagetable/spritesheet
|
|
||||||
-- @int __endFrame This is the final frame of this animation in the imagetable/spritesheet
|
|
||||||
-- @string[optional] __next By default, animation states will loop, but if you want to sequence an animation, enter the name of the next state here.
|
|
||||||
-- @bool[opt=true] __loop If you want a state to "freeze" on its final frame, instead of looping, enter `false` here.
|
|
||||||
-- @param[optional] __onComplete This function will run when this animation is complete. Be careful when using this on a looping animation!
|
|
||||||
-- @int[opt=1] __frameDuration This is the number of ticks between each frame in this animation. If not specified, it will be set to 1.
|
|
||||||
-- @usage
|
|
||||||
-- -- You can reference an animation's state's properties using bog-standard lua syntax:
|
|
||||||
--
|
|
||||||
-- animation.idle.startFrame -- 30
|
|
||||||
-- animation.walk.endFrame -- 65
|
|
||||||
-- animation.["walk"].endFrame -- 65
|
|
||||||
-- animation.jump.name -- "jump"
|
|
||||||
-- animation.["jump"].next -- "float"
|
|
||||||
-- animation.idle.next -- nil
|
|
||||||
function animation:addState(__name, __startFrame, __endFrame, __next, __loop, __onComplete, __frameDuration)
|
|
||||||
local loop = true
|
|
||||||
local frameDuration = 1
|
|
||||||
if (__loop ~= nil) then loop = __loop end
|
|
||||||
if (__frameDuration ~= nil) then frameDuration = __frameDuration end
|
|
||||||
self[__name] = {
|
|
||||||
name = __name,
|
|
||||||
startFrame = __startFrame,
|
|
||||||
endFrame = __endFrame,
|
|
||||||
next = __next,
|
|
||||||
loop = loop,
|
|
||||||
onComplete = __onComplete,
|
|
||||||
frameDuration = frameDuration,
|
|
||||||
}
|
|
||||||
|
|
||||||
-- Set this animation state as default if it is the first one added.
|
|
||||||
if (empty == true) then
|
|
||||||
empty = false
|
|
||||||
self.currentFrame = __startFrame
|
|
||||||
self.current = self[__name]
|
|
||||||
self.currentName = __name
|
|
||||||
self.frameDuration = frameDuration
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Methods
|
|
||||||
-- @section methods
|
|
||||||
|
|
||||||
--- Sets the current animation state. This can be run in a object's `update` method because it only changes the animation state if the new state is different from the current one.
|
|
||||||
-- @tparam string|Noble.Animation __animationState The name of the animation to set. You can pass the name of the state, or the object itself.
|
|
||||||
-- @bool[opt=false] __continuous Set to true if your new state's frames line up with the previous one's, i.e.: two walk cycles but one is wearing a cute hat!
|
|
||||||
-- @tparam string|Noble.Animation __unlessThisState If this state is the current state, do not set the new one.
|
|
||||||
-- @usage animation:setState("walk")
|
|
||||||
-- @usage animation:setState(animation.walk)
|
|
||||||
-- @usage
|
|
||||||
-- animation:setState(animation.walkNoHat)
|
|
||||||
-- --
|
|
||||||
-- animation:setState(animation.walkYesHat, true)
|
|
||||||
-- @usage
|
|
||||||
-- function MyHero:update()
|
|
||||||
-- -- Input
|
|
||||||
-- -- ...
|
|
||||||
--
|
|
||||||
-- -- Physics/collisions
|
|
||||||
-- -- ...
|
|
||||||
--
|
|
||||||
-- -- Animation states
|
|
||||||
-- if (grounded) then
|
|
||||||
-- if (turning) then
|
|
||||||
-- self.animation:setState(self.animation.turn)
|
|
||||||
-- elseif (math.abs(self.velocity.x) > 15) then
|
|
||||||
-- self.animation:setState(self.animation.walk, false, self.animation.turn)
|
|
||||||
-- else
|
|
||||||
-- self.animation:setState(self.animation.idle, false, self.animation.turn)
|
|
||||||
-- end
|
|
||||||
-- else
|
|
||||||
-- self.animation:setState(self.animation.jump, false, self.animation.float)
|
|
||||||
-- end
|
|
||||||
--
|
|
||||||
-- groundedLastFrame = grounded
|
|
||||||
-- end
|
|
||||||
function animation:setState(__animationState, __continuous, __unlessThisState)
|
|
||||||
if (__unlessThisState ~= nil) then
|
|
||||||
if (type(__unlessThisState) == "string") then
|
|
||||||
if (self.currentName == __unlessThisState) then return end
|
|
||||||
elseif (type(__unlessThisState) == "table") then
|
|
||||||
if (self.current == __unlessThisState) then return end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local newState = nil
|
|
||||||
|
|
||||||
if (type(__animationState) == "string") then
|
|
||||||
if (self.currentName == __animationState) then return end
|
|
||||||
newState = self[__animationState]
|
|
||||||
self.currentName = __animationState
|
|
||||||
elseif (type(__animationState) == "table") then
|
|
||||||
if (self.current == __animationState) then return end
|
|
||||||
newState = __animationState
|
|
||||||
self.currentName = __animationState.name
|
|
||||||
end
|
|
||||||
|
|
||||||
local continuous = Utilities.handleOptionalBoolean(__continuous, false)
|
|
||||||
|
|
||||||
if (continuous) then
|
|
||||||
local localFrame = self.currentFrame - self.current.startFrame
|
|
||||||
self.currentFrame = newState.startFrame + localFrame
|
|
||||||
else
|
|
||||||
self.currentFrame = newState.startFrame
|
|
||||||
end
|
|
||||||
|
|
||||||
self.current = newState
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Draw the current frame.
|
|
||||||
--
|
|
||||||
-- When attached to a NobleSprite, this is called by `NobleSprite:draw()` when added to a scene. For non-NobleSprite sprites, put this method inside your sprite's `draw()` method, or inside @{NobleScene:update|NobleScene:update}.
|
|
||||||
-- @number[opt=0] __x
|
|
||||||
-- @number[opt=0] __y
|
|
||||||
-- @bool[opt=true] __advance Advances to the next frame after drawing this one. Noble.Animation is frame-based, not "delta time"-based, so its speed is dependent on your game's framerate.
|
|
||||||
-- @usage
|
|
||||||
-- function MySprite:draw()
|
|
||||||
-- animation:draw()
|
|
||||||
-- end
|
|
||||||
-- @usage
|
|
||||||
-- function MyScene:update()
|
|
||||||
-- animation:draw(100,100)
|
|
||||||
-- end
|
|
||||||
function animation:draw(__x, __y, __advance)
|
|
||||||
--print(self.currentName .. " > " .. self.currentFrame .. " >> " .. tostring(self.current.loop))
|
|
||||||
|
|
||||||
if (__advance == nil) then __advance = true end
|
|
||||||
|
|
||||||
if (self.currentFrame < self.current.startFrame or self.currentFrame > self.current.endFrame + 1) then
|
|
||||||
self.currentFrame = self.current.startFrame -- Error correction.
|
|
||||||
elseif (self.currentFrame == self.current.endFrame + 1) then -- End frame behavior.
|
|
||||||
if (self.current.next ~= nil) then
|
|
||||||
self.currentFrame = self.current.next.startFrame -- Set to first frame of next animation.
|
|
||||||
self.frameDurationCount = 1 -- Reset ticks.
|
|
||||||
self.previousFrameDurationCount = self.frameDuration
|
|
||||||
self:setState(self.current.next) -- Set next animation state.
|
|
||||||
elseif (self.current.loop == true) then
|
|
||||||
self.currentFrame = self.current
|
|
||||||
.startFrame -- Loop animation state. (TO-DO: account for continuous somehow?)
|
|
||||||
self.frameDurationCount = 1 -- Reset ticks.
|
|
||||||
self.previousFrameDurationCount = self.frameDuration
|
|
||||||
elseif (__advance) then
|
|
||||||
self.currentFrame = self.currentFrame -
|
|
||||||
1 -- Undo advance frame because we want to draw the same frame again.
|
|
||||||
end
|
|
||||||
|
|
||||||
if (self.current.onComplete ~= nil) then
|
|
||||||
self.current.onComplete()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local x = __x or 0
|
|
||||||
local y = __y or 0
|
|
||||||
self.imageTable:drawImage(self.currentFrame, x, y, self.direction)
|
|
||||||
|
|
||||||
if (__advance == true) then
|
|
||||||
self.frameDurationCount += 1
|
|
||||||
if ((self.frameDurationCount - self.previousFrameDurationCount) >= self.current.frameDuration) then
|
|
||||||
self.currentFrame = self.currentFrame + 1
|
|
||||||
self.previousFrameDurationCount += self.current.frameDuration
|
|
||||||
end
|
|
||||||
end
|
|
||||||
--previousAnimationName = self.currentName
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Sometimes, you just want to draw a specific frame.
|
|
||||||
-- Use this for objects or sprites that you want to control outside of update loops, such as score counters, flipbook-style objects that respond to player input, etc.
|
|
||||||
-- @int __frameNumber The frame to draw from the current state. This is not an imagetable index. Entering `1` will draw the selected state's `startFrame`.
|
|
||||||
-- @string[opt=self.currentName] __stateName The specific state to pull the __frameNumber from.
|
|
||||||
-- @number[opt=0] __x
|
|
||||||
-- @number[opt=0] __y
|
|
||||||
-- @param[opt=self.direction] __direction Override the current direction.
|
|
||||||
function animation:drawFrame(__frameNumber, __stateName, __x, __y, __direction)
|
|
||||||
local x = __x or 0
|
|
||||||
local y = __y or 0
|
|
||||||
local stateName = __stateName or self.currentName
|
|
||||||
local direction = __direction or self.direction
|
|
||||||
local frameNumber = self[stateName].startFrame - 1 + __frameNumber
|
|
||||||
self.imageTable:drawImage(frameNumber, x, y, direction)
|
|
||||||
end
|
|
||||||
|
|
||||||
return animation
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Constants
|
|
||||||
-- @section constants
|
|
||||||
|
|
||||||
--- A re-contextualized instance of `playdate.graphics.kImageUnflipped`
|
|
||||||
Noble.Animation.DIRECTION_RIGHT = Graphics.kImageUnflipped
|
|
||||||
--- A re-contextualized instance of `playdate.graphics.kImageFlippedX`
|
|
||||||
Noble.Animation.DIRECTION_LEFT = Graphics.kImageFlippedX
|
|
@ -1,108 +0,0 @@
|
|||||||
--- Engine-specific error handling.
|
|
||||||
-- Noble Engine overrides/supersedes some Playdate SDK behavior. A "bonk" is what happens when your game breaks the engine.
|
|
||||||
--
|
|
||||||
-- Most bonks will throw during normal operation, but others ("debug bonks") introduce some execution overhead so are not
|
|
||||||
-- checked by default.
|
|
||||||
--
|
|
||||||
-- @module Noble.Bonk
|
|
||||||
--
|
|
||||||
Noble.Bonk = {}
|
|
||||||
|
|
||||||
local bonksAreSetup = false
|
|
||||||
|
|
||||||
local checkingForBonks = false
|
|
||||||
|
|
||||||
local debugBonks = {}
|
|
||||||
|
|
||||||
-- You cannot run this directly. Run Noble.new() with __enableDebugBonkChecking as true to enable debug bonk checking.
|
|
||||||
function Noble.Bonk.enableDebugBonkChecking()
|
|
||||||
if (bonksAreSetup == false) then
|
|
||||||
if (Noble.engineInitialized() == false) then
|
|
||||||
debugBonks.update = playdate.update
|
|
||||||
debugBonks.pause = playdate.gameWillPause
|
|
||||||
debugBonks.resume = playdate.gameWillResume
|
|
||||||
debugBonks.crankDocked = playdate.crankDocked
|
|
||||||
debugBonks.crankUndocked = playdate.crankUndocked
|
|
||||||
bonksAreSetup = true
|
|
||||||
else
|
|
||||||
error("BONK-BONK: You cannot run this directly. Run Noble.new() with __enableDebugBonkChecking as true.")
|
|
||||||
end
|
|
||||||
else
|
|
||||||
print("BONK-BONK: You have already run Noble.new() with __enableDebugBonkChecking as true, you cannot run this directly.")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
--- Begin checking for debug bonks, <strong>on every frame</strong>. This introduces needless overhead, so don't do it in a release build.
|
|
||||||
-- You can only run this if you ran previously `Noble.new()` with `__enableDebugBonkChecking` as true, which you should also not do in a release build.
|
|
||||||
-- @see Noble.new
|
|
||||||
function Noble.Bonk.startCheckingDebugBonks()
|
|
||||||
if (checkingForBonks == false) then
|
|
||||||
if (bonksAreSetup) then
|
|
||||||
checkingForBonks = true
|
|
||||||
else
|
|
||||||
error("BONK-BONK: You cannot run this unless debug bonk checking is enabled.")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Stop checking for debug bonks on every frame.
|
|
||||||
--
|
|
||||||
-- <strong>NOTE: You can only run this if debug bonk checking is enabled.</strong>
|
|
||||||
function Noble.Bonk.stopCheckingDebugBonks()
|
|
||||||
if (checkingForBonks) then
|
|
||||||
if (bonksAreSetup) then
|
|
||||||
checkingForBonks = false
|
|
||||||
else
|
|
||||||
error("BONK-BONK: You cannot run this unless debug bonk checking is enabled.")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Disable the ability to check for debug bonks. It frees up some memory. Once you disable debug bonk checking, you cannot re-enable it.
|
|
||||||
--
|
|
||||||
-- <strong>NOTE: You can only run this if debug bonk checking is enabled.</strong>
|
|
||||||
function Noble.Bonk.disableDebugBonkChecking()
|
|
||||||
if (bonksAreSetup) then
|
|
||||||
debugBonks = {}
|
|
||||||
bonksAreSetup = false
|
|
||||||
else
|
|
||||||
error("BONK-BONK: You cannot run this unless debug bonk checking is enabled.")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Are we debug bonk checking for debug bonks?
|
|
||||||
-- @treturn bool
|
|
||||||
function Noble.Bonk.checkingDebugBonks()
|
|
||||||
return checkingForBonks
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Manually check for debug bonks.
|
|
||||||
-- This method runs every frame when `checkingDebugBonks` is true, but you may call it manually instead.
|
|
||||||
--
|
|
||||||
-- <strong>NOTE: You can only run this if debug bonk checking is enabled.</strong>
|
|
||||||
function Noble.Bonk.checkDebugBonks()
|
|
||||||
|
|
||||||
if (playdate.crankDocked ~= debugBonks.crankDocked) then
|
|
||||||
error("BONK: Don't manually define playdate.crankDocked(). Create a crankDocked() inside of an inputHandler instead.")
|
|
||||||
end
|
|
||||||
if (playdate.crankUndocked ~= debugBonks.crankUndocked) then
|
|
||||||
error("BONK: Don't manually define playdate.crankUndocked(). Create a crankUndocked() inside of an inputHandler instead.")
|
|
||||||
end
|
|
||||||
if (playdate.update ~= debugBonks.update) then
|
|
||||||
error("BONK: Don't manually define playdate.update(). Put update code in your scenes' update() methods instead.")
|
|
||||||
end
|
|
||||||
if (playdate.gameWillPause ~= debugBonks.pause) then
|
|
||||||
error("BONK: Don't manually define playdate.gameWillPause(). Put pause code in your scenes' pause() methods instead.")
|
|
||||||
end
|
|
||||||
if (playdate.gameWillResume ~= debugBonks.resume) then
|
|
||||||
error("BONK: Don't manually define playdate.gameWillResume(). Put resume code in your scenes' resume() methods instead.")
|
|
||||||
end
|
|
||||||
if (Graphics.sprite.getAlwaysRedraw() == false) then
|
|
||||||
error("BONK: Don't use Graphics.sprite.setAlwaysRedraw(false) unless you know what you're doing...")
|
|
||||||
end
|
|
||||||
if (Noble.currentScene.backgroundColor == Graphics.kColorClear) then
|
|
||||||
error("BONK: Don't set a scene's backgroundColor to Graphics.kColorClear, silly.")
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
@ -1,327 +0,0 @@
|
|||||||
--- Operations for game data / save slots.
|
|
||||||
-- @module Noble.GameData
|
|
||||||
--
|
|
||||||
Noble.GameData = {}
|
|
||||||
|
|
||||||
local gameDatas = {} -- This is the actual "GameDatas" object, which holds multiple GameData slots. We keep it local to avoid direct tampering.
|
|
||||||
local gameDataDefault = nil
|
|
||||||
local numberOfGameDataSlotsAtSetup = 1
|
|
||||||
local numberOfSlots = 1
|
|
||||||
local currentSlot = 1 -- This is a helper value, so you don't have to specify a save slot with every GameData operation.
|
|
||||||
|
|
||||||
local function keyChange(__dataDefault, __data)
|
|
||||||
local defaultKeys = {}
|
|
||||||
local keys = {}
|
|
||||||
for key, value in pairs(__dataDefault.data) do
|
|
||||||
table.insert(defaultKeys, key)
|
|
||||||
end
|
|
||||||
for key, value in pairs(__data.data) do
|
|
||||||
table.insert(keys, key)
|
|
||||||
end
|
|
||||||
for i = 1, #keys, 1 do
|
|
||||||
if (defaultKeys[i] ~= keys[i]) then return true end
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
local function exists(__gameDataSlot, __key)
|
|
||||||
-- Check for valid gameSlot.
|
|
||||||
if (__gameDataSlot > #gameDatas or __gameDataSlot <= 0 ) then
|
|
||||||
error("BONK: Game Slot number " .. __gameDataSlot .. " does not exist. Use Noble.GameData.addSlot().", 3)
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
if (__key ~= nil) then
|
|
||||||
-- Check for valid data item.
|
|
||||||
for key, value in pairs(gameDatas[__gameDataSlot].data) do
|
|
||||||
if __key == key then
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
error("BONK: Game Datum \"" .. __key .. "\" does not exist. Maybe you spellet it wronlgly.", 3)
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
local function updateTimestamp(__gameData)
|
|
||||||
__gameData.timestamp = playdate.getGMTTime()
|
|
||||||
end
|
|
||||||
|
|
||||||
local gameDataHasBeenSetup = false
|
|
||||||
|
|
||||||
--- Sets up the GameDatas (save slots) for your game, and/or loads any existing GameDatas from disk.
|
|
||||||
-- You can only run this once, ideally in your main.lua before you load your first scene.
|
|
||||||
-- @tparam table __keyValuePairs All the data items for a saved game, and their default values, as key/value pairs. <strong>NOTE:</strong> Do not use "nil" as a value.
|
|
||||||
-- @int[opt=1] __numberOfSlots If you want multiple save slots, enter an integer here. You can add additional slots later.
|
|
||||||
-- @bool[opt=true] __saveToDisk Saves your default values immediately to disk.
|
|
||||||
-- @bool[opt=true] __modifyExistingOnKeyChange Updates the existing gameData objects on disk if you make changes to your keys (not values) during development or when updating your game.
|
|
||||||
-- @usage
|
|
||||||
-- Noble.GameData.setup(
|
|
||||||
-- {
|
|
||||||
-- name = "",
|
|
||||||
-- checkpointReached = 0,
|
|
||||||
-- score = 0
|
|
||||||
-- },
|
|
||||||
-- 3,
|
|
||||||
-- true,
|
|
||||||
-- true
|
|
||||||
-- )
|
|
||||||
-- Noble.GameData.set("name", "Game A", 1)
|
|
||||||
-- Noble.GameData.set("name", "Game B", 2)
|
|
||||||
-- Noble.GameData.set("name", "Game C", 3)
|
|
||||||
-- @see addSlot
|
|
||||||
-- @see deleteSlot
|
|
||||||
function Noble.GameData.setup(__keyValuePairs, __numberOfSlots, __saveToDisk, __modifyExistingOnKeyChange)
|
|
||||||
if (gameDataHasBeenSetup) then
|
|
||||||
error("BONK: You can only run Noble.GameData.setup() once.")
|
|
||||||
return
|
|
||||||
else
|
|
||||||
gameDataHasBeenSetup = true
|
|
||||||
end
|
|
||||||
|
|
||||||
numberOfSlots = __numberOfSlots or numberOfSlots
|
|
||||||
numberOfGameDataSlotsAtSetup = numberOfSlots
|
|
||||||
|
|
||||||
local saveToDisk = Utilities.handleOptionalBoolean(__saveToDisk, true)
|
|
||||||
local modifyExistingOnKeyChange = Utilities.handleOptionalBoolean(__modifyExistingOnKeyChange, true)
|
|
||||||
|
|
||||||
gameDataDefault = {
|
|
||||||
data = __keyValuePairs,
|
|
||||||
timestamp = playdate.getGMTTime()
|
|
||||||
}
|
|
||||||
|
|
||||||
local createdNewData = false
|
|
||||||
|
|
||||||
-- Noble Engine checks on disk for GameDatas, including ones that were
|
|
||||||
-- added with addSlot, but it assumes your game will have no greater than 1000 of them.
|
|
||||||
for i = 1, 1000, 1 do
|
|
||||||
-- We use a local here to avoid adding a nil item to the gameDatas table.
|
|
||||||
local gameData = Datastore.read("Game" .. i)
|
|
||||||
|
|
||||||
if (gameData == nil) then
|
|
||||||
if (i <= numberOfSlots) then
|
|
||||||
-- No gameData on disk, so we create a new ones using default values
|
|
||||||
-- up to the numberOfGameDataSlots.
|
|
||||||
gameDatas[i] = table.deepcopy(gameDataDefault)
|
|
||||||
createdNewData = true
|
|
||||||
else
|
|
||||||
-- We can't find any more GameDatas on disk, so we update the
|
|
||||||
-- value of numberOfGameDataSlots if necessary and get outta town!
|
|
||||||
numberOfSlots = i - 1
|
|
||||||
print("Total number of game slots: " .. numberOfSlots)
|
|
||||||
|
|
||||||
if (saveToDisk and createdNewData) then
|
|
||||||
Noble.GameData.saveAll()
|
|
||||||
end
|
|
||||||
|
|
||||||
return -- This is our only way out!
|
|
||||||
end
|
|
||||||
else
|
|
||||||
-- We found a gameData on disk, so we use it (either as-is or modified by a key change).
|
|
||||||
if (modifyExistingOnKeyChange and keyChange(gameDataDefault, gameData)) then
|
|
||||||
-- Found gameData on disk, but key changes have been made...
|
|
||||||
-- ...so we start with a new one, with default values...
|
|
||||||
local existingGameData = table.deepcopy(gameData)
|
|
||||||
gameData = table.deepcopy(gameDataDefault)
|
|
||||||
for key, _ in pairs(gameData.data) do
|
|
||||||
-- ...then copy data with unchanged keys to the new object,
|
|
||||||
-- naturally discarding keys that don't exist anymore.
|
|
||||||
if (existingGameData.data[key] ~= nil) then gameData.data[key] = existingGameData.data[key] end
|
|
||||||
end
|
|
||||||
gameDatas.timestamp = existingGameData.timestamp
|
|
||||||
createdNewData = true
|
|
||||||
end
|
|
||||||
gameDatas[i] = gameData
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Returns the value of the requested data item.
|
|
||||||
-- @string __dataItemName The name of the data item.
|
|
||||||
-- @int[opt] __gameDataSlot If set, uses a specific GameData slot. If not, uses the most recently touched GameData slot.
|
|
||||||
-- @treturn any
|
|
||||||
-- @usage Noble.GameData.get("equippedItem")
|
|
||||||
-- @usage Noble.GameData.get("equippedItem", 2)
|
|
||||||
function Noble.GameData.get(__dataItemName, __gameDataSlot)
|
|
||||||
currentSlot = __gameDataSlot or currentSlot
|
|
||||||
if (exists(currentSlot, __dataItemName)) then
|
|
||||||
return gameDatas[currentSlot].data[__dataItemName]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Set the value of a GameData item.
|
|
||||||
-- @string __dataItemName The name of the data item.
|
|
||||||
-- @tparam any __value The data item's new value
|
|
||||||
-- @int[opt] __gameDataSlot If set, uses a specific GameData slot. If not, uses the most recently touched GameData slot.
|
|
||||||
-- @bool[opt=true] __saveToDisk Saves to disk immediately. Set to false if you prefer to manually save (via a checkpoint or menu).
|
|
||||||
-- @bool[opt=true] __updateTimestamp Sets the timestamp of this GameData to the current time. Leave false to retain existing timestamp.
|
|
||||||
-- @usage Noble.GameData.set("score", 74205)
|
|
||||||
-- @usage Noble.GameData.set("score", Noble.GameData.get("score") + 100)
|
|
||||||
-- @see save
|
|
||||||
function Noble.GameData.set(__dataItemName, __value, __gameDataSlot, __saveToDisk, __updateTimestamp)
|
|
||||||
currentSlot = __gameDataSlot or currentSlot
|
|
||||||
if (exists(currentSlot, __dataItemName)) then
|
|
||||||
gameDatas[currentSlot].data[__dataItemName] = __value
|
|
||||||
local setTimestamp = Utilities.handleOptionalBoolean(__updateTimestamp, true)
|
|
||||||
if (setTimestamp) then updateTimestamp(gameDatas[currentSlot]) end
|
|
||||||
local saveToDisk = Utilities.handleOptionalBoolean(__saveToDisk, true)
|
|
||||||
if (saveToDisk) then Noble.GameData.save() end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Reset a GameData item to its default value, defined in @{setup|setup}.
|
|
||||||
-- @string __dataItemName The name of the data item.
|
|
||||||
-- @int[opt] __gameDataSlot If set, uses a specific GameData slot. If not, uses the most recently touched GameData slot.
|
|
||||||
-- @bool[opt=true] __saveToDisk Saves to disk immediately. Set to false if you prefer to manually save (via a checkpoint or menu).
|
|
||||||
-- @bool[opt=true] __updateTimestamp Resets the timestamp of this GameData to the current time. Leave false to retain existing timestamp.
|
|
||||||
-- @see save
|
|
||||||
function Noble.GameData.reset(__dataItemName, __gameDataSlot, __saveToDisk, __updateTimestamp)
|
|
||||||
currentSlot = __gameDataSlot or currentSlot
|
|
||||||
if (exists(currentSlot, __dataItemName)) then
|
|
||||||
gameDatas[currentSlot].data[__dataItemName] = gameDataDefault.data[__dataItemName]
|
|
||||||
local setTimestamp = Utilities.handleOptionalBoolean(__updateTimestamp, true)
|
|
||||||
if (setTimestamp) then updateTimestamp(gameDatas[currentSlot]) end
|
|
||||||
local saveToDisk = Utilities.handleOptionalBoolean(__saveToDisk, true)
|
|
||||||
if (saveToDisk) then Noble.GameData.save(currentSlot) end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Reset all values in a GameData slot to the default values, defined in @{setup|setup}.
|
|
||||||
-- @int[opt] __gameDataSlot If set, uses a specific GameData slot. If not, uses the most recently touched GameData slot.
|
|
||||||
-- @bool[opt=true] __saveToDisk Saves to disk immediately. Set to false if you prefer to manually save (via a checkpoint or menu).
|
|
||||||
-- @bool[opt=true] __updateTimestamp Resets the timestamp of this GameData to the current time. Leave false to retain existing timestamp.
|
|
||||||
-- @see save
|
|
||||||
function Noble.GameData.resetAll(__gameDataSlot, __saveToDisk, __updateTimestamp)
|
|
||||||
currentSlot = __gameDataSlot or currentSlot
|
|
||||||
for key, _ in pairs(gameDatas[currentSlot].data) do
|
|
||||||
gameDatas[currentSlot].data[key] = gameDataDefault.data[key]
|
|
||||||
end
|
|
||||||
local setTimestamp = Utilities.handleOptionalBoolean(__updateTimestamp, true)
|
|
||||||
if (setTimestamp) then updateTimestamp(gameDatas[currentSlot]) end
|
|
||||||
local saveToDisk = Utilities.handleOptionalBoolean(__saveToDisk, true)
|
|
||||||
if (saveToDisk) then Noble.GameData.save(currentSlot) end
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Add a save slot to your game. This is useful for games which have arbitrary save slots, or encourage save scumming.
|
|
||||||
-- @int[opt=1] __numberToAdd What it says on the tin.
|
|
||||||
-- @bool[opt=true] __saveToDisk Saves to disk immediately. Set to false if you prefer to manually save (via a checkpoint or menu).
|
|
||||||
-- @usage Noble.GameData.addSlot()
|
|
||||||
-- @usage Noble.GameData.addSlot(10)
|
|
||||||
function Noble.GameData.addSlot(__numberToAdd, __saveToDisk)
|
|
||||||
local numberToAdd = __numberToAdd or 1
|
|
||||||
local saveToDisk = Utilities.handleOptionalBoolean(__saveToDisk, true)
|
|
||||||
if (__numberToAdd < 1) then error ("BONK: Don't use a number smaller than 1, silly.", 2) return end
|
|
||||||
for i = 1, numberToAdd, 1 do
|
|
||||||
local newGameData = table.deepcopy(gameDataDefault)
|
|
||||||
updateTimestamp(newGameData)
|
|
||||||
table.insert(gameDatas, newGameData)
|
|
||||||
if (saveToDisk) then Noble.GameData.save() end
|
|
||||||
end
|
|
||||||
numberOfSlots = numberOfSlots + numberToAdd
|
|
||||||
print("Added " .. numberToAdd .. " GameData slots. Total GameData slots: " .. numberOfSlots)
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Deletes a GameData from disk if its save slot is greater than the default number established in `setup`.
|
|
||||||
-- Otherwise, resets all data items to default values using @{resetAll|resetAll}.
|
|
||||||
--
|
|
||||||
-- Generally, you won't need this unless you've added save slots using @{addSlot|addSlot}. In other cases, use @{resetAll|resetAll}.
|
|
||||||
-- @int __gameDataSlot The slot holding the GameData to delete. Unlike other methods that take this argument, this is not optional.
|
|
||||||
-- @bool[opt=true] __collapseGameDatas Re-sorts the gameDatas table (and renames existing JSON files on disk) to fill the gap left by the deleted GameData.
|
|
||||||
-- @see deleteAllSlots
|
|
||||||
-- @see addSlot
|
|
||||||
-- @see resetAll
|
|
||||||
-- @usage Noble.GameData.deleteSlot(6)
|
|
||||||
-- @usage Noble.GameData.deleteSlot(15, false)
|
|
||||||
function Noble.GameData.deleteSlot(__gameDataSlot, __collapseGameDatas)
|
|
||||||
if (__gameDataSlot == nil) then
|
|
||||||
error("BONK: You must specify a GameData slot to delete.")
|
|
||||||
end
|
|
||||||
local collapseGameDatas = Utilities.handleOptionalBoolean(__collapseGameDatas, true)
|
|
||||||
if (exists(__gameDataSlot)) then
|
|
||||||
if (__gameDataSlot > numberOfGameDataSlotsAtSetup) then
|
|
||||||
-- If this GameData is not one of the default ones from setup(), it is removed from disk.
|
|
||||||
if (playdate.file.exists("Game" .. __gameDataSlot)) then
|
|
||||||
gameDatas[__gameDataSlot] = nil -- Clear from memory.
|
|
||||||
Datastore.delete("Game" .. __gameDataSlot) -- Clear from disk.
|
|
||||||
if (currentSlot == __gameDataSlot) then currentSlot = 1 end -- Safety!
|
|
||||||
if (collapseGameDatas) then
|
|
||||||
-- Collapse GameDatas
|
|
||||||
local newGameDatas = {}
|
|
||||||
for i = 1, numberOfSlots do
|
|
||||||
if(gameDatas[i] ~= nil) then
|
|
||||||
table.insert(newGameDatas, gameDatas[i])
|
|
||||||
if (i >= __gameDataSlot) then
|
|
||||||
playdate.file.rename("Game" .. __gameDataSlot, "Game" .. __gameDataSlot-1)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
gameDatas = newGameDatas
|
|
||||||
numberOfSlots = numberOfSlots - 1
|
|
||||||
end
|
|
||||||
else
|
|
||||||
error("BONK: This GameData is in memory, but its file doesn't exist on disk, so it can't be deleted.", 2)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
-- If this GameData is one of the default ones from setup(), it is reset to default values.
|
|
||||||
Noble.GameData.resetAll(__gameDataSlot)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Deletes all GameDatas from disk, except for the number specified in setup, which are reset to default values.
|
|
||||||
-- Use this to clear all data as if you were running setup again.
|
|
||||||
-- Generally, you don't need this unless you've added save slots using @{addSlot|addSlot}. In other cases, use @{resetAll|resetAll} on each slot.
|
|
||||||
-- @see deleteSlot
|
|
||||||
-- @see addSlot
|
|
||||||
function Noble.GameData.deleteAllSlots()
|
|
||||||
local numberToDelete = numberOfSlots
|
|
||||||
for i = numberToDelete, 1, -1 do
|
|
||||||
Noble.GameData.deleteSlot(i, false) -- Don't need to collapse the table because we're deleting them in reverse order.
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Returns the timestamp of the requested GameData, as a tuple (local time, GMT time). The timestamp is updated
|
|
||||||
-- See Playdate SDK for details on how a time object is formatted. <strong>NOTE: Timestamps are stored internally in GMT.</strong>
|
|
||||||
-- @int __gameDataSlot The GameData slot to get the timestamp of. Unlike other methods that take this argument, this is not optional.
|
|
||||||
-- @treturn table Local time
|
|
||||||
-- @treturn table GMT time
|
|
||||||
-- @usage Noble.GameData.getTimestamp(1)
|
|
||||||
function Noble.GameData.getTimestamp(__gameDataSlot)
|
|
||||||
if (exists(__gameDataSlot)) then
|
|
||||||
return playdate.timeFromEpoch(playdate.epochFromGMTTime(gameDatas[__gameDataSlot].timestamp)), gameDatas[__gameDataSlot].timestamp
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Returns the current number of GameData slots.
|
|
||||||
-- @treturn int
|
|
||||||
function Noble.GameData.getNumberOfSlots() return numberOfSlots end
|
|
||||||
|
|
||||||
--- Returns the number of the current GameData slot.
|
|
||||||
-- @treturn int
|
|
||||||
function Noble.GameData.getCurrentSlot() return currentSlot end
|
|
||||||
|
|
||||||
--- Saves a single GameData to disk. If you want to save all GameDatas, use @{saveAll|saveAll} instead.
|
|
||||||
-- @int[opt] __gameDataSlot If set, uses a specific GameData slot. If not, uses the most recently touched GameData slot.
|
|
||||||
-- @see saveAll
|
|
||||||
-- @usage Noble.GameData.save()
|
|
||||||
-- @usage Noble.GameData.save(3)
|
|
||||||
function Noble.GameData.save(__gameDataSlot)
|
|
||||||
local gameDataSlot = __gameDataSlot or currentSlot
|
|
||||||
if (exists(gameDataSlot)) then
|
|
||||||
currentSlot = gameDataSlot
|
|
||||||
Datastore.write(gameDatas[currentSlot], "Game" .. currentSlot)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Save all GameDatas to disk. If you only have one, or want to save a specific one, use @{save|save} instead.
|
|
||||||
-- @see save
|
|
||||||
function Noble.GameData.saveAll()
|
|
||||||
for i = 1, numberOfSlots, 1 do
|
|
||||||
Datastore.write(gameDatas[i], "Game" .. currentSlot)
|
|
||||||
end
|
|
||||||
end
|
|
@ -1,333 +0,0 @@
|
|||||||
--- A complete encapsulation of the Playdate's input system. The Playdate SDK gives developers multiple ways to manage input. Noble Engine's approach revolves around the SDK's "inputHandlers," extending them to include additional input methods, and pull in other hardware functions that the SDK puts elsewhere. See usage below for the full list of supported methods.
|
|
||||||
-- <br><br>By default, Noble Engine assumes each scene will have an inputManager assigned to it. So, for example, you can define one inputManager for menu screens and another for gameplay scenes in your `main.lua`, and then in each scene, set which one that scene uses. You can instead define a unique inputHandler in each scene.
|
|
||||||
-- <br><br>You may also create and manage inputManagers within and outside of scenes. When a NobleScene is loaded, its inputHandler will become active, thus, inputHandlers do not carry across scenes, and all input is suspended during scene transitions. An advanced use-case is to leave a scene's inputHandler as nil, and manage it separately.
|
|
||||||
-- <br><br><strong>NOTE:</strong> While the Playdate SDK allows you to stack as many inputHandlers as you want, Noble Engine assumes only one <em>active</em> inputHandler at a time. You may still manually call `playdate.inputHandlers.push()` and `playdate.inputHandlers.pop()` yourself, but Noble Engine will not know about it and it may cause unexpected behavior.
|
|
||||||
-- <br><br>In addition, you may directly query button status using the SDK's methods for that, but it is not advised to use that as the primary way to manage input for Noble Engine projects, because much of Noble.Input's functionality will not apply.
|
|
||||||
-- @module Noble.Input
|
|
||||||
-- @usage
|
|
||||||
-- local myInputHandler = {
|
|
||||||
-- AButtonDown = function() end, -- Fires once when button is pressed down.
|
|
||||||
-- AButtonHold = function() end, -- Fires each frame while a button is held (Noble Engine implementation).
|
|
||||||
-- AButtonHeld = function() end, -- Fires once after button is held for 1 second (available for A and B).
|
|
||||||
-- AButtonUp = function() end, -- Fires once when button is released.
|
|
||||||
-- BButtonDown = function() end,
|
|
||||||
-- BButtonHold = function() end,
|
|
||||||
-- BButtonHeld = function() end,
|
|
||||||
-- BButtonUp = function() end,
|
|
||||||
-- downButtonDown = function() end,
|
|
||||||
-- downButtonHold = function() end,
|
|
||||||
-- downButtonUp = function() end,
|
|
||||||
-- leftButtonDown = function() end,
|
|
||||||
-- leftButtonHold = function() end,
|
|
||||||
-- leftButtonUp = function() end,
|
|
||||||
-- rightButtonDown = function() end,
|
|
||||||
-- rightButtonHold = function() end,
|
|
||||||
-- rightButtonUp = function() end,
|
|
||||||
-- upButtonDown = function() end,
|
|
||||||
-- upButtonHold = function() end
|
|
||||||
-- upButtonUp = function() end,
|
|
||||||
--
|
|
||||||
-- cranked = function(change, acceleratedChange) end, -- See Playdate SDK.
|
|
||||||
-- crankDocked = function() end, -- Noble Engine implementation.
|
|
||||||
-- crankUndocked = function() end, -- Noble Engine implementation.
|
|
||||||
--
|
|
||||||
-- orientationChanged = function() end -- Noble Engine implementation.
|
|
||||||
-- }
|
|
||||||
-- @see NobleScene.inputHandler
|
|
||||||
--
|
|
||||||
Noble.Input = {}
|
|
||||||
|
|
||||||
local currentHandler = {}
|
|
||||||
|
|
||||||
--- Get the currently active input handler. Returns nil if none are active.
|
|
||||||
-- @treturn table A table of callbacks which handle input events.
|
|
||||||
-- @see NobleScene.inputHandler
|
|
||||||
function Noble.Input.getHandler()
|
|
||||||
return currentHandler
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Use this to change the active inputHandler.
|
|
||||||
-- <br><br>Enter `nil` to disable input. Use @{setEnabled} to disable/enable input without losing track of the current inputHandler.
|
|
||||||
-- @tparam[opt=nil] table __inputHandler A table of callbacks which handle input events.
|
|
||||||
-- @see NobleScene.inputHandler
|
|
||||||
-- @see clearHandler
|
|
||||||
-- @see setEnabled
|
|
||||||
function Noble.Input.setHandler(__inputHandler)
|
|
||||||
if (currentHandler ~= nil) then
|
|
||||||
playdate.inputHandlers.pop()
|
|
||||||
end
|
|
||||||
|
|
||||||
if (__inputHandler == nil) then
|
|
||||||
currentHandler = nil
|
|
||||||
else
|
|
||||||
currentHandler = __inputHandler
|
|
||||||
playdate.inputHandlers.push(__inputHandler, true) -- The Playdate SDK allows for multiple inputHandlers to mix and match methods. Noble Engine removes this functionality.
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--- A helper function that calls Noble.Input.setHandler() with no argument.
|
|
||||||
-- @see setHandler
|
|
||||||
function Noble.Input.clearHandler()
|
|
||||||
Noble.Input.setHandler()
|
|
||||||
end
|
|
||||||
|
|
||||||
local cachedInputHandler = nil
|
|
||||||
|
|
||||||
--- Enable and disable user input without dealing with inputHanders.
|
|
||||||
-- The Playdate SDK requires removing all inputHanders to halt user input, so while the currentHandler is cleared when `false` is passed to this method,
|
|
||||||
-- it is cached so it can be later re-enabled by passing `true` it.
|
|
||||||
-- @bool __value Set to false to halt input. Set to true to resume accepting input.
|
|
||||||
-- @see getHandler
|
|
||||||
-- @see clearHandler
|
|
||||||
function Noble.Input.setEnabled(__value)
|
|
||||||
local value = Utilities.handleOptionalBoolean(__value, true)
|
|
||||||
if (value == true) then
|
|
||||||
Noble.Input.setHandler(cachedInputHandler or currentHandler)
|
|
||||||
cachedInputHandler = nil
|
|
||||||
else
|
|
||||||
cachedInputHandler = currentHandler
|
|
||||||
Noble.Input.clearHandler()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Checks to see that there is an active inputHandler
|
|
||||||
-- @treturn bool Returns true if the input system is enabled. Returns false if `setEnabled(false)` was used, or if currentHandler is `nil`.
|
|
||||||
function Noble.Input.getEnabled()
|
|
||||||
return cachedInputHandler == nil
|
|
||||||
end
|
|
||||||
|
|
||||||
local crankIndicatorActive = false
|
|
||||||
local crankIndicatorForced = false
|
|
||||||
|
|
||||||
--- Enable/disable on-screen system crank indicator.
|
|
||||||
--
|
|
||||||
-- <strong>NOTE: The indicator will only ever show if the crank is docked, unless `__evenWhenUndocked` is true.</strong>
|
|
||||||
-- @bool __active Set true to start showing the on-screen crank indicator. Set false to stop showing it.
|
|
||||||
-- @bool[opt=false] __evenWhenUndocked Set true to show the crank indicator even if the crank is already undocked (`__active` must also be true).
|
|
||||||
function Noble.Input.setCrankIndicatorStatus(__active, __evenWhenUndocked)
|
|
||||||
if (__active) then
|
|
||||||
UI.crankIndicator:start()
|
|
||||||
end
|
|
||||||
crankIndicatorActive = __active
|
|
||||||
crankIndicatorForced = Utilities.handleOptionalBoolean(__evenWhenUndocked, false)
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Checks whether the system crank indicator status. Returns a tuple.
|
|
||||||
--
|
|
||||||
-- @treturn bool Is the crank indicator active?
|
|
||||||
-- @treturn bool Is the crank indicator being forced when active, even when the crank is undocked?
|
|
||||||
-- @see setCrankIndicatorStatus
|
|
||||||
function Noble.Input.getCrankIndicatorStatus()
|
|
||||||
return crankIndicatorActive, crankIndicatorForced
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Noble Engine defines extra "buttonHold" methods that run every frame that a button is held down, but to implement them, we need to do some magic.
|
|
||||||
local buttonHoldBufferAmount = 3 -- This is how many frames to wait before the engine determines that a button is being held down. Using !buttonJustPressed() provides only 1 frame, which isn't enough.
|
|
||||||
|
|
||||||
local AButtonHoldBufferCount = 0
|
|
||||||
local BButtonHoldBufferCount = 0
|
|
||||||
local upButtonHoldBufferCount = 0
|
|
||||||
local downButtonHoldBufferCount = 0
|
|
||||||
local leftButtonHoldBufferCount = 0
|
|
||||||
local rightButtonHoldBufferCount = 0
|
|
||||||
|
|
||||||
-- Store the latest orientation in order to know when to run the orientationChanged callback
|
|
||||||
local orientation = nil
|
|
||||||
local accelerometerValues = nil
|
|
||||||
|
|
||||||
--- Checks the current display orientation of the device. Returns a tuple.
|
|
||||||
-- If the accelerometer is not currently enabled, this method will turn it on, return current values, and then turn it off.
|
|
||||||
-- If you are trying to get raw accelerometer values rather than the display orientation, you may want to use `playdate.readAccelerometer()` instead.
|
|
||||||
-- @bool[opt=false] __getStoredValues If true, this method will simply return the most recently stored values, rather than use the accelerometer to check for new ones.
|
|
||||||
-- @treturn str The named orientation of the device (a pseudo enum Noble.Input.ORIENTATION_XX)
|
|
||||||
-- @treturn list Accelerometer values, where list[1] is x, list[2] is y and list[3] is z
|
|
||||||
-- @see Noble.Input.ORIENTATION_UP
|
|
||||||
-- @see Noble.Input.ORIENTATION_DOWN
|
|
||||||
-- @see Noble.Input.ORIENTATION_LEFT
|
|
||||||
-- @see Noble.Input.ORIENTATION_RIGHT
|
|
||||||
function Noble.Input.getOrientation(__getStoredValues)
|
|
||||||
|
|
||||||
local getStoredValues = Utilities.handleOptionalBoolean(__getStoredValues, false)
|
|
||||||
if (not getStoredValues) then
|
|
||||||
|
|
||||||
local turnOffAfterUse = false
|
|
||||||
if (not playdate.accelerometerIsRunning()) then
|
|
||||||
playdate.startAccelerometer()
|
|
||||||
turnOffAfterUse = true
|
|
||||||
end
|
|
||||||
|
|
||||||
local x, y, z = playdate.readAccelerometer()
|
|
||||||
|
|
||||||
if (turnOffAfterUse) then
|
|
||||||
playdate.stopAccelerometer()
|
|
||||||
end
|
|
||||||
|
|
||||||
local newOrientation = nil
|
|
||||||
|
|
||||||
if (x <= -0.7) then
|
|
||||||
newOrientation = Noble.Input.ORIENTATION_LEFT
|
|
||||||
elseif (x >= 0.7) then
|
|
||||||
newOrientation = Noble.Input.ORIENTATION_RIGHT
|
|
||||||
elseif (y <= -0.3) then
|
|
||||||
newOrientation = Noble.Input.ORIENTATION_DOWN
|
|
||||||
else
|
|
||||||
newOrientation = Noble.Input.ORIENTATION_UP
|
|
||||||
end
|
|
||||||
|
|
||||||
accelerometerValues = {x, y, z}
|
|
||||||
|
|
||||||
if (newOrientation ~= orientation) then
|
|
||||||
if (currentHandler.orientationChanged ~= nil) then
|
|
||||||
currentHandler.orientationChanged(orientation, accelerometerValues)
|
|
||||||
end
|
|
||||||
orientation = newOrientation
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return orientation, accelerometerValues
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Do not call this method directly, or modify it, thanks. :-)
|
|
||||||
function Noble.Input.update()
|
|
||||||
|
|
||||||
if (currentHandler == nil) then return end
|
|
||||||
|
|
||||||
if (currentHandler.AButtonHold ~= nil) then
|
|
||||||
if (playdate.buttonIsPressed(playdate.kButtonA)) then
|
|
||||||
if (AButtonHoldBufferCount >= buttonHoldBufferAmount) then currentHandler.AButtonHold(AButtonHoldBufferCount) end -- Execute!
|
|
||||||
AButtonHoldBufferCount = AButtonHoldBufferCount + 1 -- Wait another frame!
|
|
||||||
end
|
|
||||||
if (playdate.buttonJustReleased(playdate.kButtonA)) then AButtonHoldBufferCount = 0 end -- Reset!
|
|
||||||
end
|
|
||||||
if (currentHandler.BButtonHold ~= nil) then
|
|
||||||
if (playdate.buttonIsPressed(playdate.kButtonB)) then
|
|
||||||
if (BButtonHoldBufferCount >= buttonHoldBufferAmount) then currentHandler.BButtonHold(BButtonHoldBufferCount) end
|
|
||||||
BButtonHoldBufferCount = BButtonHoldBufferCount + 1
|
|
||||||
end
|
|
||||||
if (playdate.buttonJustReleased(playdate.kButtonB)) then BButtonHoldBufferCount = 0 end
|
|
||||||
end
|
|
||||||
if (currentHandler.upButtonHold ~= nil) then
|
|
||||||
if (playdate.buttonIsPressed(playdate.kButtonUp)) then
|
|
||||||
if (upButtonHoldBufferCount >= buttonHoldBufferAmount) then currentHandler.upButtonHold(upButtonHoldBufferCount) end
|
|
||||||
upButtonHoldBufferCount = upButtonHoldBufferCount + 1
|
|
||||||
end
|
|
||||||
if (playdate.buttonJustReleased(playdate.kButtonUp)) then upButtonHoldBufferCount = 0 end
|
|
||||||
end
|
|
||||||
if (currentHandler.downButtonHold ~= nil) then
|
|
||||||
if (playdate.buttonIsPressed(playdate.kButtonDown)) then
|
|
||||||
if (downButtonHoldBufferCount >= buttonHoldBufferAmount) then currentHandler.downButtonHold(downButtonHoldBufferCount) end
|
|
||||||
downButtonHoldBufferCount = downButtonHoldBufferCount + 1
|
|
||||||
end
|
|
||||||
if (playdate.buttonJustReleased(playdate.kButtonDown)) then downButtonHoldBufferCount = 0 end
|
|
||||||
end
|
|
||||||
if (currentHandler.leftButtonHold ~= nil) then
|
|
||||||
if (playdate.buttonIsPressed(playdate.kButtonLeft)) then
|
|
||||||
if (leftButtonHoldBufferCount >= buttonHoldBufferAmount) then currentHandler.leftButtonHold(leftButtonHoldBufferCount) end
|
|
||||||
leftButtonHoldBufferCount = leftButtonHoldBufferCount + 1
|
|
||||||
end
|
|
||||||
if (playdate.buttonJustReleased(playdate.kButtonLeft)) then leftButtonHoldBufferCount = 0 end
|
|
||||||
end
|
|
||||||
if (currentHandler.rightButtonHold ~= nil) then
|
|
||||||
if (playdate.buttonIsPressed(playdate.kButtonRight)) then
|
|
||||||
if (rightButtonHoldBufferCount >= buttonHoldBufferAmount) then currentHandler.rightButtonHold(rightButtonHoldBufferCount) end
|
|
||||||
rightButtonHoldBufferCount = rightButtonHoldBufferCount + 1
|
|
||||||
end
|
|
||||||
if (playdate.buttonJustReleased(playdate.kButtonRight)) then rightButtonHoldBufferCount = 0 end
|
|
||||||
end
|
|
||||||
if (playdate.accelerometerIsRunning()) then
|
|
||||||
Noble.Input.getOrientation()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Do not call this method directly, or modify it, thanks. :-)
|
|
||||||
function playdate.crankDocked()
|
|
||||||
if (currentHandler ~= nil and currentHandler.crankDocked ~= nil and Noble.Input.getEnabled() == true) then
|
|
||||||
currentHandler.crankDocked()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Do not call this method directly, or modify it, thanks. :-)
|
|
||||||
function playdate.crankUndocked()
|
|
||||||
if (currentHandler ~= nil and currentHandler.crankUndocked ~= nil and Noble.Input.getEnabled() == true) then
|
|
||||||
currentHandler.crankUndocked()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Constants
|
|
||||||
-- . A set of constants referencing device inputs, stored as strings. Can be used for querying button input,
|
|
||||||
-- but are mainly for on-screen prompts or other elements where a string literal is useful, such as a filename, GameData value, or localization key.
|
|
||||||
-- For faster performance, use the ones that exist in the Playdate SDK (i.e.: `playdate.kButtonA`), which are stored as binary numbers.
|
|
||||||
-- @usage
|
|
||||||
-- function newPrompt(__input, __promptString)
|
|
||||||
-- -- ...
|
|
||||||
-- local icon = Graphics.image.new("assets/images/UI/Icon_" .. __input)
|
|
||||||
-- -- ...
|
|
||||||
-- end
|
|
||||||
--
|
|
||||||
-- promptMove = newPrompt(Noble.Input.DPAD_HORIZONTAL, "Move!") -- assets/images/UI/Icon_dPadHorizontal.png"
|
|
||||||
-- promptJump = newPrompt(Noble.Input.BUTTON_A, "Jump!") -- assets/images/UI/Icon_buttonA.png"
|
|
||||||
-- promptCharge = newPrompt(Noble.Input.CRANK_FORWARD, "Charge the battery!") -- assets/images/UI/Icon_crankForward.png"
|
|
||||||
-- @section constants
|
|
||||||
|
|
||||||
--- `"buttonA"`
|
|
||||||
Noble.Input.BUTTON_A = "buttonA"
|
|
||||||
--- `"buttonB"`
|
|
||||||
Noble.Input.BUTTON_B = "buttonB"
|
|
||||||
--- The system menu button.
|
|
||||||
--
|
|
||||||
-- `"buttonMenu"`
|
|
||||||
Noble.Input.BUTTON_MENU = "buttonMenu"
|
|
||||||
|
|
||||||
--- Referencing the D-pad component itself, rather than an input.
|
|
||||||
--
|
|
||||||
-- `"dPad"`
|
|
||||||
Noble.Input.DPAD = "dPad"
|
|
||||||
--- Referencing the left and right input D-pad inputs.
|
|
||||||
--
|
|
||||||
-- `"dPadHorizontal"`
|
|
||||||
Noble.Input.DPAD_HORIZONTAL = "dPadHorizontal"
|
|
||||||
--- Referencing the up and down input D-pad inputs.
|
|
||||||
--
|
|
||||||
-- `"dPadVertical"`
|
|
||||||
Noble.Input.DPAD_VERTICAL = "dPadVertical"
|
|
||||||
--- `"dPadUp"`
|
|
||||||
Noble.Input.DPAD_UP = "dPadUp"
|
|
||||||
--- `"dPadDown"`
|
|
||||||
Noble.Input.DPAD_DOWN = "dPadDown"
|
|
||||||
--- `"dPadLeft"`
|
|
||||||
Noble.Input.DPAD_LEFT = "dPadLeft"
|
|
||||||
--- `"dPadRight"`
|
|
||||||
Noble.Input.DPAD_RIGHT = "dPadRight"
|
|
||||||
|
|
||||||
--- Referencing the crank component itself, rather than an input.
|
|
||||||
--
|
|
||||||
-- `"crank"`
|
|
||||||
Noble.Input.CRANK = "crank"
|
|
||||||
--- AKA: Clockwise. See Playdate SDK.
|
|
||||||
--
|
|
||||||
-- `"crankForward"`
|
|
||||||
Noble.Input.CRANK_FORWARD = "crankForward"
|
|
||||||
--- AKA: Anticlockwise. See Playdate SDK.
|
|
||||||
--
|
|
||||||
-- `"crankReverse"`
|
|
||||||
Noble.Input.CRANK_REVERSE = "crankReverse"
|
|
||||||
--- Referencing the action of docking the crank.
|
|
||||||
--
|
|
||||||
-- `"crankDock"`
|
|
||||||
Noble.Input.CRANK_DOCK = "crankDock"
|
|
||||||
--- Referencing the action of undocking the crank.
|
|
||||||
--
|
|
||||||
-- `"crankUndock"`
|
|
||||||
Noble.Input.CRANK_UNDOCK = "crankUndock"
|
|
||||||
|
|
||||||
--- Referencing the display orientations.
|
|
||||||
--
|
|
||||||
-- `"orientationUp"`
|
|
||||||
Noble.Input.ORIENTATION_UP = "orientationUp"
|
|
||||||
-- `"orientationDown"`
|
|
||||||
Noble.Input.ORIENTATION_DOWN = "orientationDown"
|
|
||||||
-- `"orientationLeft"`
|
|
||||||
Noble.Input.ORIENTATION_LEFT = "orientationLeft"
|
|
||||||
-- `"orientationRight"`
|
|
||||||
Noble.Input.ORIENTATION_RIGHT = "orientationRight"
|
|
@ -1,570 +0,0 @@
|
|||||||
--- An extended implementation of `playdate.ui.gridview`, meant for 1-dimensional, single-screen text menus.
|
|
||||||
-- @module Noble.Menu
|
|
||||||
--
|
|
||||||
Noble.Menu = {}
|
|
||||||
|
|
||||||
--- Setup
|
|
||||||
-- @section setup
|
|
||||||
|
|
||||||
--- Create a new menu object.
|
|
||||||
-- @bool[opt=true] __activate @{activate|Activate} this menu upon creation.
|
|
||||||
-- @param[opt=Noble.Text.ALIGN_LEFT] __alignment The text alignment of menu items.
|
|
||||||
-- @bool[opt=false] __localized If true, menu item names are localization keys rather than display names.
|
|
||||||
-- @param[opt=Graphics.kColorBlack] __color The color of menu item text. The selected highlight will be the inverse color.
|
|
||||||
-- @int[opt=2] __padding Cell padding for menu items.
|
|
||||||
-- @int[opt] __horizontalPadding Use this to override horizontal padding, useful for certain fonts. If nil, uses __padding.
|
|
||||||
-- @int[opt=2] __margin Spacing between menu items.
|
|
||||||
-- @param[opt=Noble.Text.getCurrentFont()] __font If nil, uses current set font.
|
|
||||||
-- @int[opt=__font:getHeight()/4] __selectedCornerRadius Sets rounded corners for a selected menu item.
|
|
||||||
-- @int[opt=1] __selectedOutlineThickness Sets the outline thickness for selected items.
|
|
||||||
-- @return `menu`, a new menu item.
|
|
||||||
-- @usage
|
|
||||||
-- local menu = Noble.Menu.new(
|
|
||||||
-- true,
|
|
||||||
-- Noble.Text.ALIGN_CENTER,
|
|
||||||
-- false,
|
|
||||||
-- Graphics.kColorWhite,
|
|
||||||
-- 4, 6,
|
|
||||||
-- Noble.Text.large,
|
|
||||||
-- nil, 3
|
|
||||||
-- )
|
|
||||||
-- menu:addItem("Play Game", function() TitleScreen:playGame() end)
|
|
||||||
-- menu:addItem("Options", function() Noble.transition(OptionsScreen) end)
|
|
||||||
-- menu:addItem("Credits", function() Noble.transition(CreditsScreen) end)
|
|
||||||
-- @see addItem
|
|
||||||
function Noble.Menu.new(__activate, __alignment, __localized, __color, __padding, __horizontalPadding, __margin, __font, __selectedCornerRadius, __selectedOutlineThickness)
|
|
||||||
|
|
||||||
-- Prep for creating the gridview object
|
|
||||||
local paddingLocal = __padding or 2
|
|
||||||
local fontLocal = __font or Noble.Text.getCurrentFont()
|
|
||||||
local textHeightLocal = fontLocal:getHeight()
|
|
||||||
|
|
||||||
-- Create gridview object
|
|
||||||
local menu = UI.gridview.new(0, textHeightLocal + paddingLocal)
|
|
||||||
|
|
||||||
--- Properties
|
|
||||||
--@section properties
|
|
||||||
|
|
||||||
menu.alignment = __alignment or Noble.Text.ALIGN_LEFT
|
|
||||||
|
|
||||||
--- @bool[opt=false] _ Indicates whether this menu's item names are treated as localization keys.
|
|
||||||
menu.localized = Utilities.handleOptionalBoolean(__localized, false)
|
|
||||||
menu.textHeight = textHeightLocal
|
|
||||||
menu.padding = paddingLocal
|
|
||||||
menu.horizontalPadding = __horizontalPadding or menu.padding
|
|
||||||
menu.margin = __margin or 2
|
|
||||||
menu.font = fontLocal
|
|
||||||
menu.selectedCornerRadius = __selectedCornerRadius or textHeightLocal/4
|
|
||||||
menu.selectedOutlineThickness = __selectedOutlineThickness or 1
|
|
||||||
|
|
||||||
-- Local cleanup. We don't need these anymore.
|
|
||||||
paddingLocal = nil
|
|
||||||
fontLocal = nil
|
|
||||||
textHeightLocal = nil
|
|
||||||
|
|
||||||
-- Colors
|
|
||||||
menu.color = __color or Graphics.kColorBlack -- TO-DO allow for copy fill mode instead of color.
|
|
||||||
menu.fillMode = Graphics.kDrawModeFillBlack
|
|
||||||
menu.otherColor = Graphics.kColorWhite
|
|
||||||
menu.otherFillMode = Graphics.kDrawModeFillWhite
|
|
||||||
if (menu.color == Graphics.kColorWhite) then
|
|
||||||
menu.fillMode = Graphics.kDrawModeFillWhite
|
|
||||||
menu.otherColor = Graphics.kColorBlack
|
|
||||||
menu.otherFillMode = Graphics.kDrawModeFillBlack
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Gridview properties
|
|
||||||
menu:setNumberOfColumns(1)
|
|
||||||
menu:setCellPadding(0, 0, 0, 0)
|
|
||||||
menu.changeRowOnColumnWrap = false
|
|
||||||
|
|
||||||
--- Tables
|
|
||||||
--@section tables
|
|
||||||
|
|
||||||
--- A string "array" of menu item strings/keys.
|
|
||||||
-- <strong>You cannot add or remove menu items by modifying this table</strong>.
|
|
||||||
-- It is meant as a <strong>read-only</strong> table, provided for convenience when iterating, etc. Modifying its values may break other methods.
|
|
||||||
-- @usage
|
|
||||||
-- for i = 1, #menu.itemNames, 1 do
|
|
||||||
-- menu.clickHandlers[menu.itemNames[i]] = nil -- Clears all click handlers, for some reason.
|
|
||||||
-- end
|
|
||||||
-- @see addItem
|
|
||||||
menu.itemNames = {}
|
|
||||||
|
|
||||||
-- This is an internal table. Modifying its may break other methods.
|
|
||||||
menu.displayNames = {}
|
|
||||||
|
|
||||||
-- This is an internal table. Modifying its may break other methods.
|
|
||||||
menu.displayNamesAreLocalized = {}
|
|
||||||
|
|
||||||
--- A table of functions associated with menu items. Items are a defined when calling @{addItem|addItem}, but their associated functions may be modified afterward.
|
|
||||||
--
|
|
||||||
-- <strong>You cannot add or remove menu items by modifying this table</strong>.
|
|
||||||
-- @usage
|
|
||||||
-- local menu = Noble.Menu.new(true)
|
|
||||||
-- menu.addItem("Play Game")
|
|
||||||
-- menu.addItem("Options")
|
|
||||||
--
|
|
||||||
-- menu.clickHandlers["Play Game"] = function() TitleScreen:playGame() end
|
|
||||||
-- menu.clickHandlers["Options"] = function() Noble.transition(OptionsScreen) end
|
|
||||||
-- @usage
|
|
||||||
-- local menu = Noble.Menu.new(true)
|
|
||||||
-- menu.addItem("Play Game")
|
|
||||||
-- menu.addItem("Options")
|
|
||||||
--
|
|
||||||
-- menu.clickHandlers = {
|
|
||||||
-- ["Play Game"] = function TitleScreen:playGame() end,
|
|
||||||
-- ["Options"] = function() Noble.transition(OptionsScreen) end
|
|
||||||
-- }
|
|
||||||
-- @see addItem
|
|
||||||
-- @see removeItem
|
|
||||||
menu.clickHandlers = {}
|
|
||||||
|
|
||||||
--- A key/value table of menu item indices.
|
|
||||||
--
|
|
||||||
-- This is meant as a <strong>read-only</strong> table, provided for convenience. Modifying its values will break other methods.
|
|
||||||
-- @usage
|
|
||||||
-- menu.itemPositions["Play Game"] -- 1
|
|
||||||
-- menu.itemPositions["Options"] -- 2
|
|
||||||
menu.itemPositions = {}
|
|
||||||
|
|
||||||
--- A key/value table of pixel widths for each menu item, based on its text. Useful for animation, layout, etc.
|
|
||||||
--
|
|
||||||
-- This is meant as a <strong>read-only</strong> table, provided for convenience. Modifying its values will break other methods.
|
|
||||||
-- @usage local playGameMenuItemWidth = menu.itemWidths["Play Game"]
|
|
||||||
menu.itemWidths = {}
|
|
||||||
|
|
||||||
--- Properties
|
|
||||||
-- @section properties
|
|
||||||
|
|
||||||
--- @int _
|
|
||||||
-- The current menu item's index.
|
|
||||||
--
|
|
||||||
-- This is meant as a <strong>read-only</strong> value. Do not modify it directly.
|
|
||||||
-- @see select
|
|
||||||
menu.currentItemNumber = 1
|
|
||||||
|
|
||||||
--- @string _
|
|
||||||
-- The current menu item's name.
|
|
||||||
--
|
|
||||||
-- This is meant as a <strong>read-only</strong> value. Do not modify it directly.
|
|
||||||
-- @see select
|
|
||||||
menu.currentItemName = menu.itemNames[1]
|
|
||||||
|
|
||||||
|
|
||||||
--- @int _
|
|
||||||
-- The width of the widest menu item plus the menu's horizontal padding.
|
|
||||||
--
|
|
||||||
-- This is meant as a <strong>read-only</strong> value. Do not modify it directly.
|
|
||||||
menu.width = 0
|
|
||||||
|
|
||||||
--- Setup
|
|
||||||
-- @section setup
|
|
||||||
|
|
||||||
--- Adds a item to this menu.
|
|
||||||
-- @string __nameOrKey The name of this menu item. It can be a display name or a localization key. <strong>Must be unique.</strong>
|
|
||||||
-- @tparam[opt] function __clickHandler The function that runs when this menu item is "clicked."
|
|
||||||
-- @int[opt] __position Insert the item at a specific position. If not set, adds to the end of the list.
|
|
||||||
-- @string[opt] __displayName You can create an optional, separate display name for this item. You can add or change this at runtime via @{setItemDisplayName|setItemDisplayName}.
|
|
||||||
-- @bool[opt=false] __displayNameIsALocalizationKey If true, will treat the `__displayName` as a localization key. This is separate from this menu's @{localized|localized} value.
|
|
||||||
-- @see new
|
|
||||||
-- @see removeItem
|
|
||||||
-- @see setItemDisplayName
|
|
||||||
function menu:addItem(__nameOrKey, __clickHandler, __position, __displayName, __displayNameIsALocalizationKey)
|
|
||||||
local clickHandler = __clickHandler or function () print("Menu item \"" .. __nameOrKey .. "\" clicked!") end
|
|
||||||
if (__position ~= nil) then
|
|
||||||
if (__position <= 0 or __position > #self.itemNames) then error("BONK: Menu item out of range.", 3) return end
|
|
||||||
table.insert(self.itemNames, __position, __nameOrKey)
|
|
||||||
for key, value in pairs(self.itemPositions) do
|
|
||||||
if (value >= __position) then
|
|
||||||
self.itemPositions[key] = self.itemPositions[key] + 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
self.itemPositions[__nameOrKey] = __position
|
|
||||||
else
|
|
||||||
table.insert(self.itemNames, __nameOrKey)
|
|
||||||
self.itemPositions[__nameOrKey] = #self.itemNames
|
|
||||||
end
|
|
||||||
|
|
||||||
self.clickHandlers[__nameOrKey] = clickHandler
|
|
||||||
|
|
||||||
-- Item name
|
|
||||||
local nameOrKey
|
|
||||||
if (self.localized) then
|
|
||||||
nameOrKey = Graphics.getLocalizedText(__nameOrKey)
|
|
||||||
else
|
|
||||||
nameOrKey = __nameOrKey
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Display name
|
|
||||||
local displayName = nil
|
|
||||||
if (__displayName ~= nil) then
|
|
||||||
if (__displayNameIsALocalizationKey == true) then
|
|
||||||
displayName = Graphics.getLocalizedText(__displayName)
|
|
||||||
else
|
|
||||||
displayName = __displayName
|
|
||||||
end
|
|
||||||
self.displayNames[__nameOrKey] = displayName
|
|
||||||
end
|
|
||||||
|
|
||||||
if (displayName == nil) then
|
|
||||||
self:updateWidths(__nameOrKey, nameOrKey)
|
|
||||||
else
|
|
||||||
self:updateWidths(__nameOrKey, displayName)
|
|
||||||
end
|
|
||||||
|
|
||||||
self:setNumberOfRows(#self.itemNames)
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Internal method.
|
|
||||||
function menu:updateWidths(__nameOrKey, __string)
|
|
||||||
|
|
||||||
if (__string == nil) then
|
|
||||||
__string = __nameOrKey
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Item width
|
|
||||||
self.itemWidths[__nameOrKey] = self.font:getTextWidth(__string)
|
|
||||||
|
|
||||||
-- Menu width
|
|
||||||
local width = 0
|
|
||||||
for _, value in pairs(self.itemWidths) do
|
|
||||||
if value > width then width = value end
|
|
||||||
end
|
|
||||||
self.width = width + (self.horizontalPadding * 2) + (self.selectedOutlineThickness * 2)
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Removes a item from this menu.
|
|
||||||
-- @tparam[opt=#menu.itemNames] int|string __menuItem The menu item to remove. You can enter either the item's name/key or it's position. If left blank, removes the last item.
|
|
||||||
-- @see addItem
|
|
||||||
function menu:removeItem(__menuItem)
|
|
||||||
local itemString = nil
|
|
||||||
local itemPosition = nil
|
|
||||||
|
|
||||||
if (__menuItem == nil) then
|
|
||||||
__menuItem = #self.itemNames
|
|
||||||
end
|
|
||||||
|
|
||||||
if (type(__menuItem) == "number") then
|
|
||||||
if (__menuItem <= 0 or __menuItem > #self.itemNames) then error("BONK: Menu item out of range.", 3) return end
|
|
||||||
itemString = self.itemNames[__menuItem]
|
|
||||||
itemPosition = __menuItem
|
|
||||||
elseif (type(__menuItem) == "string") then
|
|
||||||
itemString = __menuItem
|
|
||||||
itemPosition = self.itemPositions[__menuItem]
|
|
||||||
if (itemPosition == nil) then error("BONK: Menu item not found.", 3) return end
|
|
||||||
end
|
|
||||||
|
|
||||||
for key, value in pairs(self.itemPositions) do
|
|
||||||
if (value > itemPosition) then
|
|
||||||
self.itemPositions[key] = self.itemPositions[key] - 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
table.remove(self.itemNames, itemPosition)
|
|
||||||
self.itemPositions[itemString] = nil
|
|
||||||
self.clickHandlers[itemString] = nil
|
|
||||||
self.itemWidths[itemString] = nil
|
|
||||||
self.displayNames[itemString] = nil
|
|
||||||
self.displayNamesAreLocalized[itemString] = nil
|
|
||||||
|
|
||||||
-- In case the current item is selected.
|
|
||||||
if (self.currentItemNumber == itemPosition and self.currentItemNumber ~= 1) then
|
|
||||||
self:select(self.currentItemNumber - 1, true)
|
|
||||||
if (self.isActive() == false) then
|
|
||||||
self:setSelectedRow(0)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
self:setNumberOfRows(#self.itemNames)
|
|
||||||
|
|
||||||
-- Update width
|
|
||||||
local width = 0
|
|
||||||
for _, value in pairs(self.itemWidths) do
|
|
||||||
if value > width then width = value end
|
|
||||||
end
|
|
||||||
self.width = width + (self.horizontalPadding * 2) + (self.selectedOutlineThickness * 2)
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
--
|
|
||||||
|
|
||||||
local active = Utilities.handleOptionalBoolean(__activate, true)
|
|
||||||
if (active) then
|
|
||||||
menu.currentItemNumber = 1
|
|
||||||
menu.currentItemName = menu.itemNames[1]
|
|
||||||
menu:setSelectedRow(1)
|
|
||||||
else
|
|
||||||
menu:setSelectedRow(0)
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Methods
|
|
||||||
--@section methods
|
|
||||||
|
|
||||||
--- Activate this menu.
|
|
||||||
-- This selects the most recently selected menu item (or the first item if none have been previously selected), and enables this menu's @{selectPrevious|selectPrevious}, @{selectNext|selectNext}, and @{click|click} methods.
|
|
||||||
-- @usage
|
|
||||||
-- local menu = Noble.Menu.new(false)
|
|
||||||
-- menu:activate()
|
|
||||||
function menu:activate()
|
|
||||||
active = true
|
|
||||||
self:select(self.currentItemNumber)
|
|
||||||
end
|
|
||||||
--- Deactivate this menu.
|
|
||||||
-- This deselects all menu items, and disables this menu's @{selectPrevious|selectPrevious}, @{selectNext|selectNext}, and @{click|click} methods.
|
|
||||||
-- @usage
|
|
||||||
-- local menu = Noble.Menu.new(true)
|
|
||||||
-- menu:deactivate()
|
|
||||||
function menu:deactivate()
|
|
||||||
self:setSelectedRow(0)
|
|
||||||
active = false
|
|
||||||
end
|
|
||||||
--- Check to see if this menu is currently active.
|
|
||||||
-- @treturn bool
|
|
||||||
function menu:isActive()
|
|
||||||
return active
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Selects the previous item in this menu. <strong>This menu must be active.</strong>
|
|
||||||
-- @bool[opt=false] __force Force this method to run, even if this menu is not active.
|
|
||||||
-- @bool[opt=true] __wrapSelection Selects the final menu item if the first menu item is currently selected.
|
|
||||||
-- @see activate
|
|
||||||
-- @usage
|
|
||||||
-- TitleScreen.inputHandler.upButtonDown = function()
|
|
||||||
-- menu:selectPrevious()
|
|
||||||
-- end
|
|
||||||
function menu:selectPrevious(__force, __wrapSelection)
|
|
||||||
if (self:isActive() or __force) then
|
|
||||||
local wrapSelection = Utilities.handleOptionalBoolean(__wrapSelection, true)
|
|
||||||
self:selectPreviousRow(wrapSelection, false, false)
|
|
||||||
local _, row, _ = self:getSelection()
|
|
||||||
self.currentItemNumber = row
|
|
||||||
self.currentItemName = self.itemNames[row]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
--- Selects the next previous item in this menu. <strong>This menu must be active.</strong>
|
|
||||||
-- @bool[opt=false] __force Force this method to run, even if this menu is not active.
|
|
||||||
-- @bool[opt=true] __wrapSelection Selects the first menu item if the final menu item is currently selected.
|
|
||||||
-- @see activate
|
|
||||||
-- @usage
|
|
||||||
-- TitleScreen.inputHandler.downButtonDown = function()
|
|
||||||
-- menu:selectNext()
|
|
||||||
-- end
|
|
||||||
function menu:selectNext(__force, __wrapSelection)
|
|
||||||
if (self:isActive() or __force) then
|
|
||||||
local wrapSelection = Utilities.handleOptionalBoolean(__wrapSelection, true)
|
|
||||||
self:selectNextRow(wrapSelection, false, false)
|
|
||||||
local _, row, _ = self:getSelection()
|
|
||||||
self.currentItemNumber = row
|
|
||||||
self.currentItemName = self.itemNames[row]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Selects a specific item in this menu, either by it's index, or it's name. <strong>This menu must be active.</strong>
|
|
||||||
-- @tparam int|string __menuItem The menu item to select. You can enter the item's number or it's name/key.
|
|
||||||
-- @bool[opt=false] __force Force this method to run, even if this menu is not active.
|
|
||||||
-- @see activate
|
|
||||||
-- @usage
|
|
||||||
-- function resetMenu()
|
|
||||||
-- menu:select(1, true)
|
|
||||||
-- menu:deactivate()
|
|
||||||
-- end
|
|
||||||
-- @usage
|
|
||||||
-- function resetMenu()
|
|
||||||
-- menu:select("Play Game", true)
|
|
||||||
-- menu:deactivate()
|
|
||||||
-- end
|
|
||||||
function menu:select(__menuItem, __force)
|
|
||||||
if (self:isActive() or __force) then
|
|
||||||
if (type(__menuItem) == 'number') then
|
|
||||||
if (__menuItem < 1) then
|
|
||||||
error("BONK: _menuItem must be a number greater than 0 (or a string).")
|
|
||||||
end
|
|
||||||
self:setSelectedRow(__menuItem)
|
|
||||||
elseif (type(__menuItem) == 'string') then
|
|
||||||
self:setSelectedRow(self.itemPositions[__menuItem])
|
|
||||||
else
|
|
||||||
error("BONK: _menuItem must be a number or string, silly.")
|
|
||||||
end
|
|
||||||
local _, row, _ = self:getSelection()
|
|
||||||
self.currentItemNumber = row
|
|
||||||
self.currentItemName = self.itemNames[row]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Runs the function associated with the currently selected menu item. <strong>This menu must be active.</strong>
|
|
||||||
-- @bool[opt=false] __force Force this method to run, even if this menu is not active.
|
|
||||||
-- @see activate
|
|
||||||
-- @usage
|
|
||||||
-- TitleScreen.inputHandler.AButtonDown = function()
|
|
||||||
-- menu:click()
|
|
||||||
-- end
|
|
||||||
function menu:click(__force)
|
|
||||||
if ((self:isActive() or __force) and self.clickHandlers[self.currentItemName] ~= nil) then
|
|
||||||
self.clickHandlers[self.currentItemName]()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Gets the display name of a menu item.
|
|
||||||
--
|
|
||||||
-- If a menu item does not have a display name, then the `__nameOrKey` (or its localized string) will be returned instead. This method is used internally when @{draw|draw} is called.
|
|
||||||
--
|
|
||||||
-- If this menu's `localized` value is true, a returned `__nameOrKey` will always be localized, but a returned display name is only localized if the `__displayNameIsALocalizationKey` argument was set to `true` when the display name was added.
|
|
||||||
-- @string __itemName The menu item you want the display name of.
|
|
||||||
-- @treturn string
|
|
||||||
-- @see addItem
|
|
||||||
-- @see setItemDisplayName
|
|
||||||
function menu:getItemDisplayName(__itemName)
|
|
||||||
if (self.displayNames[__itemName] == nil) then
|
|
||||||
-- No display name.
|
|
||||||
if (self.localized) then
|
|
||||||
return Graphics.getLocalizedText(__itemName)
|
|
||||||
else
|
|
||||||
return __itemName
|
|
||||||
end
|
|
||||||
else
|
|
||||||
-- Has display name.
|
|
||||||
if (self.displayNamesAreLocalized[__itemName] == true) then
|
|
||||||
return Graphics.getLocalizedText(self.displayNames[__itemName])
|
|
||||||
else
|
|
||||||
return self.displayNames[__itemName]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--- When you add a menu item, you can give it a display name that's different from it's actual name. This method adds or changes the display name of a menu item.
|
|
||||||
-- @string __itemName The menu item name (or key if this menu uses localization keys).
|
|
||||||
-- @string __displayName The display name.
|
|
||||||
-- @bool[opt=false] __displayNameIsALocalizationKey Set to use to indicate that this display name is a localization key. This setting is separate from @{localized|localized}
|
|
||||||
-- @usage
|
|
||||||
-- function changeDifficultyLevel(__level)
|
|
||||||
-- menu:setItemDisplayName("Difficulty", "Difficulty: " .. __level)
|
|
||||||
-- end
|
|
||||||
function menu:setItemDisplayName(__itemName, __displayName, __displayNameIsALocalizationKey)
|
|
||||||
self.displayNames[__itemName] = __displayName
|
|
||||||
self.displayNamesAreLocalized[__itemName] = Utilities.handleOptionalBoolean(__displayNameIsALocalizationKey, false)
|
|
||||||
|
|
||||||
local displayName
|
|
||||||
if (__displayNameIsALocalizationKey == true) then
|
|
||||||
displayName = Graphics.getLocalizedText(__displayName)
|
|
||||||
else
|
|
||||||
displayName = __displayName
|
|
||||||
end
|
|
||||||
|
|
||||||
-- If we're "resetting" the display name by setting it to nil, then use __nameOrKey instead (checking for localization before calling updateWidths)
|
|
||||||
if (displayName == nil) then
|
|
||||||
if (self.localized) then
|
|
||||||
displayName = Graphics.getLocalizedText(__itemName)
|
|
||||||
else
|
|
||||||
displayName = __itemName
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
self:updateWidths(__itemName, displayName)
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Drawing
|
|
||||||
--@section drawing
|
|
||||||
|
|
||||||
--- Draw's this menu to the screen. You may call this manually, but ideally, you will put it in in your scene's @{NobleScene:update|update} or @{NobleScene:drawBackground|drawBackground} method.
|
|
||||||
-- @usage
|
|
||||||
-- function YourScene:update()
|
|
||||||
-- YourScene.super.update(self)
|
|
||||||
-- menu:draw(50, 100)
|
|
||||||
-- end
|
|
||||||
function menu:draw(__x, __y)
|
|
||||||
local xAdjustment = 0
|
|
||||||
if (self.alignment == Noble.Text.ALIGN_CENTER) then
|
|
||||||
xAdjustment = self.width/2
|
|
||||||
elseif (self.alignment == Noble.Text.ALIGN_RIGHT) then
|
|
||||||
xAdjustment = self.width
|
|
||||||
end
|
|
||||||
self:drawInRect(__x - xAdjustment, __y, self.width, ((self.textHeight + self.padding + self.margin) * #self.itemNames) + (self.selectedOutlineThickness * 2) - self.margin)
|
|
||||||
end
|
|
||||||
|
|
||||||
--- This method is called for every <strong>non-selected</strong> item when @{draw|draw} is called. You shouldn't call this directly, but you may re-implement it if you wish.
|
|
||||||
-- @usage
|
|
||||||
-- -- This is the default implementation for this method.
|
|
||||||
-- function menu:drawItem(__x, __y, __itemIndex)
|
|
||||||
-- Graphics.setImageDrawMode(self.fillMode)
|
|
||||||
-- local xAdjustment = 0
|
|
||||||
-- if (self.alignment == Noble.Text.ALIGN_CENTER) then
|
|
||||||
-- xAdjustment = self.width/2 - self.horizontalPadding/2
|
|
||||||
-- elseif (self.alignment == Noble.Text.ALIGN_RIGHT) then
|
|
||||||
-- xAdjustment = self.width - self.horizontalPadding
|
|
||||||
-- end
|
|
||||||
-- Noble.Text.draw(self.itemNames[__itemIndex], __x + self.horizontalPadding/2 + xAdjustment, __y + self.padding/2, self.alignment, self.localized, self.font)
|
|
||||||
-- end
|
|
||||||
-- @see Noble.Text.draw
|
|
||||||
function menu:drawItem(__x, __y, __itemIndex)
|
|
||||||
Graphics.setImageDrawMode(self.fillMode)
|
|
||||||
local xAdjustment = self.selectedOutlineThickness
|
|
||||||
if (self.alignment == Noble.Text.ALIGN_CENTER) then
|
|
||||||
xAdjustment = self.width/2 - self.horizontalPadding/2
|
|
||||||
elseif (self.alignment == Noble.Text.ALIGN_RIGHT) then
|
|
||||||
xAdjustment = self.width - self.horizontalPadding - self.selectedOutlineThickness
|
|
||||||
end
|
|
||||||
Noble.Text.draw(
|
|
||||||
self:getItemDisplayName(self.itemNames[__itemIndex]),
|
|
||||||
__x + self.horizontalPadding/2 + xAdjustment, __y + self.padding/2 + self.selectedOutlineThickness + (self.margin * (__itemIndex -1)),
|
|
||||||
self.alignment, false, self.font
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
--- This method is called for every <strong>selected</strong> item when @{draw|draw} is called. You shouldn't call this directly, but you may re-implement it if you wish.
|
|
||||||
-- @usage
|
|
||||||
-- -- This is the default implementation for this method.
|
|
||||||
-- function menu:drawSelectedItem(__x, __y, __itemIndex)
|
|
||||||
-- local xAdjustmentText = 0
|
|
||||||
-- local xAdjustmentRect = 0
|
|
||||||
-- if (self.alignment == Noble.Text.ALIGN_CENTER) then
|
|
||||||
-- xAdjustmentText = self.width/2 - self.horizontalPadding/2
|
|
||||||
-- xAdjustmentRect = self.width/2 - self.itemWidths[self.itemNames[__itemIndex]]/2 - self.horizontalPadding/2
|
|
||||||
-- elseif (self.alignment == Noble.Text.ALIGN_RIGHT) then
|
|
||||||
-- xAdjustmentText = self.width - self.horizontalPadding
|
|
||||||
-- xAdjustmentRect = self.width - self.itemWidths[self.itemNames[__itemIndex]] - self.horizontalPadding
|
|
||||||
-- end
|
|
||||||
-- Graphics.setColor(self.color)
|
|
||||||
-- Graphics.fillRoundRect(__x + xAdjustmentRect, __y, self.itemWidths[self.itemNames[__itemIndex]]+self.horizontalPadding, self.textHeight+self.padding, self.selectedCornerRadius)
|
|
||||||
-- Graphics.setColor(self.otherColor)
|
|
||||||
-- Graphics.setLineWidth(self.selectedOutlineThickness)
|
|
||||||
-- Graphics.drawRoundRect(__x + xAdjustmentRect, __y, self.itemWidths[self.itemNames[__itemIndex]]+self.horizontalPadding, self.textHeight+self.padding, self.selectedCornerRadius)
|
|
||||||
-- Graphics.setImageDrawMode(self.otherFillMode)
|
|
||||||
-- Noble.Text.draw(self.itemNames[__itemIndex], __x + self.horizontalPadding/2 + xAdjustmentText, __y+self.padding/2, self.alignment, self.localized, self.font)
|
|
||||||
-- end
|
|
||||||
-- @see Noble.Text.draw
|
|
||||||
function menu:drawSelectedItem(__x, __y, __itemIndex)
|
|
||||||
local xAdjustmentText = self.selectedOutlineThickness
|
|
||||||
local xAdjustmentRect = self.selectedOutlineThickness
|
|
||||||
if (self.alignment == Noble.Text.ALIGN_CENTER) then
|
|
||||||
xAdjustmentText = self.width/2 - self.horizontalPadding/2
|
|
||||||
xAdjustmentRect = self.width/2 - self.itemWidths[self.itemNames[__itemIndex]]/2 - self.horizontalPadding/2
|
|
||||||
elseif (self.alignment == Noble.Text.ALIGN_RIGHT) then
|
|
||||||
xAdjustmentText = self.width - self.horizontalPadding - self.selectedOutlineThickness
|
|
||||||
xAdjustmentRect = self.width - self.itemWidths[self.itemNames[__itemIndex]] - self.horizontalPadding - self.selectedOutlineThickness
|
|
||||||
end
|
|
||||||
Graphics.setColor(self.color)
|
|
||||||
Graphics.fillRoundRect(__x + xAdjustmentRect, __y + self.selectedOutlineThickness + (self.margin * (__itemIndex -1)), self.itemWidths[self.itemNames[__itemIndex]]+self.horizontalPadding, self.textHeight+self.padding, self.selectedCornerRadius)
|
|
||||||
Graphics.setColor(self.otherColor)
|
|
||||||
Graphics.setLineWidth(self.selectedOutlineThickness)
|
|
||||||
Graphics.drawRoundRect(__x + xAdjustmentRect, __y + self.selectedOutlineThickness + (self.margin * (__itemIndex -1)), self.itemWidths[self.itemNames[__itemIndex]]+self.horizontalPadding, self.textHeight+self.padding, self.selectedCornerRadius)
|
|
||||||
Graphics.setImageDrawMode(self.otherFillMode)
|
|
||||||
Noble.Text.draw(
|
|
||||||
self:getItemDisplayName(self.itemNames[__itemIndex]),
|
|
||||||
__x + self.horizontalPadding/2 + xAdjustmentText, __y + self.padding/2 + self.selectedOutlineThickness + (self.margin * (__itemIndex -1)),
|
|
||||||
self.alignment, false, self.font
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Don't call or modify this function.
|
|
||||||
function menu:drawCell(_, row, _, selected, x, y, width, height)
|
|
||||||
if selected then
|
|
||||||
self:drawSelectedItem(x, y, row)
|
|
||||||
else
|
|
||||||
self:drawItem(x, y, row)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return menu
|
|
||||||
end
|
|
@ -1,158 +0,0 @@
|
|||||||
--- Operations for game settings / stats.
|
|
||||||
-- @module Noble.Settings
|
|
||||||
--
|
|
||||||
Noble.Settings = {} -- This is the "class" that holds methods.
|
|
||||||
local settings = nil -- This is the actual settings object. We keep it local to avoid direct tampering.
|
|
||||||
local settingsDefault = nil -- We keep track of default values so they can be reset.
|
|
||||||
|
|
||||||
local function keyChange(__dataDefault, __data)
|
|
||||||
local defaultKeys = {}
|
|
||||||
local keys = {}
|
|
||||||
for key, value in pairs(__dataDefault) do table.insert(defaultKeys, key) end
|
|
||||||
for key, value in pairs(__data) do table.insert(keys, key) end
|
|
||||||
for i = 1, #keys, 1 do
|
|
||||||
if (defaultKeys[i] ~= keys[i]) then return true end
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
local function settingExists(__key)
|
|
||||||
-- Check for valid data item.
|
|
||||||
for key, value in pairs(settings) do
|
|
||||||
if __key == key then
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
error("BONK: Setting \'" .. __key .. "\' does not exist. Maybe you spellet ti wronlgly.", 3)
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
local settingsHaveBeenSetup = false
|
|
||||||
|
|
||||||
--- Sets up the settings for your game. You can only run this once, and you must run it before using other `Noble.Settings` functions. It is recommended to place it in your main.lua, before `Noble.new()`.
|
|
||||||
--
|
|
||||||
-- <strong>NOTE:</strong> You will *not* be able to add new keys via the `Noble.Settings.set` method. This means you need to specify the keys and default values of all of the settings in your game at setup.
|
|
||||||
-- If you need to add keys that are not known during setup, it is probably not a setting and you should consider using `Noble.GameData` instead.
|
|
||||||
-- @tparam table __keyValuePairs table. Your game's settings, and thier default values, as key/value pairs. <strong>NOTE:</strong> Do not use "nil" as a value.
|
|
||||||
-- @bool[opt=true] __saveToDisk Saves your default values immediatly to disk.
|
|
||||||
-- @bool[opt=true] __modifyExistingOnKeyChange Updates the existing settings object on disk if you make changes to your settings keys (not values) during development or when updating your game.
|
|
||||||
-- @usage
|
|
||||||
-- Noble.Settings.setup({
|
|
||||||
-- difficulty = "normal",
|
|
||||||
-- music = true,
|
|
||||||
-- sfx = true,
|
|
||||||
-- players = 2,
|
|
||||||
-- highScore = 0 -- You can store persistant stats here, too!
|
|
||||||
-- })
|
|
||||||
function Noble.Settings.setup(__keyValuePairs, __saveToDisk, __modifyExistingOnKeyChange)
|
|
||||||
if (settingsHaveBeenSetup) then
|
|
||||||
error("BONK: You can only run Noble.Settings.setup() once.")
|
|
||||||
return
|
|
||||||
else
|
|
||||||
settingsHaveBeenSetup = true
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Prevent using the setup() method if there are no settings to register
|
|
||||||
if (__keyValuePairs == nil or table.getSize(__keyValuePairs) == 0) then
|
|
||||||
error("BONK: Do not use Noble.Settings.setup if you do not have any settings to register. New settings cannot be added via Noble.Settings.set and must be all declared upfront in the Noble.Settings.setup method.")
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local saveToDisk = Utilities.handleOptionalBoolean(__saveToDisk, true)
|
|
||||||
local modifyExistingOnKeyChange = Utilities.handleOptionalBoolean(__modifyExistingOnKeyChange, true)
|
|
||||||
settingsDefault = __keyValuePairs
|
|
||||||
|
|
||||||
-- Get existing settings from disk, if any.
|
|
||||||
settings = Datastore.read("Settings")
|
|
||||||
|
|
||||||
if (settings == nil) then
|
|
||||||
-- No settings on disk, so we create a new settings object using default values.
|
|
||||||
settings = table.deepcopy(settingsDefault)
|
|
||||||
elseif (modifyExistingOnKeyChange and keyChange(settingsDefault, settings)) then
|
|
||||||
-- Found settings on disk, but key changes have been made...
|
|
||||||
-- ...so we start with a new default settings object...
|
|
||||||
local existingSettings = table.deepcopy(settings)
|
|
||||||
settings = table.deepcopy(settingsDefault)
|
|
||||||
for key, value in pairs(settings) do
|
|
||||||
-- ...then copy settings with unchanged keys to the new settings object,
|
|
||||||
-- naturally discarding keys that don't exist anymore.
|
|
||||||
if (existingSettings[key] ~= nil) then settings[key] = existingSettings[key] end
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
if (saveToDisk) then
|
|
||||||
Noble.Settings.save()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Get the value of a setting.
|
|
||||||
-- @string __settingName The name of the setting.
|
|
||||||
-- @treturn any The value of the requested setting.
|
|
||||||
-- @see set
|
|
||||||
function Noble.Settings.get(__settingName)
|
|
||||||
if (settingExists(__settingName)) then
|
|
||||||
return settings[__settingName]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Set the value of a setting.
|
|
||||||
--
|
|
||||||
-- <strong>NOTE:</strong> If __settingName is not a key in the __keyValuePairs dictionary given to the `setup` method it will not be added to the Settings.
|
|
||||||
-- @string __settingName The name of the setting.
|
|
||||||
-- @tparam any __value The setting's new value
|
|
||||||
-- @bool[opt=true] __saveToDisk Saves to disk immediately. Set to false if you prefer to manually save (via a confirm button, etc).
|
|
||||||
-- @see setup
|
|
||||||
-- @see get
|
|
||||||
-- @see save
|
|
||||||
function Noble.Settings.set(__settingName, __value, __saveToDisk)
|
|
||||||
if (settingExists(__settingName)) then
|
|
||||||
settings[__settingName] = __value
|
|
||||||
local saveToDisk = Utilities.handleOptionalBoolean(__saveToDisk, true)
|
|
||||||
if (saveToDisk) then Noble.Settings.save() end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Resets the value of a setting to its default value defined in `setup()`.
|
|
||||||
-- @string __settingName The name of the setting.
|
|
||||||
-- @bool[opt=true] __saveToDisk Saves to disk immediately. Set to false if you prefer to manually save (via a confirm button, etc).
|
|
||||||
-- @see resetSome
|
|
||||||
-- @see resetAll
|
|
||||||
-- @see save
|
|
||||||
function Noble.Settings.reset(__settingName, __saveToDisk)
|
|
||||||
if (settingExists(__settingName)) then
|
|
||||||
settings[__settingName] = settingsDefault[__settingName]
|
|
||||||
local saveToDisk = Utilities.handleOptionalBoolean(__saveToDisk, true)
|
|
||||||
if (saveToDisk) then Noble.Settings.save() end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Resets the value of multiple settings to thier default value defined in `setup()`. This is useful if you are storing persistant stats like high scores in `Settings` and want the player to be able to reset them seperately.
|
|
||||||
-- @tparam table __settingNames The names of the settings, in an array-style table.
|
|
||||||
-- @bool[opt=true] __saveToDisk Saves to disk immediately. Set to false if you prefer to manually save (via a confirm button, etc).
|
|
||||||
-- @see resetAll
|
|
||||||
-- @see save
|
|
||||||
function Noble.Settings.resetSome(__settingNames, __saveToDisk)
|
|
||||||
for i = 1, #__settingNames, 1 do
|
|
||||||
Noble.Settings.reset(__settingNames[i], __saveToDisk)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Resets all settings to thier default values defined in `setup()`.
|
|
||||||
-- @bool[opt=true] __saveToDisk Saves to disk immediately. Set to false if you prefer to manually save (via a confirm button, etc).
|
|
||||||
-- @see resetSome
|
|
||||||
-- @see save
|
|
||||||
function Noble.Settings.resetAll(__saveToDisk)
|
|
||||||
settings = table.deepcopy(settingsDefault)
|
|
||||||
local saveToDisk = Utilities.handleOptionalBoolean(__saveToDisk, true)
|
|
||||||
if (saveToDisk) then Noble.Settings.save() end
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Saves settings to disk.
|
|
||||||
-- You don't need to call this unless you set `__saveToDisk` as false when setting or resetting a setting (say that five times fast!).
|
|
||||||
-- @see set
|
|
||||||
-- @see reset
|
|
||||||
-- @see resetAll
|
|
||||||
function Noble.Settings.save()
|
|
||||||
Datastore.write(settings, "Settings")
|
|
||||||
end
|
|
@ -1,74 +0,0 @@
|
|||||||
--- Text and font handling.
|
|
||||||
-- @module Noble.Text
|
|
||||||
Noble.Text = {}
|
|
||||||
|
|
||||||
--- Fonts
|
|
||||||
--
|
|
||||||
-- You can use these fonts in your project, or override them with your own if you wish.
|
|
||||||
-- @section fonts
|
|
||||||
-- @usage
|
|
||||||
-- Noble.Text.FONT_SMALL = Graphics.font.new("assets/fonts/MySmallFont")
|
|
||||||
-- Noble.Text.setFont(Noble.Text.FONT_SMALL)
|
|
||||||
|
|
||||||
--- The Playdate system font.
|
|
||||||
Noble.Text.FONT_SYSTEM = Graphics.getSystemFont()
|
|
||||||
--- <strong>Noble Sans</strong>: A sans-serif 8×9 font, with English and Japanese-Kana character sets.
|
|
||||||
Noble.Text.FONT_SMALL = Graphics.font.new("libraries/noble/assets/fonts/NobleSans")
|
|
||||||
--- <strong>Noble Slab</strong>: (This font is not ready yet!)
|
|
||||||
Noble.Text.FONT_MEDIUM = Graphics.font.new("libraries/noble/assets/fonts/NobleSlab")
|
|
||||||
--- <strong>Satchel Roughed</strong>: A sans-serif 17×14 rounded font, with an English character set.
|
|
||||||
Noble.Text.FONT_LARGE = Graphics.font.new("libraries/noble/assets/fonts/SatchelRoughed")
|
|
||||||
|
|
||||||
--- Constants
|
|
||||||
--@section constants
|
|
||||||
|
|
||||||
--- An alternate way to call Playdate SDK's `kTextAlignment.left`
|
|
||||||
Noble.Text.ALIGN_LEFT = kTextAlignment.left
|
|
||||||
--- An alternate way to call Playdate SDK's `kTextAlignment.right`
|
|
||||||
Noble.Text.ALIGN_RIGHT = kTextAlignment.right
|
|
||||||
--- An alternate way to call Playdate SDK's `kTextAlignment.center`
|
|
||||||
Noble.Text.ALIGN_CENTER = kTextAlignment.center
|
|
||||||
|
|
||||||
local currentFont = Noble.Text.FONT_SYSTEM
|
|
||||||
|
|
||||||
|
|
||||||
--- Functions
|
|
||||||
--@section functions
|
|
||||||
|
|
||||||
---
|
|
||||||
-- @return The currently set font.
|
|
||||||
function Noble.Text.getCurrentFont()
|
|
||||||
return currentFont
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Set the current font
|
|
||||||
-- @param __font any
|
|
||||||
-- @param __variant any
|
|
||||||
function Noble.Text.setFont(__font, __variant)
|
|
||||||
currentFont = __font
|
|
||||||
local variant = __variant or Graphics.font.kVariantNormal
|
|
||||||
Graphics.setFont(__font, variant)
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Abstracts multiple `playdate.text` drawing functions into one.
|
|
||||||
-- @string __string Display text or localization key.
|
|
||||||
-- @number __x
|
|
||||||
-- @number __y
|
|
||||||
-- @param[opt=Noble.Text.ALIGN_LEFT] __alignment Left, right, or center!
|
|
||||||
-- @bool[opt=false] __localized If true, `__string` is a localization key rather than display text.
|
|
||||||
-- @param[opt=Noble.Text.getCurrentFont()] __font A font to use. If not set, the `currentFont` is used. If set, the `currentFont` is not updated.
|
|
||||||
function Noble.Text.draw(__string, __x, __y, __alignment, __localized, __font)
|
|
||||||
local alignment = __alignment or Noble.Text.ALIGN_LEFT
|
|
||||||
local localized = Utilities.handleOptionalBoolean(__localized, false)
|
|
||||||
local string = __string or ""
|
|
||||||
|
|
||||||
if (__font ~= nil) then Graphics.setFont(__font) end -- Temporary font
|
|
||||||
|
|
||||||
if (localized) then
|
|
||||||
Graphics.drawLocalizedTextAligned(string, __x, __y, alignment)
|
|
||||||
else
|
|
||||||
Graphics.drawTextAligned(string, __x, __y, alignment)
|
|
||||||
end
|
|
||||||
|
|
||||||
if (__font ~= nil) then Graphics.setFont(currentFont) end -- Reset
|
|
||||||
end
|
|
@ -1,208 +0,0 @@
|
|||||||
--- An abstract class from which transition types are extended.
|
|
||||||
-- @module Noble.Transition
|
|
||||||
|
|
||||||
Noble.Transition = {}
|
|
||||||
class("Transition", nil, Noble).extends()
|
|
||||||
|
|
||||||
Noble.Transition.Type = {}
|
|
||||||
|
|
||||||
--- A transition type where no time at all passes between scenes.
|
|
||||||
-- @see Noble.Transition.Cut
|
|
||||||
Noble.Transition.Type.CUT = "Cut"
|
|
||||||
|
|
||||||
--- A transition type that has an "Enter" phase and an "Exit" phase. The new scene does not become active until the Enter phase is complete. A "holdTime" value determines how long to wait after the Enter phase completes before starting the Exit phase.
|
|
||||||
-- @see Noble.Transition.Dip
|
|
||||||
-- @see Noble.Transition.Imagetable
|
|
||||||
-- @see Noble.Transition.Spotlight
|
|
||||||
Noble.Transition.Type.COVER = "Cover"
|
|
||||||
|
|
||||||
--- A transition type that takes a screenshot of the exiting scene and activates the new scene before beginning the transition, allowing for both scenes to appear to be visible during the transition.
|
|
||||||
-- @see Noble.Transition.CrossDissolve
|
|
||||||
-- @see Noble.Transition.SlideOff
|
|
||||||
-- @see Noble.Transition.ImagetableMask
|
|
||||||
Noble.Transition.Type.MIX = "Mix"
|
|
||||||
|
|
||||||
--- A transition may have unique properties that can be set by the user when invoked. This table holds the default values for those properties.
|
|
||||||
-- @see setDefaultProperties
|
|
||||||
Noble.Transition.defaultProperties = {}
|
|
||||||
|
|
||||||
function Noble.Transition:init(__duration, __arguments)
|
|
||||||
|
|
||||||
self.duration = __duration or Noble.getConfig().defaultTransitionDuration
|
|
||||||
|
|
||||||
self.durationEnter = __arguments.durationEnter or self.duration/2
|
|
||||||
self.durationExit = __arguments.durationExit or self.duration/2
|
|
||||||
|
|
||||||
if (__arguments.durationEnter and not __arguments.durationExit) then
|
|
||||||
warn("Soft-BONK: You've specified 'durationEnter' but not 'durationExit' for this transition. Thus, 'durationExit' will be half the value of 'duration'. Did you intend to do that?")
|
|
||||||
elseif (__arguments.durationExit and not __arguments.durationEnter) then
|
|
||||||
warn("Soft-BONK: You've specified 'durationExit' but not 'durationEnter' for this transition. Thus, 'durationEnter' will be half the value of 'duration'. Did you intend to do that?")
|
|
||||||
end
|
|
||||||
|
|
||||||
self.sequence = nil
|
|
||||||
|
|
||||||
self._captureScreenshotsDuringTransition = self._captureScreenshotsDuringTransition or false
|
|
||||||
|
|
||||||
self.midpointReached = false
|
|
||||||
self.holdTimeElapsed = false
|
|
||||||
|
|
||||||
self.drawMode = self.drawMode or __arguments.drawMode or Graphics.kDrawModeCopy
|
|
||||||
|
|
||||||
self.holdTime = self.holdTime or __arguments.holdTime or self.defaultProperties.holdTime or 0
|
|
||||||
|
|
||||||
if (self._type == Noble.Transition.Type.MIX) then
|
|
||||||
|
|
||||||
self._sequenceStartValue = self._sequenceStartValue or 0
|
|
||||||
self._sequenceCompleteValue = self._sequenceCompleteValue or 1
|
|
||||||
|
|
||||||
self.ease = self.ease or __arguments.ease or self.defaultProperties.ease or Ease.linear
|
|
||||||
if ((__arguments.easeEnter or __arguments.easeExit) ~= nil) then
|
|
||||||
warn("BONK: You've specified an 'easeEnter' and/or 'easeExit' argument for a transition of type 'Noble.Transition.Type.MIX'. This will have no effect. Use 'ease' instead, or specify a transition of type 'Noble.Transition.Type.COVER'.")
|
|
||||||
end
|
|
||||||
|
|
||||||
self.oldSceneScreenshot = Utilities.screenshot()
|
|
||||||
|
|
||||||
elseif (self._type == Noble.Transition.Type.COVER) then
|
|
||||||
|
|
||||||
self._sequenceStartValue = self._sequenceStartValue or 0
|
|
||||||
self._sequenceMidpointValue = self._sequenceMidpointValue or 1
|
|
||||||
self._sequenceResumeValue = self._sequenceResumeValue or 1
|
|
||||||
self._sequenceCompleteValue = self._sequenceCompleteValue or 0
|
|
||||||
|
|
||||||
local ease = self.ease or __arguments.ease or self.defaultProperties.ease or Ease.linear
|
|
||||||
if (ease) then
|
|
||||||
self.easeEnter = self.easeEnter or self.defaultProperties.easeEnter or Ease.enter(ease) or ease
|
|
||||||
self.easeExit = self.easeExit or self.defaultProperties.easeExit or Ease.exit(ease) or ease
|
|
||||||
if (Ease.enter(ease) == nil or Ease.exit(ease) == nil) then
|
|
||||||
warn("Soft-BONK: You've specified an 'ease' value for a transition of type 'Noble.Transition.Type.COVER' that isn't in the form of 'Ease.inOutXxxx' or an 'Ease.outInXxxx'. As a result, this value will be used for both 'easeEnter' and 'easeExit'. Did you mean to do that?")
|
|
||||||
end
|
|
||||||
else
|
|
||||||
self.easeEnter = self.easeEnter or __arguments.easeEnter or self.defaultProperties.easeEnter or self.easeEnter or Ease.linear
|
|
||||||
self.easeExit = self.easeExit or __arguments.easeExit or self.defaultProperties.easeExit or self.easeExit or Ease.linear
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
self:setProperties(__arguments)
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Use this to modify multiple default properties of a transition. Having default properties avoids having to set them every time a transition is called.
|
|
||||||
-- Properties added here are merged with the existing default properties table. Overwrites only happen when a new value is set.
|
|
||||||
-- @usage
|
|
||||||
-- Noble.Transition.setDefaultProperties(Noble.Transition.CrossDissolve, {
|
|
||||||
-- dither = Graphics.image.kDitherTypeDiagonalLine
|
|
||||||
-- ease = Ease.outQuint
|
|
||||||
-- })
|
|
||||||
-- Noble.Transition.setDefaultProperties(Noble.Transition.SpotlightMask, {
|
|
||||||
-- x = 325,
|
|
||||||
-- y = 95,
|
|
||||||
-- invert = true
|
|
||||||
-- })
|
|
||||||
-- @see defaultProperties
|
|
||||||
function Noble.Transition.setDefaultProperties(__transition, __properties)
|
|
||||||
table.merge(__transition.defaultProperties, __properties)
|
|
||||||
end
|
|
||||||
|
|
||||||
function Noble.Transition:execute()
|
|
||||||
|
|
||||||
local onStart = function()
|
|
||||||
Noble.transitionStartHandler()
|
|
||||||
self:onStart() -- If this transition has any custom code to run here, run it.
|
|
||||||
end
|
|
||||||
|
|
||||||
local onMidpoint = function()
|
|
||||||
Noble.transitionMidpointHandler()
|
|
||||||
self.midpointReached = true
|
|
||||||
self:onMidpoint() -- If this transition has any custom code to run here, run it.
|
|
||||||
end
|
|
||||||
|
|
||||||
local onHoldTimeElapsed = function()
|
|
||||||
self.holdTimeElapsed = true
|
|
||||||
self:onHoldTimeElapsed()
|
|
||||||
end
|
|
||||||
|
|
||||||
local onComplete = function()
|
|
||||||
self:onComplete() -- If this transition has any custom code to run here, run it.
|
|
||||||
Noble.transitionCompleteHandler()
|
|
||||||
end
|
|
||||||
|
|
||||||
local type = self._type
|
|
||||||
local holdTime = self.holdTime
|
|
||||||
|
|
||||||
if (type == Noble.Transition.Type.CUT) then
|
|
||||||
onStart()
|
|
||||||
onMidpoint()
|
|
||||||
onHoldTimeElapsed()
|
|
||||||
onComplete()
|
|
||||||
elseif (type == Noble.Transition.Type.COVER) then
|
|
||||||
onStart()
|
|
||||||
self.sequence = Sequence.new()
|
|
||||||
:from(self._sequenceStartValue)
|
|
||||||
:to(self._sequenceMidpointValue, self.durationEnter-(holdTime/2), self.easeEnter)
|
|
||||||
:callback(onMidpoint)
|
|
||||||
:sleep(holdTime)
|
|
||||||
:callback(onHoldTimeElapsed)
|
|
||||||
:to(self._sequenceResumeValue, 0)
|
|
||||||
:to(self._sequenceCompleteValue, self.durationExit-(holdTime/2), self.easeExit)
|
|
||||||
:callback(onComplete)
|
|
||||||
:start()
|
|
||||||
elseif (type == Noble.Transition.Type.MIX) then
|
|
||||||
onStart()
|
|
||||||
onMidpoint()
|
|
||||||
onHoldTimeElapsed()
|
|
||||||
self.sequence = Sequence.new()
|
|
||||||
:from(self._sequenceStartValue)
|
|
||||||
:to(self._sequenceCompleteValue, self.duration, self.ease)
|
|
||||||
:callback(onComplete)
|
|
||||||
:start()
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
--- *Do not call this directly.* Implement this in a custom transition in order to set properties from user arguments given in `Noble.transition()`. See existing transitions for implementation examples.
|
|
||||||
-- @see Noble.transition
|
|
||||||
function Noble.Transition:setProperties(__arguments) end
|
|
||||||
|
|
||||||
--- *Do not call this directly.* Implement this in a custom transition in order to run custom code when the transition starts. Default transitions in Noble Engine do not use this.
|
|
||||||
function Noble.Transition:onStart() end
|
|
||||||
|
|
||||||
--- *Do not call this directly.* Implement this in a custom transition in order to run custom code when the transition reaches its midpoint. Default transitions in Noble Engine do not use this.
|
|
||||||
function Noble.Transition:onMidpoint() end
|
|
||||||
|
|
||||||
--- *Do not call this directly.* Implement this in a custom transition in order to run custom code when the transition's hold time has elapsed. Default transitions in Noble Engine do not use this.
|
|
||||||
function Noble.Transition:onHoldTimeElapsed() end
|
|
||||||
|
|
||||||
--- *Do not call this directly.* Implement this in a custom transition in order to run custom code when the transition completes. Default transitions in Noble Engine do not use this.
|
|
||||||
function Noble.Transition:onComplete() end
|
|
||||||
|
|
||||||
--- *Do not call this directly.* Implement this in a custom transition to draw the transition. This runs once per frame while the transition is running. See existing transitions for implementation examples.
|
|
||||||
function Noble.Transition:draw() end
|
|
||||||
|
|
||||||
|
|
||||||
-- Noble Engine built-in transitions.
|
|
||||||
import 'libraries/noble/modules/Noble.Transition/Cut.lua'
|
|
||||||
--
|
|
||||||
import 'libraries/noble/modules/Noble.Transition/CrossDissolve.lua'
|
|
||||||
import 'libraries/noble/modules/Noble.Transition/Dip.lua'
|
|
||||||
import 'libraries/noble/modules/Noble.Transition/DipToBlack.lua'
|
|
||||||
import 'libraries/noble/modules/Noble.Transition/DipToWhite.lua'
|
|
||||||
--
|
|
||||||
import 'libraries/noble/modules/Noble.Transition/Imagetable.lua'
|
|
||||||
import 'libraries/noble/modules/Noble.Transition/ImagetableMask.lua'
|
|
||||||
import 'libraries/noble/modules/Noble.Transition/Spotlight.lua'
|
|
||||||
import 'libraries/noble/modules/Noble.Transition/SpotlightMask.lua'
|
|
||||||
--
|
|
||||||
import 'libraries/noble/modules/Noble.Transition/SlideOff.lua'
|
|
||||||
import 'libraries/noble/modules/Noble.Transition/SlideOffLeft.lua'
|
|
||||||
import 'libraries/noble/modules/Noble.Transition/SlideOffRight.lua'
|
|
||||||
import 'libraries/noble/modules/Noble.Transition/SlideOffUp.lua'
|
|
||||||
import 'libraries/noble/modules/Noble.Transition/SlideOffDown.lua'
|
|
||||||
import 'libraries/noble/modules/Noble.Transition/SlideOn.lua'
|
|
||||||
import 'libraries/noble/modules/Noble.Transition/SlideOnLeft.lua'
|
|
||||||
import 'libraries/noble/modules/Noble.Transition/SlideOnRight.lua'
|
|
||||||
import 'libraries/noble/modules/Noble.Transition/SlideOnUp.lua'
|
|
||||||
import 'libraries/noble/modules/Noble.Transition/SlideOnDown.lua'
|
|
||||||
--
|
|
||||||
import 'libraries/noble/modules/Noble.Transition/MetroNexus.lua'
|
|
||||||
import 'libraries/noble/modules/Noble.Transition/WidgetSatchel.lua'
|
|
@ -1,26 +0,0 @@
|
|||||||
---
|
|
||||||
-- @submodule Noble.Transition
|
|
||||||
|
|
||||||
class("CrossDissolve", nil, Noble.Transition).extends(Noble.Transition)
|
|
||||||
local transition = Noble.Transition.CrossDissolve
|
|
||||||
transition.name = "Cross Dissolve"
|
|
||||||
|
|
||||||
-- Type
|
|
||||||
transition._type = Noble.Transition.Type.MIX
|
|
||||||
|
|
||||||
--- A simple cross-fade.
|
|
||||||
-- @table Noble.Transition.CrossDissolve.defaultProperties
|
|
||||||
-- @tparam[opt=Ease.outCubic] Ease ease
|
|
||||||
-- @tparam[opt=Graphics.image.kDitherTypeBayer4x4] Graphics.image.kDither dither
|
|
||||||
transition.defaultProperties = {
|
|
||||||
ease = Ease.outCubic,
|
|
||||||
dither = Graphics.image.kDitherTypeBayer4x4
|
|
||||||
}
|
|
||||||
|
|
||||||
function transition:setProperties(__properties)
|
|
||||||
self.dither = __properties.dither or self.defaultProperties.dither
|
|
||||||
end
|
|
||||||
|
|
||||||
function transition:draw()
|
|
||||||
self.oldSceneScreenshot:drawFaded(0, 0, 1 - self.sequence:get(), self.dither)
|
|
||||||
end
|
|
@ -1,13 +0,0 @@
|
|||||||
---
|
|
||||||
-- @submodule Noble.Transition
|
|
||||||
|
|
||||||
class("Cut", nil, Noble.Transition).extends(Noble.Transition)
|
|
||||||
local transition = Noble.Transition.Cut
|
|
||||||
transition.name = "Cut"
|
|
||||||
|
|
||||||
-- Properties
|
|
||||||
transition._type = Noble.Transition.Type.CUT
|
|
||||||
|
|
||||||
--- An all-time classic.
|
|
||||||
-- This transition has no properties.
|
|
||||||
-- @table Noble.Transition.Cut.defaultProperties
|
|
@ -1,37 +0,0 @@
|
|||||||
---
|
|
||||||
-- @submodule Noble.Transition
|
|
||||||
|
|
||||||
class("Dip", nil, Noble.Transition).extends(Noble.Transition)
|
|
||||||
local transition = Noble.Transition.Dip
|
|
||||||
transition.name = "Dip"
|
|
||||||
|
|
||||||
-- Type
|
|
||||||
transition._type = Noble.Transition.Type.COVER
|
|
||||||
|
|
||||||
--- Fade to an image, then to the next scene.
|
|
||||||
-- @table Noble.Transition.Dip.defaultProperties
|
|
||||||
-- @number[opt=0.25] holdTime
|
|
||||||
-- @tparam Graphics.image panelImage
|
|
||||||
-- @tparam[opt=Graphics.image.kDitherTypeBayer4x4] Graphics.image.kDither dither
|
|
||||||
-- @tparam[opt=Ease.outInQuad] Ease ease
|
|
||||||
-- @number[opt=0] x
|
|
||||||
-- @number[opt=0] y
|
|
||||||
transition.defaultProperties = {
|
|
||||||
holdTime = 0.25,
|
|
||||||
ease = Ease.outInQuad,
|
|
||||||
dither = Graphics.image.kDitherTypeBayer4x4,
|
|
||||||
panelImage = nil,
|
|
||||||
x = 0,
|
|
||||||
y = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
function transition:setProperties(__arguments)
|
|
||||||
self.dither = __arguments.dither or self.defaultProperties.dither
|
|
||||||
self.panelImage = __arguments.panelImage or self.defaultProperties.panelImage
|
|
||||||
self.x = __arguments.x or self.defaultProperties.x
|
|
||||||
self.y = __arguments.y or self.defaultProperties.y
|
|
||||||
end
|
|
||||||
|
|
||||||
function transition:draw()
|
|
||||||
self.panelImage:drawFaded(self.x, self.y, self.sequence:get(), self.dither)
|
|
||||||
end
|
|
@ -1,19 +0,0 @@
|
|||||||
---
|
|
||||||
-- @submodule Noble.Transition
|
|
||||||
|
|
||||||
class("DipToBlack", nil, Noble.Transition).extends(Noble.Transition.Dip)
|
|
||||||
local transition = Noble.Transition.DipToBlack
|
|
||||||
transition.name = "Dip to Black"
|
|
||||||
|
|
||||||
--- Fade to black, then to the next scene.
|
|
||||||
-- NOTE: The `panelImage` property is locked.
|
|
||||||
-- @see Noble.Transition.Dip.defaultProperties
|
|
||||||
-- @table Noble.Transition.DipToBlack.defaultProperties
|
|
||||||
|
|
||||||
transition.panelImage = Graphics.image.new(400, 240, Graphics.kColorBlack)
|
|
||||||
|
|
||||||
function transition:setCustomArguments(__arguments)
|
|
||||||
transition.super.setCustomArguments(self, __arguments)
|
|
||||||
self.x = 0
|
|
||||||
self.y = 0
|
|
||||||
end
|
|
@ -1,19 +0,0 @@
|
|||||||
---
|
|
||||||
-- @submodule Noble.Transition
|
|
||||||
|
|
||||||
class("DipToWhite", nil, Noble.Transition).extends(Noble.Transition.Dip)
|
|
||||||
local transition = Noble.Transition.DipToWhite
|
|
||||||
transition.name = "Dip to White"
|
|
||||||
|
|
||||||
--- Fade to white, then to the next scene.
|
|
||||||
-- NOTE: The `panelImage` property is locked.
|
|
||||||
-- @see Noble.Transition.Dip.defaultProperties
|
|
||||||
-- @table Noble.Transition.DipToWhite.defaultProperties
|
|
||||||
|
|
||||||
transition.panelImage = Graphics.image.new(400, 240, Graphics.kColorWhite)
|
|
||||||
|
|
||||||
function transition:setCustomArguments(__arguments)
|
|
||||||
transition.super.setCustomArguments(self, __arguments)
|
|
||||||
self.x = 0
|
|
||||||
self.y = 0
|
|
||||||
end
|
|
@ -1,131 +0,0 @@
|
|||||||
---
|
|
||||||
-- @submodule Noble.Transition
|
|
||||||
|
|
||||||
class("Imagetable", nil, Noble.Transition).extends(Noble.Transition)
|
|
||||||
local transition = Noble.Transition.Imagetable
|
|
||||||
transition.name = "Imagetable"
|
|
||||||
|
|
||||||
-- Type
|
|
||||||
transition._type = Noble.Transition.Type.COVER
|
|
||||||
|
|
||||||
-- Overrides
|
|
||||||
transition.easeEnter = Ease.linear
|
|
||||||
transition.easeExit = Ease.linear
|
|
||||||
|
|
||||||
--- A dip-style transition using one or two imagetables.
|
|
||||||
-- @see Noble.Transition.ImagetableMask.defaultProperties
|
|
||||||
-- @table Noble.Transition.Imagetable.defaultProperties
|
|
||||||
-- @number[opt=0] holdTime
|
|
||||||
-- @tparam Graphics.imagetable imagetable
|
|
||||||
-- @bool[opt=false] reverse
|
|
||||||
-- @bool[opt=false] flipX
|
|
||||||
-- @bool[opt=false] flipY
|
|
||||||
-- @bool[opt=false] rotate
|
|
||||||
-- @tparam Graphics.imagetable imagetableEnter
|
|
||||||
-- @bool[opt=nil] reverseEnter
|
|
||||||
-- @bool[opt=nil] flipXEnter
|
|
||||||
-- @bool[opt=nil] flipYEnter
|
|
||||||
-- @bool[opt=nil] rotateEnter
|
|
||||||
-- @tparam Graphics.imagetable imagetableExit
|
|
||||||
-- @bool[opt=nil] reverseExit
|
|
||||||
-- @bool[opt=nil] flipXExit
|
|
||||||
-- @bool[opt=nil] flipYExit
|
|
||||||
-- @bool[opt=nil] rotateExit
|
|
||||||
transition.defaultProperties = {
|
|
||||||
holdTime = 0,
|
|
||||||
imagetable = nil,
|
|
||||||
imagetableEnter = Graphics.imagetable.new("libraries/noble/assets/images/BoltTransitionEnter"),
|
|
||||||
imagetableExit = Graphics.imagetable.new("libraries/noble/assets/images/BoltTransitionExit"),
|
|
||||||
reverse = false,
|
|
||||||
reverseEnter = nil,
|
|
||||||
reverseExit = nil,
|
|
||||||
flipX = false,
|
|
||||||
flipY = false,
|
|
||||||
flipXEnter = nil,
|
|
||||||
flipYEnter = nil,
|
|
||||||
flipXExit = nil,
|
|
||||||
flipYExit = nil,
|
|
||||||
rotate = false,
|
|
||||||
rotateEnter = nil,
|
|
||||||
rotateExit = nil,
|
|
||||||
}
|
|
||||||
|
|
||||||
function transition:setProperties(__properties)
|
|
||||||
|
|
||||||
self.imagetable = __properties.imagetable or self.defaultProperties.imagetable
|
|
||||||
self.imagetableEnter = __properties.imagetableEnter or self.defaultProperties.imagetableEnter or self.imagetable
|
|
||||||
self.imagetableExit = __properties.imagetableExit or self.defaultProperties.imagetableExit or self.imagetable
|
|
||||||
|
|
||||||
self.reverse = __properties.reverse or self.defaultProperties.reverse
|
|
||||||
self.reverseEnter = __properties.reverseEnter or self.defaultProperties.reverseEnter or self.reverse
|
|
||||||
self.reverseExit = __properties.reverseExit or self.defaultProperties.reverseExit or self.reverse
|
|
||||||
|
|
||||||
self.flipX = __properties.flipX or self.defaultProperties.flipX
|
|
||||||
self.flipY = __properties.flipY or self.defaultProperties.flipY
|
|
||||||
self.flipXEnter = __properties.flipXEnter or self.defaultProperties.flipXEnter or self.flipX
|
|
||||||
self.flipYEnter = __properties.flipYEnter or self.defaultProperties.flipYEnter or self.flipY
|
|
||||||
self.flipXExit = __properties.flipXExit or self.defaultProperties.flipXExit or self.flipX
|
|
||||||
self.flipYExit = __properties.flipYExit or self.defaultProperties.flipYExit or self.flipY
|
|
||||||
|
|
||||||
self.rotate = __properties.rotate or self.defaultProperties.rotate
|
|
||||||
self.rotateEnter = __properties.rotateEnter or self.defaultProperties.rotateEnter or self.rotate
|
|
||||||
self.rotateExit = __properties.rotateExit or self.defaultProperties.rotateExit or self.rotate
|
|
||||||
|
|
||||||
-- "Private" variables
|
|
||||||
self._frameCountEnter = self.imagetableEnter and #self.imagetableEnter or 0
|
|
||||||
self._frameCountExit = self.imagetableExit and #self.imagetableExit or 0
|
|
||||||
|
|
||||||
self._flipValueEnter = Noble.Transition.Imagetable.getFlipValue(self.rotateEnter, self.flipXEnter, self.flipYEnter)
|
|
||||||
self._flipValueExit = Noble.Transition.Imagetable.getFlipValue(self.rotateExit, self.flipXExit, self.flipYExit)
|
|
||||||
|
|
||||||
local sequence0 = (not self.reverseEnter) and 0 or 1
|
|
||||||
local sequence1 = (not self.reverseEnter) and 1 or 0
|
|
||||||
local sequenceExit0 = (not self.reverseExit) and 0 or 1
|
|
||||||
local sequenceExit1 = (not self.reverseExit) and 1 or 0
|
|
||||||
|
|
||||||
if (self.imagetableEnter == self.imagetableExit) then
|
|
||||||
self._sequenceStartValue = sequence0
|
|
||||||
self._sequenceMidpointValue = sequence1
|
|
||||||
self._sequenceResumeValue = sequence1
|
|
||||||
self._sequenceCompleteValue = sequence0
|
|
||||||
else
|
|
||||||
self._sequenceStartValue = sequence0
|
|
||||||
self._sequenceMidpointValue = sequence1
|
|
||||||
self._sequenceResumeValue = sequenceExit0
|
|
||||||
self._sequenceCompleteValue = sequenceExit1
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Warnings
|
|
||||||
if ((__properties.ease or __properties.easeEnter or __properties.easeExit) ~= nil) then
|
|
||||||
warn("BONK: You've specified an ease value for an Noble.Transition.Imagetable transition. This will have no effect.")
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
function transition:draw()
|
|
||||||
local progress = self.sequence:get()
|
|
||||||
local imagetable
|
|
||||||
local frameCount
|
|
||||||
local flipValue
|
|
||||||
if not self.holdTimeElapsed then
|
|
||||||
imagetable = self.imagetableEnter
|
|
||||||
frameCount = self._frameCountEnter
|
|
||||||
flipValue = self._flipValueEnter
|
|
||||||
else
|
|
||||||
imagetable = self.imagetableExit
|
|
||||||
frameCount = self._frameCountExit
|
|
||||||
flipValue = self._flipValueExit
|
|
||||||
end
|
|
||||||
local index = math.clamp((progress * frameCount) // 1, 1, frameCount)
|
|
||||||
imagetable[index]:draw(0, 0, flipValue)
|
|
||||||
end
|
|
||||||
|
|
||||||
function Noble.Transition.Imagetable.getFlipValue(__rotate, __flipX, __flipY)
|
|
||||||
if(__rotate or (__flipX and __flipY)) then
|
|
||||||
return Graphics.kImageFlippedXY
|
|
||||||
else
|
|
||||||
if(__flipX) then return Graphics.kImageFlippedX
|
|
||||||
elseif(__flipY) then return Graphics.kImageFlippedY end
|
|
||||||
end
|
|
||||||
return Graphics.kImageUnflipped
|
|
||||||
end
|
|
@ -1,83 +0,0 @@
|
|||||||
---
|
|
||||||
-- @submodule Noble.Transition
|
|
||||||
|
|
||||||
class("ImagetableMask", nil, Noble.Transition).extends(Noble.Transition)
|
|
||||||
local transition = Noble.Transition.ImagetableMask
|
|
||||||
transition.name = "Imagetable Mask"
|
|
||||||
|
|
||||||
-- Type
|
|
||||||
transition._type = Noble.Transition.Type.MIX
|
|
||||||
|
|
||||||
-- Overrides
|
|
||||||
transition.ease = Ease.linear
|
|
||||||
|
|
||||||
--- A wipe transition using an animated mask in the form of an imagetable.
|
|
||||||
-- @see Noble.Transition.Imagetable.defaultProperties
|
|
||||||
-- @table Noble.Transition.ImagetableMask.defaultProperties
|
|
||||||
-- @tparam Graphics.imagetable imagetable
|
|
||||||
-- @bool[opt=false] reverse Set `true` to play the imagetable's frames in reverse order.
|
|
||||||
-- @bool[opt=false] flipX
|
|
||||||
-- @bool[opt=false] flipY
|
|
||||||
-- @bool[opt=false] rotate Set as `true` to rotate the image 180-degrees
|
|
||||||
-- @bool[opt=true] hasTransparency Set as `true` if the imagetable asset has transparent pixels. Set as `false` if the image uses white pixels for transparency.
|
|
||||||
-- @bool[opt=false] invert Set as `true` to invert the image mask.
|
|
||||||
transition.defaultProperties = {
|
|
||||||
imagetable = Graphics.imagetable.new("libraries/noble/assets/images/BoltTransitionEnter"),
|
|
||||||
reverse = false,
|
|
||||||
flipX = false,
|
|
||||||
flipY = false,
|
|
||||||
rotate = false,
|
|
||||||
hasTransparency = true,
|
|
||||||
invert = false
|
|
||||||
}
|
|
||||||
|
|
||||||
function transition:setProperties(__properties)
|
|
||||||
|
|
||||||
self.imagetable = __properties.imagetable or self.defaultProperties.imagetable
|
|
||||||
self.reverse = __properties.reverse or self.defaultProperties.reverse
|
|
||||||
self.flipX = __properties.flipX or self.defaultProperties.flipX
|
|
||||||
self.flipY = __properties.flipY or self.defaultProperties.flipY
|
|
||||||
self.rotate = __properties.rotate or self.defaultProperties.rotate
|
|
||||||
self.hasTransparency = __properties.hasTransparency or self.defaultProperties.hasTransparency
|
|
||||||
self.invert = __properties.invert or self.defaultProperties.invert
|
|
||||||
|
|
||||||
-- "Private" variables
|
|
||||||
self._flipValue = Noble.Transition.Imagetable.getFlipValue(self.rotate, self.flipX, self.flipY)
|
|
||||||
self._imagetableLength = self.imagetable and #self.imagetable or 0
|
|
||||||
self._maskBackground = nil
|
|
||||||
self._maskForegroundDrawMode = nil
|
|
||||||
if (self.invert ~= true) then
|
|
||||||
self._maskBackground = Graphics.image.new(400, 240, Graphics.kColorWhite)
|
|
||||||
self._maskForegroundDrawMode = Graphics.kDrawModeFillBlack
|
|
||||||
else
|
|
||||||
self._maskBackground = Graphics.image.new(400, 240, Graphics.kColorBlack)
|
|
||||||
self._maskForegroundDrawMode = Graphics.kDrawModeFillWhite
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Warnings
|
|
||||||
if (__properties.imagetableExit ~= nil) then
|
|
||||||
warn("BONK: You've specified an 'imagetableExit' for an Noble.Transition.ImagetableMask transition. This will have no effect. ")
|
|
||||||
end
|
|
||||||
if ((__properties.ease or __properties.easeEnter or __properties.easeExit) ~= nil) then
|
|
||||||
warn("BONK: You've specified an ease value for an Noble.Transition.ImagetableMask transition. This will have no effect.")
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
function transition:draw()
|
|
||||||
local progress = self.sequence:get()
|
|
||||||
local length = self._imagetableLength
|
|
||||||
local index = math.clamp((progress * length) // 1, 1, length)
|
|
||||||
local mask = Graphics.image.new(400, 240)
|
|
||||||
|
|
||||||
Graphics.pushContext(mask)
|
|
||||||
Graphics.setImageDrawMode(Graphics.kDrawModeCopy)
|
|
||||||
self._maskBackground:draw(0,0)
|
|
||||||
if (self.hasTransparency) then Graphics.setImageDrawMode(self._maskForegroundDrawMode) end
|
|
||||||
self.imagetable[index]:draw(0,0, self._flipValue)
|
|
||||||
Graphics.popContext()
|
|
||||||
|
|
||||||
self.oldSceneScreenshot:setMaskImage(mask)
|
|
||||||
self.oldSceneScreenshot:draw(0,0)
|
|
||||||
|
|
||||||
end
|
|
@ -1,58 +0,0 @@
|
|||||||
---
|
|
||||||
-- @submodule Noble.Transition
|
|
||||||
|
|
||||||
class("MetroNexus", nil, Noble.Transition).extends(Noble.Transition)
|
|
||||||
local transition = Noble.Transition.MetroNexus
|
|
||||||
transition.name = "Metro Nexus"
|
|
||||||
|
|
||||||
-- Type
|
|
||||||
transition._type = Noble.Transition.Type.COVER
|
|
||||||
|
|
||||||
-- Overrides
|
|
||||||
transition._sequenceResumeValue = 0
|
|
||||||
transition._sequenceCompleteValue = 1
|
|
||||||
transition.easeEnter = Ease.linear
|
|
||||||
transition.easeExit = Ease.linear
|
|
||||||
|
|
||||||
--- A "cascade" wipe transition, taken from "Metro Nexus" by Noble Robot.
|
|
||||||
-- This transition has no properties.
|
|
||||||
-- @table Noble.Transition.MetroNexus.defaultProperties
|
|
||||||
|
|
||||||
-- "Static" variables
|
|
||||||
local panels
|
|
||||||
|
|
||||||
function transition:setProperties(__arguments)
|
|
||||||
|
|
||||||
if (panels == nil) then
|
|
||||||
panels = {
|
|
||||||
Graphics.image.new(80,240, Graphics.kColorWhite),
|
|
||||||
Graphics.image.new(80,240, Graphics.kColorWhite),
|
|
||||||
Graphics.image.new(80,240, Graphics.kColorWhite),
|
|
||||||
Graphics.image.new(80,240, Graphics.kColorWhite),
|
|
||||||
Graphics.image.new(80,240, Graphics.kColorWhite)
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Warnings
|
|
||||||
if (__arguments.easeEnter or __arguments.easeEnter or __arguments.ease) then
|
|
||||||
warn("BONK: 'Noble.Transition.MetroNexus' does not support custom ease values.")
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
function transition:draw()
|
|
||||||
local progress = self.sequence:get()
|
|
||||||
if (not self.holdTimeElapsed) then
|
|
||||||
panels[1]:draw(000, (-1 + Ease.outQuint(progress, 0, 1, 1)) * 240)
|
|
||||||
panels[2]:draw(080, (-1 + Ease.outQuart(progress, 0, 1, 1)) * 240)
|
|
||||||
panels[3]:draw(160, (-1 + Ease.outQuart(progress, 0, 1, 1)) * 240)
|
|
||||||
panels[4]:draw(240, (-1 + Ease.outCubic(progress, 0, 1, 1)) * 240)
|
|
||||||
panels[5]:draw(320, (-1 + Ease.outSine (progress, 0, 1, 1)) * 240)
|
|
||||||
else
|
|
||||||
panels[1]:draw(000, (1 - Ease.inQuint(progress, 0, 1, 1)) * -240 + 240)
|
|
||||||
panels[2]:draw(080, (1 - Ease.inQuart(progress, 0, 1, 1)) * -240 + 240)
|
|
||||||
panels[3]:draw(160, (1 - Ease.inQuart(progress, 0, 1, 1)) * -240 + 240)
|
|
||||||
panels[4]:draw(240, (1 - Ease.inCubic(progress, 0, 1, 1)) * -240 + 240)
|
|
||||||
panels[5]:draw(320, (1 - Ease.inSine (progress, 0, 1, 1)) * -240 + 240)
|
|
||||||
end
|
|
||||||
end
|
|
@ -1,38 +0,0 @@
|
|||||||
---
|
|
||||||
-- @submodule Noble.Transition
|
|
||||||
|
|
||||||
class("SlideOff", nil, Noble.Transition).extends(Noble.Transition)
|
|
||||||
local transition = Noble.Transition.SlideOff
|
|
||||||
transition.name = "Slide Off"
|
|
||||||
|
|
||||||
-- Type
|
|
||||||
transition._type = Noble.Transition.Type.MIX
|
|
||||||
|
|
||||||
--- The previous scene slides off the screen, revealing the next scene.
|
|
||||||
-- @table Noble.Transition.SlideOff.defaultProperties
|
|
||||||
-- @tparam[opt=Ease.outInQuad] Ease ease
|
|
||||||
-- @number[opt=0] x
|
|
||||||
-- @number[opt=0] y
|
|
||||||
-- @number[opt=0] rotation
|
|
||||||
transition.defaultProperties = {
|
|
||||||
ease = Ease.inQuart,
|
|
||||||
x = 0,
|
|
||||||
y = 0,
|
|
||||||
rotation = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
function transition:setProperties(__arguments)
|
|
||||||
self.x = __arguments.x or self.defaultProperties.x
|
|
||||||
self.y = __arguments.y or self.defaultProperties.y
|
|
||||||
self.rotation = __arguments.rotation or self.defaultProperties.rotation
|
|
||||||
end
|
|
||||||
|
|
||||||
function transition:draw()
|
|
||||||
transition.super.draw(self)
|
|
||||||
local progress = self.sequence:get()
|
|
||||||
self.oldSceneScreenshot:drawRotated(
|
|
||||||
self.x * progress + 200,
|
|
||||||
self.y * progress + 120,
|
|
||||||
self.rotation * progress
|
|
||||||
)
|
|
||||||
end
|
|
@ -1,18 +0,0 @@
|
|||||||
---
|
|
||||||
-- @submodule Noble.Transition
|
|
||||||
|
|
||||||
class("SlideOffDown", nil, Noble.Transition).extends(Noble.Transition.SlideOff)
|
|
||||||
local transition = Noble.Transition.SlideOffDown
|
|
||||||
transition.name = "Slide Off (Down)"
|
|
||||||
|
|
||||||
--- The previous scene slides off the bottom of the screen, revealing the next scene.
|
|
||||||
-- NOTE: The `x`, `y`, and `rotation` properties are locked.
|
|
||||||
-- @see Noble.Transition.SlideOff.defaultProperties
|
|
||||||
-- @table Noble.Transition.SlideOffDown.defaultProperties
|
|
||||||
|
|
||||||
function transition:setProperties(__arguments)
|
|
||||||
transition.super.setProperties(self, __arguments)
|
|
||||||
self.x = 0
|
|
||||||
self.y = 240
|
|
||||||
self.rotation = 0
|
|
||||||
end
|
|
@ -1,18 +0,0 @@
|
|||||||
---
|
|
||||||
-- @submodule Noble.Transition
|
|
||||||
|
|
||||||
class("SlideOffLeft", nil, Noble.Transition).extends(Noble.Transition.SlideOff)
|
|
||||||
local transition = Noble.Transition.SlideOffLeft
|
|
||||||
transition.name = "Slide Off (Left)"
|
|
||||||
|
|
||||||
--- The previous scene slides off the left side of the screen, revealing the next scene.
|
|
||||||
-- NOTE: The `x`, `y`, and `rotation` properties are locked.
|
|
||||||
-- @see Noble.Transition.SlideOff.defaultProperties
|
|
||||||
-- @table Noble.Transition.SlideOffLeft.defaultProperties
|
|
||||||
|
|
||||||
function transition:setProperties(__arguments)
|
|
||||||
transition.super.setProperties(self, __arguments)
|
|
||||||
self.x = -400
|
|
||||||
self.y = 0
|
|
||||||
self.rotation = 0
|
|
||||||
end
|
|
@ -1,18 +0,0 @@
|
|||||||
---
|
|
||||||
-- @submodule Noble.Transition
|
|
||||||
|
|
||||||
class("SlideOffRight", nil, Noble.Transition).extends(Noble.Transition.SlideOff)
|
|
||||||
local transition = Noble.Transition.SlideOffRight
|
|
||||||
transition.name = "Slide Off (Right)"
|
|
||||||
|
|
||||||
--- The previous scene slides off the right side of the screen, revealing the next scene.
|
|
||||||
-- NOTE: The `x`, `y`, and `rotation` properties are locked.
|
|
||||||
-- @see Noble.Transition.SlideOff.defaultProperties
|
|
||||||
-- @table Noble.Transition.SlideOffRight.defaultProperties
|
|
||||||
|
|
||||||
function transition:setProperties(__arguments)
|
|
||||||
transition.super.setProperties(self, __arguments)
|
|
||||||
self.x = 400
|
|
||||||
self.y = 0
|
|
||||||
self.rotation = 0
|
|
||||||
end
|
|
@ -1,18 +0,0 @@
|
|||||||
---
|
|
||||||
-- @submodule Noble.Transition
|
|
||||||
|
|
||||||
class("SlideOffUp", nil, Noble.Transition).extends(Noble.Transition.SlideOff)
|
|
||||||
local transition = Noble.Transition.SlideOffUp
|
|
||||||
transition.name = "Slide Off (Up)"
|
|
||||||
|
|
||||||
--- The previous scene slides off the top of the screen, revealing the next scene.
|
|
||||||
-- NOTE: The `x`, `y`, and `rotation` properties are locked.
|
|
||||||
-- @see Noble.Transition.SlideOff.defaultProperties
|
|
||||||
-- @table Noble.Transition.SlideOffUp.defaultProperties
|
|
||||||
|
|
||||||
function transition:setProperties(__arguments)
|
|
||||||
transition.super.setProperties(self, __arguments)
|
|
||||||
self.x = 0
|
|
||||||
self.y = -240
|
|
||||||
self.rotation = 0
|
|
||||||
end
|
|
@ -1,44 +0,0 @@
|
|||||||
---
|
|
||||||
-- @submodule Noble.Transition
|
|
||||||
|
|
||||||
class("SlideOn", nil, Noble.Transition).extends(Noble.Transition)
|
|
||||||
local transition = Noble.Transition.SlideOn
|
|
||||||
transition.name = "Slide On"
|
|
||||||
|
|
||||||
-- Type
|
|
||||||
transition._type = Noble.Transition.Type.MIX
|
|
||||||
|
|
||||||
-- Overrides
|
|
||||||
transition._sequenceStartValue = 1
|
|
||||||
transition._sequenceCompleteValue = 0
|
|
||||||
transition._captureScreenshotsDuringTransition = true
|
|
||||||
|
|
||||||
--- The next scene slides on the screen, covering up the previous scene.
|
|
||||||
-- @table Noble.Transition.SlideOn.defaultProperties
|
|
||||||
-- @tparam[opt=Ease.outInQuad] Ease ease
|
|
||||||
-- @number[opt=0] x
|
|
||||||
-- @number[opt=0] y
|
|
||||||
-- @number[opt=0] rotation
|
|
||||||
transition.defaultProperties = {
|
|
||||||
ease = Ease.outQuart,
|
|
||||||
x = 0,
|
|
||||||
y = 0,
|
|
||||||
rotation = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
function transition:setProperties(__arguments)
|
|
||||||
self.x = __arguments.x or self.defaultProperties.x
|
|
||||||
self.y = __arguments.y or self.defaultProperties.y
|
|
||||||
self.rotation = __arguments.rotation or self.defaultProperties.rotation
|
|
||||||
end
|
|
||||||
|
|
||||||
function transition:draw()
|
|
||||||
transition.super.draw(self)
|
|
||||||
local progress = self.sequence:get()
|
|
||||||
self.oldSceneScreenshot:draw(0,0)
|
|
||||||
self.newSceneScreenshot:drawRotated(
|
|
||||||
self.x * progress + 200,
|
|
||||||
self.y * progress + 120,
|
|
||||||
self.rotation * progress
|
|
||||||
)
|
|
||||||
end
|
|
@ -1,18 +0,0 @@
|
|||||||
---
|
|
||||||
-- @submodule Noble.Transition
|
|
||||||
|
|
||||||
class("SlideOnDown", nil, Noble.Transition).extends(Noble.Transition.SlideOn)
|
|
||||||
local transition = Noble.Transition.SlideOnDown
|
|
||||||
transition.name = "Slide On (Down)"
|
|
||||||
|
|
||||||
--- The next scene slides onto the screen from the top, covering up the previous scene.
|
|
||||||
-- NOTE: The `x`, `y`, and `rotation` properties are locked.
|
|
||||||
-- @see Noble.Transition.SlideOn.defaultProperties
|
|
||||||
-- @table Noble.Transition.SlideOnDown.defaultProperties
|
|
||||||
|
|
||||||
function transition:setProperties(__arguments)
|
|
||||||
transition.super.setProperties(self, __arguments)
|
|
||||||
self.x = 0
|
|
||||||
self.y = -240
|
|
||||||
self.rotation = 0
|
|
||||||
end
|
|
@ -1,18 +0,0 @@
|
|||||||
---
|
|
||||||
-- @submodule Noble.Transition
|
|
||||||
|
|
||||||
class("SlideOnLeft", nil, Noble.Transition).extends(Noble.Transition.SlideOn)
|
|
||||||
local transition = Noble.Transition.SlideOnLeft
|
|
||||||
transition.name = "Slide On (Left)"
|
|
||||||
|
|
||||||
--- The next scene slides onto the screen right-to-left, covering up the previous scene.
|
|
||||||
-- NOTE: The `x`, `y`, and `rotation` properties are locked.
|
|
||||||
-- @see Noble.Transition.SlideOn.defaultProperties
|
|
||||||
-- @table Noble.Transition.SlideOnLeft.defaultProperties
|
|
||||||
|
|
||||||
function transition:setProperties(__arguments)
|
|
||||||
transition.super.setProperties(self, __arguments)
|
|
||||||
self.x = 400
|
|
||||||
self.y = 0
|
|
||||||
self.rotation = 0
|
|
||||||
end
|
|
@ -1,18 +0,0 @@
|
|||||||
---
|
|
||||||
-- @submodule Noble.Transition
|
|
||||||
|
|
||||||
class("SlideOnRight", nil, Noble.Transition).extends(Noble.Transition.SlideOn)
|
|
||||||
local transition = Noble.Transition.SlideOnRight
|
|
||||||
transition.name = "Slide On (Right)"
|
|
||||||
|
|
||||||
--- The next scene slides onto the screen left-to-right, covering up the previous scene.
|
|
||||||
-- NOTE: The `x`, `y`, and `rotation` properties are locked.
|
|
||||||
-- @see Noble.Transition.SlideOn.defaultProperties
|
|
||||||
-- @table Noble.Transition.SlideOnRight.defaultProperties
|
|
||||||
|
|
||||||
function transition:setProperties(__arguments)
|
|
||||||
transition.super.setProperties(self, __arguments)
|
|
||||||
self.x = -400
|
|
||||||
self.y = 0
|
|
||||||
self.rotation = 0
|
|
||||||
end
|
|
@ -1,18 +0,0 @@
|
|||||||
---
|
|
||||||
-- @submodule Noble.Transition
|
|
||||||
|
|
||||||
class("SlideOnUp", nil, Noble.Transition).extends(Noble.Transition.SlideOn)
|
|
||||||
local transition = Noble.Transition.SlideOnUp
|
|
||||||
transition.name = "Slide On (Up)"
|
|
||||||
|
|
||||||
--- The next scene slides onto the screen from the bottom, covering up the previous scene.
|
|
||||||
-- NOTE: The `x`, `y`, and `rotation` properties are locked.
|
|
||||||
-- @see Noble.Transition.SlideOn.defaultProperties
|
|
||||||
-- @table Noble.Transition.SlideOnUp.defaultProperties
|
|
||||||
|
|
||||||
function transition:setProperties(__arguments)
|
|
||||||
transition.super.setProperties(self, __arguments)
|
|
||||||
self.x = 0
|
|
||||||
self.y = 240
|
|
||||||
self.rotation = 0
|
|
||||||
end
|
|
@ -1,100 +0,0 @@
|
|||||||
---
|
|
||||||
-- @submodule Noble.Transition
|
|
||||||
|
|
||||||
class("Spotlight", nil, Noble.Transition).extends(Noble.Transition)
|
|
||||||
local transition = Noble.Transition.Spotlight
|
|
||||||
transition.name = "Spotlight"
|
|
||||||
|
|
||||||
-- Type
|
|
||||||
transition._type = Noble.Transition.Type.COVER
|
|
||||||
|
|
||||||
--- A spotlight in-out transition.
|
|
||||||
-- @see Noble.Transition.SpotlightMask.defaultProperties
|
|
||||||
-- @table Noble.Transition.Spotlight.defaultProperties
|
|
||||||
-- @number[opt=0.25] holdTime
|
|
||||||
-- @tparam Graphics.image panelImage
|
|
||||||
-- @tparam[opt=Graphics.image.kDitherTypeBayer4x4] Graphics.image.kDither dither
|
|
||||||
-- @tparam[opt=Ease.outInQuad] Ease ease
|
|
||||||
-- @number[opt=200] x
|
|
||||||
-- @number[opt=120] y
|
|
||||||
-- @tparam[opt=nil] Ease easeEnter
|
|
||||||
-- @number[opt=nil] xEnter
|
|
||||||
-- @number[opt=nil] yEnter
|
|
||||||
-- @number[opt=nil] xEnterStart
|
|
||||||
-- @number[opt=nil] yEnterStart
|
|
||||||
-- @number[opt=nil] xEnterEnd
|
|
||||||
-- @number[opt=nil] yEnterEnd
|
|
||||||
-- @tparam[opt=nil] Ease easeEnter
|
|
||||||
-- @number[opt=nil] xExit
|
|
||||||
-- @number[opt=nil] yExit
|
|
||||||
-- @number[opt=nil] xExitStart
|
|
||||||
-- @number[opt=nil] yExitStart
|
|
||||||
-- @number[opt=nil] xExitEnd
|
|
||||||
-- @number[opt=nil] yExitEnd
|
|
||||||
transition.defaultProperties = {
|
|
||||||
holdTime = 0.25,
|
|
||||||
panelImage = nil,
|
|
||||||
dither = Graphics.image.kDitherTypeBayer4x4,
|
|
||||||
ease = Ease.outInQuad,
|
|
||||||
x = 200,
|
|
||||||
y = 120,
|
|
||||||
easeEnter = nil,
|
|
||||||
xEnter = nil,
|
|
||||||
yEnter = nil,
|
|
||||||
xEnterStart = nil,
|
|
||||||
yEnterStart = nil,
|
|
||||||
xEnterEnd = nil,
|
|
||||||
yEnterEnd = nil,
|
|
||||||
easeExit = nil,
|
|
||||||
xExit = nil,
|
|
||||||
yExit = nil,
|
|
||||||
xExitStart = nil,
|
|
||||||
yExitStart = nil,
|
|
||||||
xExitEnd = nil,
|
|
||||||
yExitEnd = nil
|
|
||||||
}
|
|
||||||
|
|
||||||
-- "Static" variables
|
|
||||||
local defaultPanelImage
|
|
||||||
|
|
||||||
function transition:setProperties(__arguments)
|
|
||||||
if (defaultPanelImage == nil) then defaultPanelImage = Graphics.image.new(400,240, Graphics.kColorBlack) end
|
|
||||||
self.panelImage = __arguments.panelImage or self.defaultProperties.panelImage or defaultPanelImage
|
|
||||||
self.dither = __arguments.dither or self.defaultProperties.dither
|
|
||||||
self.x = __arguments.x or self.defaultProperties.x
|
|
||||||
self.y = __arguments.y or self.defaultProperties.y
|
|
||||||
|
|
||||||
self.xEnter = __arguments.xEnter or self.defaultProperties.xEnter or self.x
|
|
||||||
self.yEnter = __arguments.yEnter or self.defaultProperties.yEnter or self.y
|
|
||||||
self.xEnterStart = __arguments.xEnterStart or self.defaultProperties.xEnterStart or self.xEnter
|
|
||||||
self.yEnterStart = __arguments.yEnterStart or self.defaultProperties.yEnterStart or self.yEnter
|
|
||||||
self.xEnterEnd = __arguments.xEnterEnd or self.defaultProperties.xEnterEnd or self.xEnter
|
|
||||||
self.yEnterEnd = __arguments.yEnterEnd or self.defaultProperties.yEnterEnd or self.yEnter
|
|
||||||
|
|
||||||
self.xExit = __arguments.xExit or self.defaultProperties.xExit or self.x
|
|
||||||
self.yExit = __arguments.yExit or self.defaultProperties.yExit or self.y
|
|
||||||
self.xExitStart = __arguments.xExitStart or self.defaultProperties.xExitStart or self.xExit
|
|
||||||
self.yExitStart = __arguments.yExitStart or self.defaultProperties.yExitStart or self.yExit
|
|
||||||
self.xExitEnd = __arguments.xExitEnd or self.defaultProperties.xExitEnd or self.xExit
|
|
||||||
self.yExitEnd = __arguments.yExitEnd or self.defaultProperties.yExitEnd or self.yExit
|
|
||||||
end
|
|
||||||
|
|
||||||
function transition:draw()
|
|
||||||
local progress = self.sequence:get()
|
|
||||||
self.panelImage:drawFaded(0, 0, progress, self.dither)
|
|
||||||
Graphics.setColor(Graphics.kColorClear)
|
|
||||||
if (not self.midpointReached) then
|
|
||||||
Graphics.fillCircleAtPoint(
|
|
||||||
math.lerp(self.xEnterStart, self.xEnterEnd, progress),
|
|
||||||
math.lerp(self.yEnterStart, self.yEnterEnd, progress),
|
|
||||||
(1 - progress) * 233
|
|
||||||
)
|
|
||||||
else
|
|
||||||
Graphics.fillCircleAtPoint(
|
|
||||||
math.lerp(self.xExitStart, self.xExitEnd, progress),
|
|
||||||
math.lerp(self.yExitStart, self.yExitEnd, progress),
|
|
||||||
(1 - progress) * 233
|
|
||||||
)
|
|
||||||
end
|
|
||||||
Graphics.setColor(Graphics.kColorBlack)
|
|
||||||
end
|
|
@ -1,99 +0,0 @@
|
|||||||
---
|
|
||||||
-- @submodule Noble.Transition
|
|
||||||
|
|
||||||
class("SpotlightMask", nil, Noble.Transition).extends(Noble.Transition)
|
|
||||||
local transition = Noble.Transition.SpotlightMask
|
|
||||||
transition.name = "Spotlight Mask"
|
|
||||||
|
|
||||||
-- Type
|
|
||||||
transition._type = Noble.Transition.Type.MIX
|
|
||||||
|
|
||||||
--- A circle wipe transition.
|
|
||||||
-- @see Noble.Transition.Spotlight.defaultProperties
|
|
||||||
-- @table Noble.Transition.SpotlightMask.defaultProperties
|
|
||||||
-- @tparam[opt=Ease.outQuad] Ease ease
|
|
||||||
-- @number[opt=200] x
|
|
||||||
-- @number[opt=120] y
|
|
||||||
-- @number[opt=nil] xStart
|
|
||||||
-- @number[opt=nil] yStart
|
|
||||||
-- @number[opt=nil] xEnd
|
|
||||||
-- @number[opt=nil] yEnd
|
|
||||||
-- @bool[opt=false] invert
|
|
||||||
transition.defaultProperties = {
|
|
||||||
ease = Ease.outQuad,
|
|
||||||
x = 200,
|
|
||||||
y = 120,
|
|
||||||
xStart = nil,
|
|
||||||
yStart = nil,
|
|
||||||
xEnd = nil,
|
|
||||||
yEnd = nil,
|
|
||||||
invert = false
|
|
||||||
}
|
|
||||||
|
|
||||||
function transition:setProperties(__arguments)
|
|
||||||
self.x = __arguments.x or self.defaultProperties.x
|
|
||||||
self.y = __arguments.y or self.defaultProperties.y
|
|
||||||
self.xStart = __arguments.xStart or self.defaultProperties.xStart or self.x
|
|
||||||
self.yStart = __arguments.yStart or self.defaultProperties.yStart or self.y
|
|
||||||
self.xEnd = __arguments.xEnd or self.defaultProperties.xEnd or self.x
|
|
||||||
self.yEnd = __arguments.yEnd or self.defaultProperties.yEnd or self.y
|
|
||||||
|
|
||||||
self.invert = __arguments.invert or self.defaultProperties.invert
|
|
||||||
|
|
||||||
if (self.invert) then
|
|
||||||
self.ease = Ease.reverse(self.ease)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- "Private" variables
|
|
||||||
self._maskBackground = nil
|
|
||||||
self._maskForegroundDrawMode = nil
|
|
||||||
if (self.invert ~= true) then
|
|
||||||
self._maskBackground = Graphics.image.new(400, 240, Graphics.kColorWhite)
|
|
||||||
self._maskForegroundDrawMode = Graphics.kDrawModeFillBlack
|
|
||||||
else
|
|
||||||
self._maskBackground = Graphics.image.new(400, 240, Graphics.kColorBlack)
|
|
||||||
self._maskForegroundDrawMode = Graphics.kDrawModeFillWhite
|
|
||||||
end
|
|
||||||
|
|
||||||
self._startRadius = math.max(
|
|
||||||
Geometry.distanceToPoint(self.xStart, self.yStart, 0, 0),
|
|
||||||
Geometry.distanceToPoint(self.xStart, self.yStart, 400, 0),
|
|
||||||
Geometry.distanceToPoint(self.xStart, self.yStart, 400, 240),
|
|
||||||
Geometry.distanceToPoint(self.xStart, self.yStart, 0, 240)
|
|
||||||
)
|
|
||||||
self._endRadius = math.max(
|
|
||||||
Geometry.distanceToPoint(self.xEnd, self.yEnd, 0, 0),
|
|
||||||
Geometry.distanceToPoint(self.xEnd, self.yEnd, 400, 0),
|
|
||||||
Geometry.distanceToPoint(self.xEnd, self.yEnd, 400, 240),
|
|
||||||
Geometry.distanceToPoint(self.xEnd, self.yEnd, 0, 240)
|
|
||||||
)
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
function transition:draw()
|
|
||||||
local progress = self.sequence:get()
|
|
||||||
|
|
||||||
if (not self.invert) then
|
|
||||||
self.oldSceneScreenshot:draw(0, 0)
|
|
||||||
Graphics.setColor(Graphics.kColorClear)
|
|
||||||
Graphics.fillCircleAtPoint(
|
|
||||||
math.lerp(self.xStart, self.xEnd, progress),
|
|
||||||
math.lerp(self.yStart, self.yEnd, progress),
|
|
||||||
progress * self._endRadius
|
|
||||||
)
|
|
||||||
Graphics.setColor(Graphics.kColorBlack)
|
|
||||||
else
|
|
||||||
local mask = Graphics.image.new(400, 240, Graphics.kColorBlack)
|
|
||||||
Graphics.pushContext(mask)
|
|
||||||
Graphics.setColor(Graphics.kColorWhite)
|
|
||||||
Graphics.fillCircleAtPoint(
|
|
||||||
math.lerp(self.xStart, self.xEnd, progress),
|
|
||||||
math.lerp(self.yStart, self.yEnd, progress),
|
|
||||||
(1 - progress) * self._startRadius
|
|
||||||
)
|
|
||||||
Graphics.popContext()
|
|
||||||
self.oldSceneScreenshot:setMaskImage(mask)
|
|
||||||
self.oldSceneScreenshot:draw(0, 0)
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
@ -1,73 +0,0 @@
|
|||||||
---
|
|
||||||
-- @submodule Noble.Transition
|
|
||||||
|
|
||||||
class("WidgetSatchel", nil, Noble.Transition).extends(Noble.Transition)
|
|
||||||
local transition = Noble.Transition.WidgetSatchel
|
|
||||||
transition.name = "Widget Satchel"
|
|
||||||
|
|
||||||
-- Type
|
|
||||||
transition._type = Noble.Transition.Type.COVER
|
|
||||||
|
|
||||||
-- Overrides
|
|
||||||
transition._sequenceCompleteValue = 2
|
|
||||||
transition.easeEnter = Ease.outCubic
|
|
||||||
transition.easeExit = Ease.inCubic
|
|
||||||
|
|
||||||
--- An "accordion" transition, taken from "Widget Satchel" by Noble Robot.
|
|
||||||
-- This transition has no properties.
|
|
||||||
-- @table Noble.Transition.MetroNexus.defaultProperties
|
|
||||||
|
|
||||||
-- "Static" variables
|
|
||||||
local panels
|
|
||||||
|
|
||||||
function transition:setProperties(__arguments)
|
|
||||||
|
|
||||||
if (panels == nil) then
|
|
||||||
panels = {
|
|
||||||
Graphics.image.new(400,48, Graphics.kColorWhite),
|
|
||||||
Graphics.image.new(400,48, Graphics.kColorWhite),
|
|
||||||
Graphics.image.new(400,48, Graphics.kColorWhite),
|
|
||||||
Graphics.image.new(400,48, Graphics.kColorWhite),
|
|
||||||
Graphics.image.new(400,48, Graphics.kColorWhite)
|
|
||||||
}
|
|
||||||
Graphics.lockFocus(panels[1])
|
|
||||||
Graphics.setDitherPattern(0.4, Graphics.image.kDitherTypeScreen)
|
|
||||||
Graphics.fillRect(0,0,400,48)
|
|
||||||
Graphics.lockFocus(panels[2])
|
|
||||||
Graphics.setDitherPattern(0.7, Graphics.image.kDitherTypeScreen)
|
|
||||||
Graphics.fillRect(0,0,400,48)
|
|
||||||
Graphics.lockFocus(panels[3])
|
|
||||||
Graphics.setDitherPattern(0.25, Graphics.image.kDitherTypeBayer8x8)
|
|
||||||
Graphics.fillRect(0,0,400,48)
|
|
||||||
Graphics.lockFocus(panels[4])
|
|
||||||
Graphics.setDitherPattern(0.5, Graphics.image.kDitherTypeDiagonalLine)
|
|
||||||
Graphics.fillRect(0,0,400,48)
|
|
||||||
Graphics.lockFocus(panels[5])
|
|
||||||
Graphics.setDitherPattern(0.8, Graphics.image.kDitherTypeHorizontalLine)
|
|
||||||
Graphics.fillRect(0,0,400,48)
|
|
||||||
Graphics.unlockFocus()
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Warnings
|
|
||||||
if (__arguments.easeEnter or __arguments.easeEnter or __arguments.ease) then
|
|
||||||
warn("BONK: 'Noble.Transition.WidgetSatchel' does not support custom ease values.")
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
function transition:draw()
|
|
||||||
local progress = self.sequence:get()
|
|
||||||
if (not self.midpointReached ) then
|
|
||||||
panels[1]:draw(0, -48 + (progress * (48*1)) )
|
|
||||||
panels[2]:draw(0, -48 + (progress * (48*2)) )
|
|
||||||
panels[3]:draw(0, -48 + (progress * (48*3)) )
|
|
||||||
panels[4]:draw(0, -48 + (progress * (48*4)) )
|
|
||||||
panels[5]:draw(0, -48 + (progress * (48*5)) )
|
|
||||||
else
|
|
||||||
panels[1]:draw(0, 48*0 + (progress - 1) * 48*5)
|
|
||||||
panels[2]:draw(0, 48*1 + (progress - 1) * 48*4)
|
|
||||||
panels[3]:draw(0, 48*2 + (progress - 1) * 48*3)
|
|
||||||
panels[4]:draw(0, 48*3 + (progress - 1) * 48*2)
|
|
||||||
panels[5]:draw(0, 48*4 + (progress - 1) * 48*1)
|
|
||||||
end
|
|
||||||
end
|
|
@ -1,242 +0,0 @@
|
|||||||
---
|
|
||||||
-- An abstract scene class.
|
|
||||||
-- Do not copy this file as a template for your scenes. Instead, your scenes will extend this class.
|
|
||||||
-- See <a href="../examples/SceneTemplate.lua.html">templates/SceneTemplate.lua</a> for a blank scene that you can copy and modify for your own scenes.
|
|
||||||
-- If you are using <a href="http://github.com/NobleRobot/NobleEngine-ProjectTemplate">NobleEngine-ProjectTemplate</a>,
|
|
||||||
-- see `scenes/ExampleScene.lua` for an implementation example.
|
|
||||||
-- @usage
|
|
||||||
-- YourSceneName = {}
|
|
||||||
-- class("YourSceneName").extends(NobleScene)
|
|
||||||
-- local scene = YourSceneName
|
|
||||||
--
|
|
||||||
-- @classmod NobleScene
|
|
||||||
--
|
|
||||||
|
|
||||||
NobleScene = {}
|
|
||||||
class("NobleScene").extends(Object)
|
|
||||||
|
|
||||||
--- Properties
|
|
||||||
-- @section properties
|
|
||||||
|
|
||||||
--- The name of this scene. Optional.
|
|
||||||
-- If you do not set this value, it will take on the scene's `className`.
|
|
||||||
NobleScene.name = ""
|
|
||||||
|
|
||||||
--- This is the background color of this scene.
|
|
||||||
--
|
|
||||||
NobleScene.backgroundColor = Graphics.kColorWhite
|
|
||||||
|
|
||||||
--- Tables
|
|
||||||
-- @section tables
|
|
||||||
|
|
||||||
--- All scenes have a default inputHandler which is made active when the scene starts.
|
|
||||||
-- If you do not define your scene's `inputHandler`, it is `nil` and input is disabled when this scene
|
|
||||||
-- starts.
|
|
||||||
-- @see Noble.Input.setHandler
|
|
||||||
--
|
|
||||||
-- @usage
|
|
||||||
-- YourSceneName.inputHandler = {
|
|
||||||
-- AButtonDown = function()
|
|
||||||
-- // Your code here
|
|
||||||
-- end,
|
|
||||||
-- AButtonHold = function()
|
|
||||||
-- // Your code here
|
|
||||||
-- end,
|
|
||||||
-- -- ...
|
|
||||||
-- -- ...
|
|
||||||
-- }
|
|
||||||
-- -- OR...
|
|
||||||
-- -- Use a non-scene-specific inputHandler, defined elsewhere.
|
|
||||||
-- YourSceneName.inputHandler = somePreviouslyDefinedInputHandler
|
|
||||||
-- -- OR...
|
|
||||||
-- -- Reuse another scene's inputHandler.
|
|
||||||
-- YourSceneName.inputHandler = SomeOtherSceneName.inputHandler
|
|
||||||
NobleScene.inputHandler = {}
|
|
||||||
|
|
||||||
--- When you add a sprite to your scene, it is put in this table so the scene can keep track of it.
|
|
||||||
--
|
|
||||||
-- This is intended as `read-only`. You should not modify this table directly.
|
|
||||||
-- @see addSprite
|
|
||||||
NobleScene.sprites = {}
|
|
||||||
|
|
||||||
--- Methods
|
|
||||||
-- @section Methods
|
|
||||||
|
|
||||||
--- Use this to add sprites to your scene instead of `playdate.graphics.sprite:add()`.
|
|
||||||
--
|
|
||||||
-- If your sprite is a `NobleSprite`, using `NobleSprite:add()` will also call this method.
|
|
||||||
--
|
|
||||||
-- Sprites added with this method that are tracked by the scene. Any not manually removed before transitioning to another scene are automatically removed in @{finish|finish}.
|
|
||||||
-- @tparam playdate.graphics.sprite __sprite The sprite to add to the scene.
|
|
||||||
-- @see NobleSprite:add
|
|
||||||
-- @see removeSprite
|
|
||||||
function NobleScene:addSprite(__sprite)
|
|
||||||
if (__sprite.isNobleSprite == true) then
|
|
||||||
__sprite:superAdd()
|
|
||||||
else
|
|
||||||
__sprite:add()
|
|
||||||
end
|
|
||||||
|
|
||||||
if (table.indexOfElement(self.sprites, __sprite) == nil) then
|
|
||||||
table.insert(self.sprites, __sprite)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Use this to remove sprites from your scene instead of `playdate.graphics.sprite:remove()`.
|
|
||||||
--
|
|
||||||
-- If your sprite is a `NobleSprite`, using `NobleSprite:remove()` will also call this method.
|
|
||||||
--
|
|
||||||
-- Sprites not manually removed before transitioning to another scene are automatically removed in @{finish|finish}.
|
|
||||||
-- @tparam playdate.graphics.sprite __sprite The sprite to add to the scene.
|
|
||||||
-- @see NobleSprite:remove
|
|
||||||
-- @see addSprite
|
|
||||||
function NobleScene:removeSprite(__sprite)
|
|
||||||
if (__sprite.isNobleSprite == true) then
|
|
||||||
__sprite:superRemove()
|
|
||||||
else
|
|
||||||
__sprite:remove()
|
|
||||||
end
|
|
||||||
|
|
||||||
if (table.indexOfElement(self.sprites, __sprite) ~= nil) then
|
|
||||||
table.remove(self.sprites, table.indexOfElement(self.sprites, __sprite))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Callbacks
|
|
||||||
-- @section callbacks
|
|
||||||
|
|
||||||
--- Implement this in your scene if you have code to run when your scene's object is created.
|
|
||||||
--
|
|
||||||
-- @usage
|
|
||||||
-- function YourSceneName:init()
|
|
||||||
-- YourSceneName.super.init(self)
|
|
||||||
-- --[Your code here]--
|
|
||||||
-- end
|
|
||||||
--
|
|
||||||
function NobleScene:init()
|
|
||||||
self.name = self.className
|
|
||||||
self.sprites = {}
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Implement if you want to run code as the transition to this scene begins, such as UI animation, triggers, etc.
|
|
||||||
--
|
|
||||||
-- @usage
|
|
||||||
-- function YourSceneName:enter()
|
|
||||||
-- YourSceneName.super.enter(self)
|
|
||||||
-- --[Your code here]--
|
|
||||||
-- end
|
|
||||||
--
|
|
||||||
function NobleScene:enter() end
|
|
||||||
|
|
||||||
--- Implement if you have code to run once the transition to this scene is complete. This method signifies the full activation of a scene. If this scene's `inputHandler` is defined, it is enabled now.
|
|
||||||
-- @see inputHandler
|
|
||||||
-- @usage
|
|
||||||
-- function YourSceneName:start()
|
|
||||||
-- YourSceneName.super.start(self)
|
|
||||||
-- --[Your code here]--
|
|
||||||
-- end
|
|
||||||
--
|
|
||||||
function NobleScene:start()
|
|
||||||
Noble.Input.setHandler(self.inputHandler)
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Implement to run scene-specific code on every frame while this scene is active.
|
|
||||||
-- <strong>NOTE:</strong> you may use coroutine.yield() here, because it only runs inside of playdate.update(), which is a coroutine.
|
|
||||||
--
|
|
||||||
-- @usage
|
|
||||||
-- function YourSceneName:update()
|
|
||||||
-- YourSceneName.super.update(self)
|
|
||||||
-- --[Your code here]--
|
|
||||||
-- end
|
|
||||||
--
|
|
||||||
function NobleScene:update() end
|
|
||||||
|
|
||||||
--- Implement this function to draw background visual elements in your scene.
|
|
||||||
--- This runs when the engine need to redraw a background area.
|
|
||||||
--- By default it runs every frame and fills the background with self.backgroundColor. All arguments are optional.
|
|
||||||
--- Use `Graphics.sprite.setAlwaysRedraw(false)` after `Noble.new()` to optimize partial redraw.
|
|
||||||
--
|
|
||||||
-- @usage
|
|
||||||
-- function YourSceneName:drawBackground(__x, __y, __width, __height)
|
|
||||||
-- YourSceneName.super.drawBackground(self) -- optional, invokes default behavior.
|
|
||||||
-- --[Your code here]--
|
|
||||||
-- end
|
|
||||||
--
|
|
||||||
function NobleScene:drawBackground(__x, __y, __width, __height)
|
|
||||||
__x = __x or 0
|
|
||||||
__y = __y or 0
|
|
||||||
__width = __width or Display.getWidth()
|
|
||||||
__height = __height or Display.getHeight()
|
|
||||||
|
|
||||||
-- Cache the currently set color/pattern.
|
|
||||||
local color <const> = Graphics.getColor()
|
|
||||||
local color_type <const> = type(color)
|
|
||||||
|
|
||||||
-- Draw background.
|
|
||||||
Graphics.setColor(self.backgroundColor)
|
|
||||||
Graphics.fillRect(__x, __y, __width, __height)
|
|
||||||
|
|
||||||
-- Reset color/pattern from cache.
|
|
||||||
if color_type == 'number' then
|
|
||||||
Graphics.setColor(color)
|
|
||||||
elseif color_type == 'table' then
|
|
||||||
Graphics.setPattern(color)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Implement this in your scene if you have "goodbye" code to run when a transition to another scene
|
|
||||||
-- begins, such as UI animation, saving to disk, etc.
|
|
||||||
--
|
|
||||||
-- @usage
|
|
||||||
-- function YourSceneName:exit()
|
|
||||||
-- YourSceneName.super.exit(self)
|
|
||||||
-- --[Your code here]--
|
|
||||||
-- end
|
|
||||||
--
|
|
||||||
function NobleScene:exit()
|
|
||||||
for _, sprite in ipairs(self.sprites) do
|
|
||||||
sprite:setUpdatesEnabled(false)
|
|
||||||
sprite:setCollisionsEnabled(false)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Implement this in your scene if you have code to run when a transition to another scene
|
|
||||||
-- is complete, such as resetting variables.
|
|
||||||
--
|
|
||||||
-- @usage
|
|
||||||
-- function YourSceneName:finish()
|
|
||||||
-- YourSceneName.super.finish(self)
|
|
||||||
-- --[Your code here]--
|
|
||||||
-- end
|
|
||||||
--
|
|
||||||
function NobleScene:finish()
|
|
||||||
for _, sprite in ipairs(self.sprites) do
|
|
||||||
if (sprite.isNobleSprite) then
|
|
||||||
sprite:superRemove()
|
|
||||||
else
|
|
||||||
sprite:remove()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--- `pause()` / `resume()`
|
|
||||||
--
|
|
||||||
-- Implement one or both of these in your scene if you want something to happen when the game is paused/unpaused
|
|
||||||
-- by the system. The Playdate SDK does not require you to write pause logic, but these are useful if you want a
|
|
||||||
-- custom menu image (see Playdate SDK for more details), want to obscure game elements to prevent players from
|
|
||||||
-- cheating in a time-sensitive game, want to count the number of times the player pauses the game, etc.
|
|
||||||
--
|
|
||||||
-- @usage
|
|
||||||
-- function YourSceneName:pause()
|
|
||||||
-- YourSceneName.super.pause(self)
|
|
||||||
-- --[Your code here]--
|
|
||||||
-- end
|
|
||||||
function NobleScene:pause() end
|
|
||||||
|
|
||||||
--- <span></span>
|
|
||||||
-- @usage
|
|
||||||
-- function YourSceneName:resume()
|
|
||||||
-- YourSceneName.super.resume(self)
|
|
||||||
-- --[Your code here]--
|
|
||||||
-- end
|
|
||||||
function NobleScene:resume() end
|
|
@ -1,149 +0,0 @@
|
|||||||
---
|
|
||||||
-- An extension of Playdate's sprite object, incorporating `Noble.Animation` and other Noble Engine features.
|
|
||||||
-- Use this in place of `playdate.graphics.sprite` in most cases.
|
|
||||||
--
|
|
||||||
-- `NobleSprite` is a child class of `playdate.graphics.sprite`, so see the Playdate SDK documentation for additional methods and properties.
|
|
||||||
--
|
|
||||||
-- @classmod NobleSprite
|
|
||||||
--
|
|
||||||
|
|
||||||
NobleSprite = {}
|
|
||||||
class("NobleSprite").extends(Graphics.sprite)
|
|
||||||
|
|
||||||
--- Do not call an "init" method directly. Use `NobleSprite()` (see usage examples).
|
|
||||||
-- @string[opt] __view This can be: the path to an image or spritesheet image file, an image object (`Graphics.image`) or an animation object (`Noble.Animation`)
|
|
||||||
-- @bool[opt=false] __viewIsSpritesheet Set this to `true` to indicate that `__view` is a spritesheet. Will only be considered if `__view` is a string path to an image.
|
|
||||||
-- @bool[opt=false] __singleState If this sprite has just one animation, set this to true. It saves you from having to use Noble.Animation.addState()
|
|
||||||
-- @bool[opt=true] __singleStateLoop If using a single state animation, should it loop?
|
|
||||||
--
|
|
||||||
-- @usage
|
|
||||||
-- -- Provide a spritesheet image file to create a new `Noble.Animation` for a NobleSprite's view.
|
|
||||||
-- myNobleSprite = NobleSprite("path/to/spritesheet", true)
|
|
||||||
--
|
|
||||||
-- @usage
|
|
||||||
-- -- Provide an image file to create a new `Graphics.image` for a NobleSprite's view.
|
|
||||||
-- myNobleSprite = NobleSprite("path/to/image")
|
|
||||||
--
|
|
||||||
-- @usage
|
|
||||||
-- -- Use an existing `Noble.Animation` for a NobleSprite's view.
|
|
||||||
-- local myAnimation = Noble.Animation.new("path/to/spritesheet")
|
|
||||||
-- myAnimation:addState("default", 1, animation.imageTable:getLength(), nil, true)
|
|
||||||
-- myNobleSprite = NobleSprite(myAnimation)
|
|
||||||
--
|
|
||||||
-- @usage
|
|
||||||
-- -- Use an existing `Graphics.image` object for a NobleSprite's view.
|
|
||||||
-- local myImage = Graphics.image.new("path/to/image")
|
|
||||||
-- myNobleSprite = NobleSprite(myImage)
|
|
||||||
--
|
|
||||||
-- @usage
|
|
||||||
-- -- Extending NobleSprite.
|
|
||||||
--
|
|
||||||
-- -- MyCustomSprite.lua
|
|
||||||
-- MyCustomSprite = {}
|
|
||||||
-- class("MyCustomSprite").extends(NobleSprite)
|
|
||||||
--
|
|
||||||
-- function MyCustomSprite:init(__x, __y, __anotherFunArgument)
|
|
||||||
-- MyCustomSprite.super.init(self, "path/to/spritesheet", true)
|
|
||||||
-- -- Etc. etc.
|
|
||||||
-- end
|
|
||||||
--
|
|
||||||
-- -- MyNobleScene.lua
|
|
||||||
-- myNobleSprite = MyCustomSprite(100, 100, "Fun!")
|
|
||||||
--
|
|
||||||
-- @see Noble.Animation:addState
|
|
||||||
-- @see Noble.Animation.new
|
|
||||||
--
|
|
||||||
function NobleSprite:init(__view, __viewIsSpritesheet, __singleState, __singleStateLoop)
|
|
||||||
NobleSprite.super.init(self)
|
|
||||||
self.isNobleSprite = true -- This is important so other methods don't confuse this for a playdate.graphics.sprite. DO NOT modify this value at runtime.
|
|
||||||
if (__view ~= nil) then
|
|
||||||
-- __view is the path to an image or spritesheet file.
|
|
||||||
if (type(__view) == "string") then
|
|
||||||
self.animated = __viewIsSpritesheet -- NO NOT modify self.animated at runtime.
|
|
||||||
|
|
||||||
if (__viewIsSpritesheet == true) then
|
|
||||||
-- Create a new Noble.Animation object.
|
|
||||||
|
|
||||||
--- The animation for this NobleSprite.
|
|
||||||
-- @see Noble.Animation.new
|
|
||||||
self.animation = Noble.Animation.new(__view)
|
|
||||||
|
|
||||||
local singleStateLoop = true
|
|
||||||
if (__singleStateLoop ~= nil) then singleStateLoop = __singleStateLoop end
|
|
||||||
|
|
||||||
if (__singleState == true) then
|
|
||||||
self.animation:addState("default", 1, self.animation.imageTable:getLength(), nil, singleStateLoop)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
-- Create a new Graphics.image object.
|
|
||||||
self:setImage(Graphics.image.new(__view))
|
|
||||||
end
|
|
||||||
|
|
||||||
-- __view is an existing Graphics.image object.
|
|
||||||
elseif (type(__view) == "userdata") then
|
|
||||||
self.animated = false
|
|
||||||
self:setImage(__view)
|
|
||||||
|
|
||||||
-- __view is an existing Noble.Animation object.
|
|
||||||
elseif (type(__view) == "table") then
|
|
||||||
self.animated = true
|
|
||||||
self.animation = __view
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function NobleSprite:draw()
|
|
||||||
if (self.animation ~= nil) then
|
|
||||||
self.animation:draw()
|
|
||||||
self:markDirty()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--- This will enable the update loop for this NobleSprite, which also causes its Noble.Animation to play.
|
|
||||||
function NobleSprite:play()
|
|
||||||
self:setUpdatesEnabled(true)
|
|
||||||
end
|
|
||||||
|
|
||||||
--- This will disable the update loop for this NobleSprite, which also causes its Noble.Animation to pause.
|
|
||||||
function NobleSprite:pause()
|
|
||||||
self:setUpdatesEnabled(false)
|
|
||||||
end
|
|
||||||
|
|
||||||
--- This will disable the update loop for this NobleSprite, and also reset its Noble.Animation (if it exists) to the first frame of its current state.
|
|
||||||
function NobleSprite:stop()
|
|
||||||
self:setUpdatesEnabled(false)
|
|
||||||
if (self.animation ~= nil) then
|
|
||||||
self.animation.currentFrame = self.animation.current.startFrame
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Use this to add this NobleSprite to your scene. This replaces `playdate.graphics.sprite:add()` to allow NobleSprites to be tracked by the current NobleScene.
|
|
||||||
--
|
|
||||||
-- To add a `playdate.graphics.sprite` to a scene, use `NobleScene:addSprite(__sprite)`.
|
|
||||||
-- @see NobleScene:addSprite
|
|
||||||
function NobleSprite:add(__x, __y)
|
|
||||||
local x = __x or 0
|
|
||||||
local y = __y or 0
|
|
||||||
self:moveTo(x, y)
|
|
||||||
Noble.currentScene():addSprite(self)
|
|
||||||
end
|
|
||||||
|
|
||||||
function NobleSprite:superAdd()
|
|
||||||
NobleSprite.super.add(self)
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Use this to remove this NobleSprite from your scene. This replaces `playdate.graphics.sprite:remove()` to allow NobleSprites to be tracked by the current NobleScene.
|
|
||||||
--
|
|
||||||
-- To remove a `playdate.graphics.sprite` from a scene, use `NobleScene:removeSprite(__sprite)`.
|
|
||||||
-- @see NobleScene:removeSprite
|
|
||||||
function NobleSprite:remove()
|
|
||||||
if (self.animation ~= nil) then
|
|
||||||
self:stop()
|
|
||||||
self:setUpdatesEnabled(true) -- reset!
|
|
||||||
end
|
|
||||||
Noble.currentScene():removeSprite(self)
|
|
||||||
end
|
|
||||||
|
|
||||||
function NobleSprite:superRemove()
|
|
||||||
NobleSprite.super.remove(self)
|
|
||||||
end
|
|
@ -1,185 +0,0 @@
|
|||||||
--
|
|
||||||
-- SceneTemplate.lua
|
|
||||||
--
|
|
||||||
-- Use this as a starting point for your game's scenes.
|
|
||||||
-- Copy this file to your root "scenes" directory,
|
|
||||||
-- and rename it.
|
|
||||||
--
|
|
||||||
|
|
||||||
-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
||||||
-- !!! Rename "SceneTemplate" to your scene's name in these first three lines. !!!
|
|
||||||
-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
||||||
|
|
||||||
SceneTemplate = {}
|
|
||||||
class("SceneTemplate").extends(NobleScene)
|
|
||||||
local scene = SceneTemplate
|
|
||||||
|
|
||||||
-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
||||||
-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
||||||
|
|
||||||
-- It is recommended that you declare, but don't yet define,
|
|
||||||
-- your scene-specific varibles and methods here. Use "local" where possible.
|
|
||||||
--
|
|
||||||
-- local variable1 = nil -- local variable
|
|
||||||
-- scene.variable2 = nil -- Scene variable.
|
|
||||||
-- When accessed outside this file use `SceneTemplate.variable2`.
|
|
||||||
-- ...
|
|
||||||
--
|
|
||||||
|
|
||||||
-- This is the background color of this scene.
|
|
||||||
scene.backgroundColor = Graphics.kColorWhite
|
|
||||||
|
|
||||||
-- This runs when your scene's object is created, which is the
|
|
||||||
-- first thing that happens when transitining away from another scene.
|
|
||||||
function scene:init()
|
|
||||||
scene.super.init(self)
|
|
||||||
|
|
||||||
-- variable1 = 100
|
|
||||||
-- SceneTemplate.variable2 = "string"
|
|
||||||
-- ...
|
|
||||||
|
|
||||||
-- Your code here
|
|
||||||
end
|
|
||||||
|
|
||||||
-- When transitioning from another scene, this runs as soon as this
|
|
||||||
-- scene needs to be visible (this moment depends on which transition type is used).
|
|
||||||
function scene:enter()
|
|
||||||
scene.super.enter(self)
|
|
||||||
-- Your code here
|
|
||||||
end
|
|
||||||
|
|
||||||
-- This runs once a transition from another scene is complete.
|
|
||||||
function scene:start()
|
|
||||||
scene.super.start(self)
|
|
||||||
-- Your code here
|
|
||||||
end
|
|
||||||
|
|
||||||
-- This runs once per frame.
|
|
||||||
function scene:update()
|
|
||||||
scene.super.update(self)
|
|
||||||
-- Your code here
|
|
||||||
end
|
|
||||||
|
|
||||||
-- This runs once per frame, and is meant for drawing code.
|
|
||||||
function scene:drawBackground()
|
|
||||||
scene.super.drawBackground(self)
|
|
||||||
-- Your code here
|
|
||||||
end
|
|
||||||
|
|
||||||
-- This runs as as soon as a transition to another scene begins.
|
|
||||||
function scene:exit()
|
|
||||||
scene.super.exit(self)
|
|
||||||
-- Your code here
|
|
||||||
end
|
|
||||||
|
|
||||||
-- This runs once a transition to another scene completes.
|
|
||||||
function scene:finish()
|
|
||||||
scene.super.finish(self)
|
|
||||||
-- Your code here
|
|
||||||
end
|
|
||||||
|
|
||||||
function scene:pause()
|
|
||||||
scene.super.pause(self)
|
|
||||||
-- Your code here
|
|
||||||
end
|
|
||||||
function scene:resume()
|
|
||||||
scene.super.resume(self)
|
|
||||||
-- Your code here
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Define the inputHander for this scene here, or use a previously defined inputHandler.
|
|
||||||
|
|
||||||
-- scene.inputHandler = someOtherInputHandler
|
|
||||||
-- OR
|
|
||||||
scene.inputHandler = {
|
|
||||||
|
|
||||||
-- A button
|
|
||||||
--
|
|
||||||
AButtonDown = function() -- Runs once when button is pressed.
|
|
||||||
-- Your code here
|
|
||||||
end,
|
|
||||||
AButtonHold = function() -- Runs every frame while the player is holding button down.
|
|
||||||
-- Your code here
|
|
||||||
end,
|
|
||||||
AButtonHeld = function() -- Runs after button is held for 1 second.
|
|
||||||
-- Your code here
|
|
||||||
end,
|
|
||||||
AButtonUp = function() -- Runs once when button is released.
|
|
||||||
-- Your code here
|
|
||||||
end,
|
|
||||||
|
|
||||||
-- B button
|
|
||||||
--
|
|
||||||
BButtonDown = function()
|
|
||||||
-- Your code here
|
|
||||||
end,
|
|
||||||
BButtonHeld = function()
|
|
||||||
-- Your code here
|
|
||||||
end,
|
|
||||||
BButtonHold = function()
|
|
||||||
-- Your code here
|
|
||||||
end,
|
|
||||||
BButtonUp = function()
|
|
||||||
-- Your code here
|
|
||||||
end,
|
|
||||||
|
|
||||||
-- D-pad left
|
|
||||||
--
|
|
||||||
leftButtonDown = function()
|
|
||||||
-- Your code here
|
|
||||||
end,
|
|
||||||
leftButtonHold = function()
|
|
||||||
-- Your code here
|
|
||||||
end,
|
|
||||||
leftButtonUp = function()
|
|
||||||
-- Your code here
|
|
||||||
end,
|
|
||||||
|
|
||||||
-- D-pad right
|
|
||||||
--
|
|
||||||
rightButtonDown = function()
|
|
||||||
-- Your code here
|
|
||||||
end,
|
|
||||||
rightButtonHold = function()
|
|
||||||
-- Your code here
|
|
||||||
end,
|
|
||||||
rightButtonUp = function()
|
|
||||||
-- Your code here
|
|
||||||
end,
|
|
||||||
|
|
||||||
-- D-pad up
|
|
||||||
--
|
|
||||||
upButtonDown = function()
|
|
||||||
-- Your code here
|
|
||||||
end,
|
|
||||||
upButtonHold = function()
|
|
||||||
-- Your code here
|
|
||||||
end,
|
|
||||||
upButtonUp = function()
|
|
||||||
-- Your code here
|
|
||||||
end,
|
|
||||||
|
|
||||||
-- D-pad down
|
|
||||||
--
|
|
||||||
downButtonDown = function()
|
|
||||||
-- Your code here
|
|
||||||
end,
|
|
||||||
downButtonHold = function()
|
|
||||||
-- Your code here
|
|
||||||
end,
|
|
||||||
downButtonUp = function()
|
|
||||||
-- Your code here
|
|
||||||
end,
|
|
||||||
|
|
||||||
-- Crank
|
|
||||||
--
|
|
||||||
cranked = function(change, acceleratedChange) -- Runs when the crank is rotated. See Playdate SDK documentation for details.
|
|
||||||
-- Your code here
|
|
||||||
end,
|
|
||||||
crankDocked = function() -- Runs once when when crank is docked.
|
|
||||||
-- Your code here
|
|
||||||
end,
|
|
||||||
crankUndocked = function() -- Runs once when when crank is undocked.
|
|
||||||
-- Your code here
|
|
||||||
end
|
|
||||||
}
|
|
@ -1,81 +0,0 @@
|
|||||||
--- Extensions to `playdate.easingFunctions`, aliased as `Ease` in Noble Engine.
|
|
||||||
-- See the Playdate SDK for a list of easing functions.
|
|
||||||
-- @module Ease
|
|
||||||
|
|
||||||
local componentFunctions = {
|
|
||||||
[Ease.inOutQuad] = { enter = Ease.inQuad, exit = Ease.outQuad },
|
|
||||||
[Ease.inOutCubic] = { enter = Ease.inCubic, exit = Ease.outCubic },
|
|
||||||
[Ease.inOutQuart] = { enter = Ease.inQuart, exit = Ease.outQuart },
|
|
||||||
[Ease.inOutQuint] = { enter = Ease.inQuint, exit = Ease.outQuint },
|
|
||||||
[Ease.inOutSine] = { enter = Ease.inSine, exit = Ease.outSine },
|
|
||||||
[Ease.inOutExpo] = { enter = Ease.inExpo, exit = Ease.outExpo },
|
|
||||||
[Ease.inOutCirc] = { enter = Ease.inCirc, exit = Ease.outCirc },
|
|
||||||
[Ease.inOutElastic] = { enter = Ease.inElastic, exit = Ease.outElastic },
|
|
||||||
[Ease.inOutBack] = { enter = Ease.inBack, exit = Ease.outBack },
|
|
||||||
[Ease.inOutBounce] = { enter = Ease.inBounce, exit = Ease.outBounce },
|
|
||||||
[Ease.outInQuad] = { enter = Ease.outQuad, exit = Ease.inQuad },
|
|
||||||
[Ease.outInCubic] = { enter = Ease.outCubic, exit = Ease.inCubic },
|
|
||||||
[Ease.outInQuart] = { enter = Ease.outQuart, exit = Ease.inQuart },
|
|
||||||
[Ease.outInQuint] = { enter = Ease.outQuint, exit = Ease.inQuint },
|
|
||||||
[Ease.outInSine] = { enter = Ease.outSine, exit = Ease.inSine },
|
|
||||||
[Ease.outInExpo] = { enter = Ease.outExpo, exit = Ease.inExpo },
|
|
||||||
[Ease.outInCirc] = { enter = Ease.outCirc, exit = Ease.inCirc },
|
|
||||||
[Ease.outInElastic] = { enter = Ease.outElastic, exit = Ease.inElastic },
|
|
||||||
[Ease.outInBack] = { enter = Ease.outBack, exit = Ease.inBack },
|
|
||||||
[Ease.outInBounce] = { enter = Ease.outBounce, exit = Ease.inBounce },
|
|
||||||
[Ease.linear] = { enter = Ease.linear, exit = Ease.linear }
|
|
||||||
}
|
|
||||||
|
|
||||||
local reverseFunctions = {
|
|
||||||
[Ease.inQuad] = Ease.outQuad,
|
|
||||||
[Ease.inCubic] = Ease.outCubic,
|
|
||||||
[Ease.inQuart] = Ease.outQuart,
|
|
||||||
[Ease.inQuint] = Ease.outQuint,
|
|
||||||
[Ease.inSine] = Ease.outSine,
|
|
||||||
[Ease.inExpo] = Ease.outExpo,
|
|
||||||
[Ease.inCirc] = Ease.outCirc,
|
|
||||||
[Ease.inElastic] = Ease.outElastic,
|
|
||||||
[Ease.inBack] = Ease.outBack,
|
|
||||||
[Ease.inBounce] = Ease.outBounce,
|
|
||||||
[Ease.outQuad] = Ease.inQuad,
|
|
||||||
[Ease.outCubic] = Ease.inCubic,
|
|
||||||
[Ease.outQuart] = Ease.inQuart,
|
|
||||||
[Ease.outQuint] = Ease.inQuint,
|
|
||||||
[Ease.outSine] = Ease.inSine,
|
|
||||||
[Ease.outExpo] = Ease.inExpo,
|
|
||||||
[Ease.outCirc] = Ease.inCirc,
|
|
||||||
[Ease.outElastic] = Ease.inElastic,
|
|
||||||
[Ease.outBack] = Ease.inBack,
|
|
||||||
[Ease.outBounce] = Ease.inBounce,
|
|
||||||
[Ease.linear] = Ease.linear
|
|
||||||
}
|
|
||||||
|
|
||||||
--- Returns the first half of an "inOut" or "outIn" easing function.
|
|
||||||
-- Returns `nil` for any easing function that isn't in the form of `Ease.inOutXxxx` or `Ease.outInXxxx`. `Ease.linear` returns itself.
|
|
||||||
-- @usage
|
|
||||||
-- local ease = Ease.outInQuad
|
|
||||||
-- local easeEnter = Ease.enter(ease) -- Returns "Ease.outQuad"
|
|
||||||
function Ease.enter(__easingFunction)
|
|
||||||
if (componentFunctions[__easingFunction] == nil) then return nil end
|
|
||||||
return componentFunctions[__easingFunction].enter
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Returns the second half of an "inOut" or "outIn" easing function.
|
|
||||||
-- Returns `nil` for any easing function that isn't in the form of `Ease.inOutXxxx` or `Ease.outInXxxx`. `Ease.linear` returns itself.
|
|
||||||
-- @usage
|
|
||||||
-- local ease = Ease.outInQuad
|
|
||||||
-- local easeExit = Ease.exit(ease) -- Returns "Ease.inQuad"
|
|
||||||
function Ease.exit(__easingFunction)
|
|
||||||
if (componentFunctions[__easingFunction] == nil) then return nil end
|
|
||||||
return componentFunctions[__easingFunction].exit
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Returns the reverse function of the provided function.
|
|
||||||
-- Returns `nil` for any easing function that isn't in the form of `Ease.inXxxx` or `Ease.outXxxx`. `Ease.linear` returns itself.
|
|
||||||
-- @usage
|
|
||||||
-- local ease = Ease.inQuad
|
|
||||||
-- local reverseEase = Ease.reverse(ease) -- Returns "Ease.outQuad"
|
|
||||||
function Ease.reverse(__easingFunction)
|
|
||||||
if (reverseFunctions[__easingFunction] == nil) then return nil end
|
|
||||||
return reverseFunctions[__easingFunction]
|
|
||||||
end
|
|
@ -1,197 +0,0 @@
|
|||||||
--
|
|
||||||
-- Utilities.lua
|
|
||||||
--
|
|
||||||
-- Useful helper functions and API extensions.
|
|
||||||
-- Place your own utilities in "utilities/Utilities.lua"
|
|
||||||
--
|
|
||||||
|
|
||||||
Utilities = {}
|
|
||||||
|
|
||||||
function Utilities.copy(obj, seen)
|
|
||||||
if type(obj) ~= 'table' then return obj end
|
|
||||||
if seen and seen[obj] then return seen[obj] end
|
|
||||||
local s = seen or {}
|
|
||||||
local res = setmetatable({}, getmetatable(obj))
|
|
||||||
s[obj] = res
|
|
||||||
for k, v in pairs(obj) do res[Utilities.copy(k, s)] = Utilities.copy(v, s) end
|
|
||||||
return res
|
|
||||||
end
|
|
||||||
|
|
||||||
function Utilities.isNull(__object)
|
|
||||||
return __object == nil or __object == ''
|
|
||||||
end
|
|
||||||
function Utilities.isNotNull(__object)
|
|
||||||
return __object ~= nil and __object ~= ''
|
|
||||||
end
|
|
||||||
|
|
||||||
function Utilities.startsWith(__string, __start)
|
|
||||||
return __string:sub(1, #__start) == __start
|
|
||||||
end
|
|
||||||
|
|
||||||
function Utilities.endsWith(__string, __ending)
|
|
||||||
return __ending == "" or __string:sub(-#__ending) == __ending
|
|
||||||
end
|
|
||||||
|
|
||||||
function Utilities.handleOptionalBoolean(__argument, __default)
|
|
||||||
if (__argument == nil) then
|
|
||||||
return __default
|
|
||||||
elseif (__argument == true or __argument == false) then
|
|
||||||
return __argument
|
|
||||||
else
|
|
||||||
error("BONK: You shouldn’t pass non-boolean value as a boolean parameter.")
|
|
||||||
return __argument
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
Utilities.varName = {}
|
|
||||||
setmetatable(
|
|
||||||
Utilities.varName,
|
|
||||||
{
|
|
||||||
__index = function(self, __key, __value)
|
|
||||||
return string.format('%s', __key)
|
|
||||||
end
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
function Utilities.getHypotenuse(__x,__y)
|
|
||||||
return math.sqrt((__x*__x)+(__y*__y))
|
|
||||||
end
|
|
||||||
|
|
||||||
function Utilities.average(__a, __b)
|
|
||||||
return (__a + __b) / 2
|
|
||||||
end
|
|
||||||
|
|
||||||
function Utilities.screenshot()
|
|
||||||
return Graphics.getDisplayImage()
|
|
||||||
end
|
|
||||||
|
|
||||||
function Utilities.autoTable(__numberOfDimensions)
|
|
||||||
local metatable = {};
|
|
||||||
for i = 1, __numberOfDimensions do
|
|
||||||
metatable[i] = {
|
|
||||||
__index = function(__table, __key)
|
|
||||||
if i < __numberOfDimensions then
|
|
||||||
__table[__key] = setmetatable({}, metatable[i+1])
|
|
||||||
return __table[__key];
|
|
||||||
end
|
|
||||||
end
|
|
||||||
}
|
|
||||||
end
|
|
||||||
return setmetatable({}, metatable[1]);
|
|
||||||
end
|
|
||||||
|
|
||||||
function Utilities.newUUID()
|
|
||||||
local func = function(x)
|
|
||||||
local random = math.random(16) - 1
|
|
||||||
random = (x == "x") and (random + 1) or (random % 4) + 9
|
|
||||||
return ("0123456789abcdef"):sub(random, random)
|
|
||||||
end
|
|
||||||
return (("xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"):gsub("[xy]", func))
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
-- New math methods
|
|
||||||
--
|
|
||||||
|
|
||||||
function math.clamp(__value, __min, __max)
|
|
||||||
if (__min > __max) then
|
|
||||||
__min, __max = __max, __min
|
|
||||||
end
|
|
||||||
return math.max(__min, math.min(__max, __value))
|
|
||||||
end
|
|
||||||
|
|
||||||
function math.ring(__value, __min, __max)
|
|
||||||
if (__min > __max) then
|
|
||||||
__min, __max = __max, __min
|
|
||||||
end
|
|
||||||
return __min + (__value - __min) % (__max - __min)
|
|
||||||
end
|
|
||||||
|
|
||||||
function math.ringInt(__value, __min, __max)
|
|
||||||
return math.ring(__value, __min, __max + 1)
|
|
||||||
end
|
|
||||||
|
|
||||||
function math.approach(_value, __target, __step)
|
|
||||||
if (_value == __target) then
|
|
||||||
return _value, true
|
|
||||||
end
|
|
||||||
local d = __target - _value
|
|
||||||
if (d > 0) then
|
|
||||||
_value = _value + __step
|
|
||||||
if (_value >= __target) then
|
|
||||||
return __target, true
|
|
||||||
else
|
|
||||||
return _value, false
|
|
||||||
end
|
|
||||||
elseif (d < 0) then
|
|
||||||
_value = _value - __step
|
|
||||||
if (_value <= __target) then
|
|
||||||
return __target, true
|
|
||||||
else
|
|
||||||
return _value, false
|
|
||||||
end
|
|
||||||
else
|
|
||||||
return _value, true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function math.infiniteApproach(at_zero, at_infinite, x_halfway, x)
|
|
||||||
return at_infinite - (at_infinite - at_zero) * 0.5 ^ (x / x_halfway)
|
|
||||||
end
|
|
||||||
|
|
||||||
function math.round(__value, __bracket)
|
|
||||||
local bracket = __bracket or 1
|
|
||||||
return math.floor(__value/bracket + math.sign(__value) * 0.5) * bracket
|
|
||||||
end
|
|
||||||
|
|
||||||
function math.sign(__value)
|
|
||||||
return (__value >= 0 and 1) or -1
|
|
||||||
end
|
|
||||||
|
|
||||||
function math.lerp(a, b, t)
|
|
||||||
return a + (b - a) * t
|
|
||||||
end
|
|
||||||
|
|
||||||
-- New array/table methods
|
|
||||||
--
|
|
||||||
|
|
||||||
function table.merge(__table1, __table2)
|
|
||||||
local mergedTable = {}
|
|
||||||
for k,v in pairs(__table1) do
|
|
||||||
mergedTable[k] = v
|
|
||||||
end
|
|
||||||
for k,v in pairs(__table2) do
|
|
||||||
mergedTable[k] = v
|
|
||||||
end
|
|
||||||
return mergedTable
|
|
||||||
end
|
|
||||||
|
|
||||||
function table.random(__table)
|
|
||||||
if (type(__table) ~= "table") then return nil end
|
|
||||||
return __table[math.ceil(math.random(#__table))]
|
|
||||||
end
|
|
||||||
function table.each(__table, __function)
|
|
||||||
if (type(__function) ~= "function") then return end
|
|
||||||
for _, e in pairs(__table) do
|
|
||||||
__function(e)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function table.filter(__table, __filter)
|
|
||||||
local out = {}
|
|
||||||
for _, value in pairs(__table) do
|
|
||||||
--if filterIter(v, k, table) then out[k] = v end
|
|
||||||
if (__filter(value)) then
|
|
||||||
__table.insert (out,value)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return out
|
|
||||||
end
|
|
||||||
|
|
||||||
function table.getSize(__table)
|
|
||||||
local count = 0
|
|
||||||
for _, _ in pairs(__table) do count += 1 end
|
|
||||||
return count
|
|
||||||
end
|
|
@ -100,19 +100,20 @@ Difficulty = {
|
|||||||
|
|
||||||
DifficultySettings = {
|
DifficultySettings = {
|
||||||
[Difficulty.Easy] = {
|
[Difficulty.Easy] = {
|
||||||
assebleTime = 2500,
|
assebleTime = 1700,
|
||||||
},
|
},
|
||||||
[Difficulty.Medium] = {
|
[Difficulty.Medium] = {
|
||||||
assebleTime = 1500,
|
assebleTime = 1000,
|
||||||
},
|
},
|
||||||
[Difficulty.Hard] = {
|
[Difficulty.Hard] = {
|
||||||
assebleTime = 800,
|
assebleTime = 500,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Noble.Settings.setup({
|
Noble.Settings.setup({
|
||||||
difficulty = Difficulty.Medium,
|
difficulty = Difficulty.Medium,
|
||||||
music = true
|
music = true,
|
||||||
|
debug = true
|
||||||
})
|
})
|
||||||
|
|
||||||
Noble.GameData.setup({
|
Noble.GameData.setup({
|
||||||
|
@ -113,7 +113,15 @@ end
|
|||||||
|
|
||||||
function scene:setupMenu(__menu)
|
function scene:setupMenu(__menu)
|
||||||
__menu:addItem("Start", function() Noble.transition(DroneCardSelector, nil, Noble.Transition.DipToWhite) end)
|
__menu:addItem("Start", function() Noble.transition(DroneCardSelector, nil, Noble.Transition.DipToWhite) end)
|
||||||
__menu:addItem("Tutorial", function() return end)
|
__menu:addItem("Tutorial", function()
|
||||||
|
local debug = Noble.Settings.get("debug")
|
||||||
|
if debug then
|
||||||
|
Noble.Settings.set("debug", false)
|
||||||
|
else
|
||||||
|
Noble.Settings.set("debug", true)
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end)
|
||||||
__menu:addItem("Credits", function() return end)
|
__menu:addItem("Credits", function() return end)
|
||||||
__menu:select("Start")
|
__menu:select("Start")
|
||||||
end
|
end
|
||||||
|
@ -53,8 +53,12 @@ function Player:init(x, y)
|
|||||||
Player.bat = Player.fullBat
|
Player.bat = Player.fullBat
|
||||||
Player.dischargeRate = 1
|
Player.dischargeRate = 1
|
||||||
Player.moveRight = false
|
Player.moveRight = false
|
||||||
|
Player.moveLeft = false -- TODO: refactor to use a single variable
|
||||||
self.lastDirection = nil
|
self.lastDirection = nil
|
||||||
self.targetDone = false
|
self.targetDone = false
|
||||||
|
|
||||||
|
|
||||||
|
self.debug = Noble.Settings.get("debug")
|
||||||
end
|
end
|
||||||
|
|
||||||
function Player:handleInput()
|
function Player:handleInput()
|
||||||
@ -68,6 +72,7 @@ function Player:handleInput()
|
|||||||
if not playdate.buttonIsPressed(playdate.kButtonLeft) and not playdate.buttonIsPressed(playdate.kButtonRight) then
|
if not playdate.buttonIsPressed(playdate.kButtonLeft) and not playdate.buttonIsPressed(playdate.kButtonRight) then
|
||||||
self.xVelocity = self.xVelocity * self.friction
|
self.xVelocity = self.xVelocity * self.friction
|
||||||
Player.moveRight = false
|
Player.moveRight = false
|
||||||
|
Player.moveLeft = false
|
||||||
self.animation:setState("down")
|
self.animation:setState("down")
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -78,6 +83,8 @@ function Player:handleInput()
|
|||||||
end
|
end
|
||||||
self:changeToRunState("left")
|
self:changeToRunState("left")
|
||||||
self.lastDirection = "left"
|
self.lastDirection = "left"
|
||||||
|
Player.moveLeft = true
|
||||||
|
Player.moveRight = false
|
||||||
self.xVelocity = self.xVelocity - self.acceleration
|
self.xVelocity = self.xVelocity - self.acceleration
|
||||||
elseif playdate.buttonIsPressed(playdate.kButtonRight) then
|
elseif playdate.buttonIsPressed(playdate.kButtonRight) then
|
||||||
if self.lastDirection == "left" then
|
if self.lastDirection == "left" then
|
||||||
@ -85,6 +92,7 @@ function Player:handleInput()
|
|||||||
end
|
end
|
||||||
self:changeToRunState("right")
|
self:changeToRunState("right")
|
||||||
Player.moveRight = true
|
Player.moveRight = true
|
||||||
|
Player.moveLeft = false
|
||||||
self.lastDirection = "right"
|
self.lastDirection = "right"
|
||||||
self.xVelocity = self.xVelocity + self.acceleration
|
self.xVelocity = self.xVelocity + self.acceleration
|
||||||
end
|
end
|
||||||
@ -95,10 +103,12 @@ function Player:handleInput()
|
|||||||
|
|
||||||
-- Y velocity
|
-- Y velocity
|
||||||
if crankChange ~= 0 then
|
if crankChange ~= 0 then
|
||||||
if crankChange > 0 then
|
if Player.moveRight == false and Player.moveLeft == false then
|
||||||
self.animation:setState("up")
|
if crankChange > 0 then
|
||||||
else
|
self.animation:setState("up")
|
||||||
self.animation:setState("down")
|
else
|
||||||
|
self.animation:setState("down")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
self.yInertia = self.yInertia - (acceleratedChange * 0.007)
|
self.yInertia = self.yInertia - (acceleratedChange * 0.007)
|
||||||
else
|
else
|
||||||
@ -173,6 +183,9 @@ function Player:handleMovementAndCollisions()
|
|||||||
self:boom()
|
self:boom()
|
||||||
return
|
return
|
||||||
elseif collisionTag == 154 then -- Baleba
|
elseif collisionTag == 154 then -- Baleba
|
||||||
|
if self.debug then
|
||||||
|
return
|
||||||
|
end
|
||||||
self:boom(collisionObject)
|
self:boom(collisionObject)
|
||||||
return
|
return
|
||||||
elseif collisionTag == 2 then -- Tank
|
elseif collisionTag == 2 then -- Tank
|
||||||
|