Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
elephant
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
template admin
elephant
Commits
ecf1293b
Commit
ecf1293b
authored
Dec 17, 2021
by
liujiaxin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add exit function
parent
8020f9d6
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
1196 additions
and
878 deletions
+1196
-878
elephant.fire
assets/elephant/scene/elephant.fire
+1148
-873
elephant.ts
assets/elephant/scene/elephant.ts
+7
-0
api.ts
assets/elephant/scene/net/api.ts
+3
-3
pg.ts
assets/elephant/scene/pg.ts
+2
-2
btn_return.png
assets/elephant/textures/btn_return.png
+0
-0
btn_return.png.meta
assets/elephant/textures/btn_return.png.meta
+36
-0
No files found.
assets/elephant/scene/elephant.fire
View file @
ecf1293b
This diff is collapsed.
Click to expand it.
assets/elephant/scene/elephant.ts
View file @
ecf1293b
...
@@ -89,6 +89,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -89,6 +89,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
private
kitchen
:
cc
.
Node
;
private
kitchen
:
cc
.
Node
;
private
shop
:
cc
.
Node
;
private
shop
:
cc
.
Node
;
private
loading
:
cc
.
Node
;
private
loading
:
cc
.
Node
;
private
exitButton
:
cc
.
Node
;
tws
:
any
[]
=
[];
tws
:
any
[]
=
[];
LoadingCount
:
number
=
1
;
LoadingCount
:
number
=
1
;
initView
()
{
initView
()
{
...
@@ -99,6 +100,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -99,6 +100,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
this
.
shop
=
pg
.
view
.
find
(
this
,
"
shop
"
);
this
.
shop
=
pg
.
view
.
find
(
this
,
"
shop
"
);
this
.
elephant
=
pg
.
view
.
find
(
this
.
home
,
"
elephant
"
);
this
.
elephant
=
pg
.
view
.
find
(
this
.
home
,
"
elephant
"
);
this
.
loading
=
pg
.
view
.
find
(
this
,
"
loading
"
);
this
.
loading
=
pg
.
view
.
find
(
this
,
"
loading
"
);
this
.
exitButton
=
pg
.
view
.
find
(
this
.
home
,
"
exit_btn
"
);
this
.
elephentState
(
0
);
this
.
elephentState
(
0
);
}
}
...
@@ -109,9 +111,14 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -109,9 +111,14 @@ export default class SceneComponent extends MyCocosSceneComponent {
pg
.
view
.
touchOn
(
pg
.
view
.
find
(
this
,
"
shop/btn_close
"
),
this
.
onTouchShopClose
,
this
);
pg
.
view
.
touchOn
(
pg
.
view
.
find
(
this
,
"
shop/btn_close
"
),
this
.
onTouchShopClose
,
this
);
pg
.
view
.
touchOn
(
pg
.
view
.
find
(
this
.
elephant
,
"
walk
"
),
this
.
onTouchElephent
,
this
);
pg
.
view
.
touchOn
(
pg
.
view
.
find
(
this
.
elephant
,
"
walk
"
),
this
.
onTouchElephent
,
this
);
pg
.
view
.
touchOn
(
pg
.
view
.
find
(
this
.
elephant
,
"
panel_info/btn_close
"
),
this
.
onTouchPanel
,
this
);
pg
.
view
.
touchOn
(
pg
.
view
.
find
(
this
.
elephant
,
"
panel_info/btn_close
"
),
this
.
onTouchPanel
,
this
);
pg
.
view
.
touchOn
(
this
.
exitButton
,
this
.
onExitPetRoom
,
this
);
}
}
//----------------------------商店部分--------------------------------------
//----------------------------商店部分--------------------------------------
// 推出按钮
onExitPetRoom
()
{
cc
.
find
(
'
middleLayer
'
).
getComponent
(
'
middleLayer
'
).
exit
();
}
//商店按钮
//商店按钮
private
shopType
=
0
;
private
shopType
=
0
;
onTouchShop
()
{
onTouchShop
()
{
...
...
assets/elephant/scene/net/api.ts
View file @
ecf1293b
...
@@ -7,7 +7,7 @@ import shop from "../model/shop";
...
@@ -7,7 +7,7 @@ import shop from "../model/shop";
class
Api
{
class
Api
{
static
askUser
()
{
static
askUser
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
pg
.
http
.
send
(
"
GET
"
,
`
${
globalThis
.
SERVER_HOST
}
/api
/pets/info`
,
null
).
then
((
userInfo
:
any
)
=>
{
pg
.
http
.
send
(
"
GET
"
,
`
${
cc
.
find
(
'
middleLayer
'
).
getComponent
(
'
middleLayer
'
).
baseUrl
}
/pets/info`
,
null
).
then
((
userInfo
:
any
)
=>
{
// let userInfo = USER;
// let userInfo = USER;
try
{
try
{
const
mood
=
(
Date
.
now
()
-
userInfo
.
status
.
eat
.
time
)
>
4
*
60
*
60
*
1000
?
1
:
0
;
// 4 hours
const
mood
=
(
Date
.
now
()
-
userInfo
.
status
.
eat
.
time
)
>
4
*
60
*
60
*
1000
?
1
:
0
;
// 4 hours
...
@@ -38,7 +38,7 @@ class Api {
...
@@ -38,7 +38,7 @@ class Api {
}
}
static
askUseItem
(
data
)
{
static
askUseItem
(
data
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
pg
.
http
.
send
(
"
POST
"
,
`
${
globalThis
.
SERVER_HOST
}
/api
/pets/use/item`
,
{
item_id
:
data
.
id
}).
then
((
resp
:
any
)
=>
{
pg
.
http
.
send
(
"
POST
"
,
`
${
cc
.
find
(
'
middleLayer
'
).
getComponent
(
'
middleLayer
'
).
baseUrl
}
/pets/use/item`
,
{
item_id
:
data
.
id
}).
then
((
resp
:
any
)
=>
{
// user.addGrowth(data.growthValue);
// user.addGrowth(data.growthValue);
// kitchen.use(data.id);
// kitchen.use(data.id);
try
{
try
{
...
@@ -55,7 +55,7 @@ class Api {
...
@@ -55,7 +55,7 @@ class Api {
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
data
.
id
;
data
.
id
;
data
.
type
;
data
.
type
;
pg
.
http
.
send
(
"
POST
"
,
`
${
globalThis
.
SERVER_HOST
}
/api
/pets/item/buy`
,
{
item_id
:
data
.
id
}).
then
((
resp
:
any
)
=>
{
pg
.
http
.
send
(
"
POST
"
,
`
${
cc
.
find
(
'
middleLayer
'
).
getComponent
(
'
middleLayer
'
).
baseUrl
}
/pets/item/buy`
,
{
item_id
:
data
.
id
}).
then
((
resp
:
any
)
=>
{
// user.useCoin(data.cost * data.discount);
// user.useCoin(data.cost * data.discount);
// kitchen.buy(data.id);
// kitchen.buy(data.id);
try
{
try
{
...
...
assets/elephant/scene/pg.ts
View file @
ecf1293b
...
@@ -340,8 +340,8 @@ let pg = {
...
@@ -340,8 +340,8 @@ let pg = {
xhr
.
timeout
=
30000
;
xhr
.
timeout
=
30000
;
xhr
.
responseType
=
"
text
"
;
xhr
.
responseType
=
"
text
"
;
xhr
.
open
(
type
,
url
,
true
);
xhr
.
open
(
type
,
url
,
true
);
xhr
.
setRequestHeader
(
"
token
"
,
globalThis
.
USER_TOKEN
);
xhr
.
setRequestHeader
(
"
token
"
,
cc
.
find
(
'
middleLayer
'
).
getComponent
(
'
middleLayer
'
).
token
);
xhr
.
setRequestHeader
(
"
Client-Type
"
,
globalThis
.
CLIENT_TYPE
);
xhr
.
setRequestHeader
(
"
Client-Type
"
,
'
student
'
);
xhr
.
setRequestHeader
(
"
Content-Type
"
,
"
application/json
"
);
xhr
.
setRequestHeader
(
"
Content-Type
"
,
"
application/json
"
);
xhr
.
onreadystatechange
=
()
=>
{
xhr
.
onreadystatechange
=
()
=>
{
if
(
xhr
.
readyState
!==
4
)
return
;
if
(
xhr
.
readyState
!==
4
)
return
;
...
...
assets/elephant/textures/btn_return.png
0 → 100644
View file @
ecf1293b
4.31 KB
assets/elephant/textures/btn_return.png.meta
0 → 100644
View file @
ecf1293b
{
"ver": "2.3.5",
"uuid": "96dab226-d041-47e5-8549-068281e523e0",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 82,
"height": 65,
"platformSettings": {},
"subMetas": {
"btn_return": {
"ver": "1.0.4",
"uuid": "cc47e80b-2d35-4cdb-b287-5df9dc415a92",
"rawTextureUuid": "96dab226-d041-47e5-8549-068281e523e0",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 82,
"height": 65,
"rawWidth": 82,
"rawHeight": 65,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment