Coder Social home page Coder Social logo

Comments (5)

ganlvtech avatar ganlvtech commented on July 1, 2024 1

Thank you.

Fixed. Please try it again. Have fun.

from phaser-catch-the-cat.

ganlvtech avatar ganlvtech commented on July 1, 2024

其实可以手动设置 canvas 的宽度和高度,这个 js 只是一个游戏的 js,具体怎么调整 canvas,可以自己使用额外的代码

from phaser-catch-the-cat.

ganlvtech avatar ganlvtech commented on July 1, 2024

window.game = new CatchTheCatGame(11, 11, 20, 'catch-the-cat');

你可以看到,游戏是这样初始化的。

from phaser-catch-the-cat.

ganlvtech avatar ganlvtech commented on July 1, 2024

@Coxxs 你有什么代码方面的建议吗?或者提交一个 Pull Request ?

from phaser-catch-the-cat.

Coxxs avatar Coxxs commented on July 1, 2024

我找到篇相关资料:https://supernapie.com/blog/support-retina-with-phaser-3 ,因为这个游戏用的都是 svg 素材,可能只需要稍微修改 Phaser 3 的初始化代码即可。

let config = {
    ...
    width: window.innerWidth * window.devicePixelRatio, // set game width by multiplying window width with devicePixelRatio
    height: window.innerHeight * window.devicePixelRatio, // set game height by multiplying window height with devicePixelRatio
    ...
    zoom: 1 / window.devicePixelRatio, // Set the zoom to the inverse of the devicePixelRatio
    ...
};

另外为了兼容旧版浏览器,建议这样使用 window.devicePixelRatio:

window.devicePixelRatio || 1

文章里还有些其他建议,可以参考下。

from phaser-catch-the-cat.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.