123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- // Learn TypeScript:
- // - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
- // Learn Attribute:
- // - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
- // Learn life-cycle callbacks:
- // - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html
- const { ccclass, property } = cc._decorator;
- @ccclass
- export default class Parabola extends cc.Component {
- ParabolaID: number = 1000
- prefab: cc.Node = null
- start() {
- const url = `Parabola/${this.ParabolaID}`
- cc.resources.load(url, cc.SpriteFrame, (err, SpriteFrame) => {
- if (err) {
- return
- }
- let SubNode = new cc.Node()
- SubNode.addComponent(cc.Sprite).spriteFrame = SpriteFrame
- SubNode.setAnchorPoint(0.5, 0.5)
- SubNode.setScale(0.8)
- this.prefab = SubNode
- });
- }
- ChildIndex: number = 0
- circle(x: number, y: number) {
- if (this.node.children[this.ChildIndex]) {
- this.node.children[this.ChildIndex].setPosition(x, y)
- this.node.children[this.ChildIndex].active = true
- } else {
- let temp = cc.instantiate(this.prefab)
- temp.parent = this.node
- temp.active = true
- temp.setPosition(x, y)
-
- }
- this.ChildIndex++
- }
- clear() {
- this.ChildIndex = 0
- this.node.children.forEach(e => { e.active = false })
- }
- // update (dt) {}
- }
|