铅笔家族不显示

来源:4-11 小游戏上下铅笔形管道的创建-2

qq_流颜陌若夕_0

2019-03-01

在pencils 类 里面打印 imgae.heigth

和 上下铅笔类的地方 打印 imgae.heigth 都是 未定义 但是宽度可以打印出来 包括陆地的 imgae.heigth 也是未定义 但是陆地出来并且没有任何问题。而上下部分铅笔不出来 并且不报错。

//上半部分的铅笔
import {Pencil} from “./Pencil.js”;
import {Sprite} from “…/base/Sprite.js”;
export class UpPencli extends Pencil{
constructor(top){
const image = Sprite.getImage(‘pie_up’)
super(image,top)
}
draw(){

    this.y = this.top -this.height;
    // console.log(this.y)
    super.draw()
}

}

// 下半部分铅笔
import {Pencil} from “./Pencil.js”;
import {Sprite} from “…/base/Sprite.js”;

export class DownPencli extends Pencil{
constructor(top){
const image = Sprite.getImage(‘pie_down’)
super(image,top)
}
draw(){
let gap = window.innerHeight / 5 ;
this.y = this.top + gap;
super.draw();
}
}

import {Sprite} from “…/base/Sprite.js”;
import {Director} from “…/Director.js”;

export class Pencil extends Sprite{

constructor(image,top){
    super(image,
        0,0,
        image.width,image.heigth,
        window.innerWidth,0,
        image.width,image.heigth
        )
        this.top = top;
}
draw(){
    this.x = this.x - Director.getInstance().moveSpend

    super.draw(this.image,
        0,0,
        this.image.width,this.image.heigth,
        this.x,this.y,
        this.image.width,this.image.heigth,
    )
}

}

写回答

1回答

傅猿猿

2019-03-01

js这种动态语言就是这样的,你是没有正确的传入一个值,才会出现安迪范的,或者是没有这样的一个情况,要检查呢,就要检查你调用这个类的那个父类,或者说是调用这个类的其他的类。

0
0

微信小游戏入门与实战,一天之内搞定微信小游戏开发

官方同步,第一时间掌握整套微信小游戏开发核心技术

3515 学习 · 664 问题

查看课程