forked from iamkun/tower_game
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtutorial.js
35 lines (32 loc) · 1007 Bytes
/
tutorial.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { getHookStatus } from './utils'
import * as constant from './constant'
export const tutorialAction = (instance, engine, time) => {
const { width, height } = engine
const { name } = instance
if (!instance.ready) {
instance.ready = true
const tutorialWidth = width * 0.2
instance.updateWidth(tutorialWidth)
instance.height = tutorialWidth * 0.46
instance.x = engine.calWidth - instance.calWidth
instance.y = height * 0.45
if (name !== 'tutorial') {
instance.y += instance.height * 1.2
}
}
if (name !== 'tutorial') {
instance.y += Math.cos(time / 200) * instance.height * 0.01
}
}
export const tutorialPainter = (instance, engine) => {
if (engine.checkTimeMovement(constant.tutorialMovement)) {
return
}
if (getHookStatus(engine) !== constant.hookNormal) {
return
}
const { ctx } = engine
const { name } = instance
const t = engine.getImg(name)
ctx.drawImage(t, instance.x, instance.y, instance.width, instance.height)
}