Fix: 修复python_skulpt板卡下sprite模块不可用
This commit is contained in:
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,9 +1,6 @@
|
||||
/* eslint-disable new-cap */
|
||||
import Sk from './skulpt/skulpt';
|
||||
import {
|
||||
Events,
|
||||
Debug
|
||||
} from 'mixly';
|
||||
import { Events, Debug } from 'mixly';
|
||||
import MIXPY_TEMPLATE from '../templates/python/mixpy.py';
|
||||
|
||||
const externalLibs = {//外部引入的第三方库
|
||||
@@ -186,7 +183,7 @@ export default class PyEngine {
|
||||
|
||||
kill() {
|
||||
// 新增了sprite相关内容
|
||||
// SPRITE.kill();
|
||||
window.SPRITE.kill();
|
||||
//点击取消按钮发送数据
|
||||
Sk.execLimit = 0;
|
||||
this.executionEnd_();
|
||||
@@ -272,14 +269,20 @@ export default class PyEngine {
|
||||
run(code) {
|
||||
// Reset everything
|
||||
this.reset();
|
||||
if (code.indexOf('import sprite') !== -1
|
||||
|| code.indexOf('from sprite import') !== -1) {
|
||||
window.SPRITE.runit(Sk.TurtleGraphics.target);
|
||||
}
|
||||
this.programStatus['running'] = true;
|
||||
Sk.misceval.asyncToPromise(() => Sk.importMainWithBody("<stdin>", false, code, true))
|
||||
.then(() => {
|
||||
window.SPRITE.running = false;
|
||||
this.programStatus['running'] = false;
|
||||
this.#events_.run('finished');
|
||||
})
|
||||
.catch((error) => {
|
||||
Debug.error(error);
|
||||
window.SPRITE.running = false;
|
||||
this.programStatus['running'] = false;
|
||||
this.#events_.run('error', error);
|
||||
var original = prettyPrintError(error);
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
}
|
||||
|
||||
div[m-id="{{d.mId}}"] > #output-img {
|
||||
width: 500px;
|
||||
width: fit-content;
|
||||
height: 500px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
@@ -571,8 +571,6 @@ SPRITE.ClearTimer = ()=>{
|
||||
}
|
||||
|
||||
SPRITE.GameLoopDisplay = ()=>{
|
||||
if( pyengine.programStatus['running'] === false)SPRITE.running = false;
|
||||
else SPRITE.running = true;
|
||||
if(SPRITE.processingDisplayEvent) {
|
||||
const pSE = SPRITE.processingDisplayEvent;
|
||||
switch (pSE.displayType) {
|
||||
@@ -662,7 +660,7 @@ SPRITE.GameLoopDisplay = ()=>{
|
||||
}
|
||||
|
||||
SPRITE.ChangeWidth = (w)=>{
|
||||
const $canvas = $('#spriteContainer canvas');
|
||||
const $canvas = $(SPRITE.renderer.view);
|
||||
const canvasWidth = $canvas.width();
|
||||
const canvasHeight = $canvas.height();
|
||||
$canvas.width(w);
|
||||
@@ -682,11 +680,13 @@ SPRITE.kill = ()=>{
|
||||
SPRITE.ClearTimer();
|
||||
}
|
||||
|
||||
SPRITE.runit = ()=>{
|
||||
SPRITE.runit = (container) => {
|
||||
const $container = $(container);
|
||||
$container.empty();
|
||||
// Keep the scale mode to nearest
|
||||
PIXI.SCALE_MODES.DEFAULT = PIXI.SCALE_MODES.NEAREST;
|
||||
SPRITE.renderer = PIXI.autoDetectRenderer(SPRITE.canvasWidth, SPRITE.canvasHeight,{backgroundColor : 0x00FFFFFF});
|
||||
document.getElementById("spriteContainer").appendChild(SPRITE.renderer.view);
|
||||
$container.append(SPRITE.renderer.view);
|
||||
// Create SPRITE.stage container
|
||||
// SPRITE.stage = new PIXI.Container();
|
||||
SPRITE.pointer = {x:0, y:0};
|
||||
|
||||
Reference in New Issue
Block a user