小编Pab*_*noz的帖子

2D游戏中的跳跃数学

我在J2ME工作,我的gameloop执行以下操作:

public void run() {
        Graphics g = this.getGraphics();
        while (running) {
            long diff = System.currentTimeMillis() - lastLoop;
            lastLoop = System.currentTimeMillis();
            input();
            this.level.doLogic();
            render(g, diff);
            try {
                Thread.sleep(10);
            } catch (InterruptedException e) {
                stop(e);
            }
        }
    }
Run Code Online (Sandbox Code Playgroud)

所以它只是一个基本的游戏循环,该doLogic()函数调用场景中角色的所有逻辑函数并render(g, diff)调用场景animateChar中每个角色的animChar函数,然后,Character类中的函数设置屏幕中的所有内容,如下所示:

protected void animChar(long diff) {
        this.checkGravity();
        this.move((int) ((diff * this.dx) / 1000), (int) ((diff * this.dy) / 1000));
        if (this.acumFrame > this.framerate) {
            this.nextFrame();
            this.acumFrame = 0;
        } else {
            this.acumFrame += diff; …
Run Code Online (Sandbox Code Playgroud)

java math physics 2d

8
推荐指数
1
解决办法
1万
查看次数

gulp和babel与gulp-live-server

我正在尝试用ES6编写一个快速服务器而我正在使用Babel来进行转换,但是我无法使用gulp-live-server工作,因为我无法正常重启改变我的文件.

目前我有以下内容:

// gulpfile.babel.js

import gulp from 'gulp';
import gls from 'gulp-live-server';
import babel from 'gulp-babel';

gulp.task('transpile', ['clean:server'], () => {
  gulp.src(['server/**/*.js'])
  .pipe(babel())
  .pipe(gulp.dest('dist'));
});

gulp.task('server', ['transpile'], () => {
  var server = gls.new('dist/app.js');
  server.start();      
  gulp.watch(['server/**/*.js'], ['transpile']);
  gulp.watch('dist/app.js', server.start.bind(server)); //error
});
Run Code Online (Sandbox Code Playgroud)

但它不起作用,此代码返回Gaze错误:

internal/child_process.js:274
  var err = this._handle.spawn(options);
                         ^

TypeError: Bad argument
    at TypeError (native)
    at ChildProcess.spawn (internal/child_process.js:274:26)
    at exports.spawn (child_process.js:339:9)
    at Object.exports.start (/Users/oni/Documents/Projects/meanimo/node_modules/gulp-live-server/index.js:134:19)
    at Gaze.<anonymous> (/Users/oni/Documents/Projects/meanimo/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-watcher/index.js:18:14)
    at emitTwo (events.js:87:13)
    at Gaze.emit (events.js:172:7)
    at Gaze.emit (/Users/oni/Documents/Projects/meanimo/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-watcher/node_modules/gaze/lib/gaze.js:129:32)
    at /Users/oni/Documents/Projects/meanimo/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-watcher/node_modules/gaze/lib/gaze.js:415:16
    at …
Run Code Online (Sandbox Code Playgroud)

javascript ecmascript-6 gulp babeljs

2
推荐指数
1
解决办法
738
查看次数

标签 统计

2d ×1

babeljs ×1

ecmascript-6 ×1

gulp ×1

java ×1

javascript ×1

math ×1

physics ×1