Hey !! I am developing a Javascript game using p5.js and matter.js using oop concept. I am unable to change the Image on collision. Someone help in this please!!
For further actions, you may consider blocking this person and/or reporting abuse
Hey !! I am developing a Javascript game using p5.js and matter.js using oop concept. I am unable to change the Image on collision. Someone help in this please!!
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (1)
You can use changeImage method in p5.js library. It can be used only on sprites, though. For example:
Syntax:
spriteName.changeImage("labelName")
Eg:
box.changeImage("newBox")
Also, please note that the newBox in the above example needs to be the same label that has the image loaded into it using the loadImage method.
Hope it helped you!