| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- import GameConfig from "../../configData/GameConfig";
- import gameOver from "./gameOver";
- const { ccclass, property } = cc._decorator;
- @ccclass
- export default class viewComtent extends cc.Component {
- private winsize:cc.Vec2 = null;
- public static instance: viewComtent = null;
- protected onLoad() {
- viewComtent.instance = this;
- let hhh = cc.winSize.height * (1920 / cc.winSize.width);
- this.node.setContentSize(1920, hhh);
- this.winsize = cc.v2(1920, hhh);
-
-
- }
-
- /**游戏结算 */
- public gameOver(Hpnum: number) {
- let self = this;
- cc.resources.load("prefabs/over", cc.Prefab, function (err, prefab: cc.Prefab) {
- var newNode = cc.instantiate(prefab);
- self.node.addChild(newNode, 1);
- newNode.setPosition(cc.v2(0, 0));
- let iver = newNode.getComponent(gameOver);
- iver.gameiswin(Hpnum);
- });
- }
- /**获取屏幕真是大小 */
- public getWinsize():cc.Vec2
- {
- return this.winsize;
- }
- /**获取偏移量 */
- public getOff(): number {
- let scroll = this.node.parent.getComponent(cc.ScrollView);
- // console.log("最大偏移量:"+scroll.getMaxScrollOffset());
- return scroll.getMaxScrollOffset().y-scroll.getScrollOffset().y;
- }
- }
|