惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Y
Y Combinator Blog
腾讯CDC
Recent Announcements
Recent Announcements
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Hugging Face - Blog
Hugging Face - Blog
H
Help Net Security
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Last Week in AI
Last Week in AI
博客园_首页
D
DataBreaches.Net
P
Proofpoint News Feed
云风的 BLOG
云风的 BLOG
V
Visual Studio Blog
月光博客
月光博客
Jina AI
Jina AI
Stack Overflow Blog
Stack Overflow Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 【当耐特】
Vercel News
Vercel News
WordPress大学
WordPress大学
J
Java Code Geeks
博客园 - 聂微东
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
U
Unit 42

博客园 - 布袋

Phaser游戏框架与HTML Dom元素之间的通信交互 Phaser Matter Collision Plugin 碰撞插件 -- iFiero技术分享 Phaser3跟随自定义路径移动的赛车 -- iFIERO游戏教程 Phaser3让超级玛丽实现轻跳、高跳及加上对应的跳跃声音 PHASER3 设置场景SCENE SLEEPING休眠和WAKE唤醒 Phaser3游戏三角学应用--一只跟随屏幕点击位置游动的鱼 Phaser3 对象池随机产生炸弹并销毁 Phaser3 场景Scene之间的传值 -- HTML JAVASCRIPT 网页游戏开发 Phaser3 屏幕适配iPhoneX、iPhoneXs的坑 -- JavaScript Html5 游戏开发 GameplayKit的GKStateMachine用法与实例 适配iPhoneX、iPhoneXs、iPhoneXs Max、iPhoneXr 屏幕尺寸及安全区域 Swift使用AVAudioPlayer来调节游戏的背景音乐大小 学好三角学(函数) — SWIFT和JAVASCRIPT游戏开发的必备技能 iFIERO.com 应用UserDefaults储存游戏分数和最高分 一步一步图文介绍SpriteKit使用TexturePacker导出的纹理集Altas SpriteKit在复制节点时留了一个巨坑给开发者,需要开发者手动把复制节点的isPaused设置为false 运用GamePlayKit的GKEntity及GKComponent 的iOS游戏开发实例 SpriteKit手机游戏摇杆JoyStick的使用 -- by iFIERO游戏开发教程 SpirteKit深度复制SKSpriteNode节点及convert转换其它Scene上的节点到当前场景坐标
用EC5/EC6自定义class的区别及用法 -- Phaser3网页游戏框架
布袋 · 2018-12-04 · via 博客园 - 布袋

custom class

custom class

EC6 自定义class

class Brain extends Phaser.GameObjects.Sprite {

    constructor (scene, x, y)
    {
        super(scene, x, y);

        this.setTexture('brain');
        this.setPosition(x, y);
    }

    preUpdate (time, delta)
    {
        super.preUpdate(time, delta);

        this.rotation += 0.01;
    }

}

EC5 自定义class

var Bunny = new Phaser.Class({
    Extends:Phaser.GameObjects.Sprite,
    initialize:function Bunny(scene,x,y,speed){
        Phaser.GameObjects.Sprite.call(this,scene);
        this.setTexture('bunny');
        this.setPosition(x, y);
        this.setScale(0.3);
        this.speed = speed;
        
    },
    preUpdate(time,delta){
        this.rotation += (0.01+ this.speed * 0.0001) ;
    }
});

完整代码:

var Bunny = new Phaser.Class({
    Extends:Phaser.GameObjects.Sprite,
    initialize:function Bunny(scene,x,y,speed){
        Phaser.GameObjects.Sprite.call(this,scene);
        this.setTexture('bunny');
        this.setPosition(x, y);
        this.setScale(0.3);
        this.speed = speed;
        
    },
    preUpdate(time,delta){
        this.rotation += (0.01+ this.speed * 0.0001) ;
    }
});
var config = {
    type: Phaser.AUTO,
    width: 600,
    height: 480,
    parent: 'phaser-example',
    scene: {
        preload: preload,
        create: create
    }
};

var game = new Phaser.Game(config);

function preload (){
    

更多游戏教学:www.iFIERO.com -- 为游戏开发深感自豪