Skip to content

Commit

Permalink
impl: clone; but why so slow ㅠㅠ
Browse files Browse the repository at this point in the history
  • Loading branch information
gnlow committed Dec 3, 2023
1 parent 1871d26 commit 2be695a
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const toDegrees =
export class EntrySprite extends Sprite {
textureIds: string[] = []
currentTextureIndex = 0
scene = ""

constructor() {
super()
Expand Down Expand Up @@ -66,9 +67,26 @@ export class EntrySprite extends Sprite {
x: entity.scaleX,
y: entity.scaleY,
}
sprite.scene = scene
project.scenes[scene].addChild(sprite)
return sprite
}
clone(project: Entry) {
const sprite = new this.constructor()
sprite.textureIds = this.textureIds
sprite.currentTextureIndex = this.currentTextureIndex
sprite.texture = this.texture
sprite.anchor.set(0.5)
sprite.x = this.x
sprite.y = this.y
sprite.scale = this.scale
sprite.scene = this.scene
project.scenes[sprite.scene].addChild(sprite)

sprite.emit("clone")

return sprite
}
}

export class Timer {
Expand Down Expand Up @@ -205,7 +223,6 @@ export class Entry {
this.emit("start")
}
render() {
Object.values(this.scenes)[0].x
this.renderer!.render({
container: Object.values(this.scenes)[0]
})
Expand Down Expand Up @@ -266,9 +283,12 @@ export class Entry {
}
create_clone(targetId: string, obj: EntrySprite) {
if (targetId == "self") {
console.log(obj)
const clone = obj.clone(this)
}
}
when_clone_start(f: () => void, obj: EntrySprite) {
obj.on("clone", f)
}

/* 움직임 */
move_x(n: number, obj: EntrySprite) {
Expand Down

0 comments on commit 2be695a

Please sign in to comment.