Skip to content
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

window.preload = function() #1

Closed
mchangxe opened this issue Feb 10, 2019 · 2 comments
Closed

window.preload = function() #1

mchangxe opened this issue Feb 10, 2019 · 2 comments

Comments

@mchangxe
Copy link

Hi! Thanks for making this great adapter! One question tho, is it still possible to used the preload function in processing in weapps using this library? I am trying to preload some images to use for later in the app. Thanks again!

@avantcontra
Copy link
Owner

@mchangxe Thks!

The preload() function mechanism is normal as p5.js.

But I found that when loadImage() in preload, the image will not be shown after draw(). There are two reasons:

  1. If preload() called, you will need call canvas.style.visibility = 'visible'; once again in setup(), otherwise all the content of the canvas will not be shown.
  2. Canvas of the image created by loadImage() in preload() is not the same as the canvas in setup() or draw(). It should be something conflict with WeChat Mini Game. I'll try to find more next.
    For now you can loadPixels() in callbackFunction of loadImage(xxx, callbackFunction) in preload(), and then setup the pixels to another Image created in draw().

@avantcontra
Copy link
Owner

@mchangxe , now you can use preload and loadImage as usual! Thanks @xarray!!
Just pull the latest master branch, and you can find a loadImage example in sketch.

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

No branches or pull requests

2 participants