Skip to content

gdx forのRubyからblockへの変換を追加 #247

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

takaokouji
Copy link

gdx_forのRubyからblockへの変換を追加しました

#245 をベースにマージできるに高尾が修正

@riversunlight
Copy link

LGTM

);
break;
}
} else {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ここで args[0] に値が設定されているかどうかをチェックすること

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

これは私のアドバイスが間違っていたね。
ここではself.whenのチェックをしてほしいので,以下を参考にしてください。結構複雑よ。
参考にするファイルは, src/lib/ruby-to-blocks-converter/event.js です。

        if ((this._isSelf(receiver) || receiver === Opal.nil) &&
            name === 'when' &&
            args.length >= 1 && args[0].type === 'sym' &&
            rubyBlockArgs && rubyBlockArgs.length === 0 &&
            rubyBlock) {
            switch (args[0].value) {
            case 'flag_clicked':
            case 'clicked':
                if (args.length === 1) {
                    let opcode;
                    switch (args[0].value) {
                    case 'flag_clicked':
                        opcode = 'event_whenflagclicked';
                        break;
                    case 'clicked':
                        if (this._context.target && this._context.target.isStage) {
                            opcode = 'event_whenstageclicked';
                        } else {
                            opcode = 'event_whenthisspriteclicked';
                        }
                        break;
                    }
                    block = this._createBlock(opcode, 'hat');
                    this._setParent(rubyBlock, block);
                }
                break;
            case 'key_pressed':
                if (args.length === 2 && this._isString(args[1]) && KeyOptions.indexOf(args[1].toString()) >= 0) {
                    block = this._createBlock('event_whenkeypressed', 'hat');
                    this._addField(block, 'KEY_OPTION', args[1]);
                    this._setParent(rubyBlock, block);
                }
                break;
            case 'backdrop_switches':
                if (args.length === 2 && this._isString(args[1])) {
                    block = this._createBlock('event_whenbackdropswitchesto', 'hat');
                    this._addField(block, 'BACKDROP', args[1]);
                    this._setParent(rubyBlock, block);
                }
                break;

@takaokouji
Copy link
Author

#257 で続きを行うため、こちらはcloseします。

@takaokouji takaokouji closed this Aug 20, 2020
@takaokouji takaokouji deleted the dev_gdx_for branch August 20, 2020 11:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants