englercj / resource-loader

A middleware-style generic resource loader built with web games in mind.
http://englercj.github.io/resource-loader/
MIT License
424 stars 77 forks source link

i can't load a image from url #115

Closed chrisyer closed 6 years ago

chrisyer commented 6 years ago

I try to load a image from http://thirdwx.qlogo.cn/mmopen/XYrRG5UShDcrTQs7ZnsUks0uT8AqAPcwNPnwmnHef1c0a5O2ScvubY5iaB9nHCAswFCWJLicic6Z3FLWcXTEYvw1qYOQG2f9gQn/132

param:

{
  name: 'avatar',
  url: 'http://thirdwx.qlogo.cn/mmopen/XYrRG5UShDcrTQs7ZnsUks0uT8AqAPcwNPnwmnHef1c0a5O2ScvubY5iaB9nHCAswFCWJLicic6Z3FLWcXTEYvw1qYOQG2f9gQn/132',
  options: {
    xhrType: PIXI.loaders.Resource.XHR_RESPONSE_TYPE.BLOB,
  },
}

but i find the resource's data is text

default

example: https://jsfiddle.net/w6puqrsx/8/

themoonrat commented 6 years ago

I've fixed your fiddle: https://jsfiddle.net/L6wn9b4p/

There were a number of things causing it not to work

  1. You weren't adding the canvas element correct. I've fixed this with document.body.appendChild(app.view);
  2. You correctly worked out that you needed to manually set a loadType, because your url has no extension, but you'd created a new options object when you were already within the options object
  3. You needed to use the texture of res.test to create the Sprite

(ps. I'd really recommend using a non minified version of pixi for your fiddles. It makes debugging so much easier!)

chrisyer commented 6 years ago

Thanks very much for you reply.

发送自 Windows 10 版邮件https://go.microsoft.com/fwlink/?LinkId=550986应用


发件人: Dave Moore notifications@github.com 发送时间: Saturday, August 11, 2018 6:51:48 PM 收件人: englercj/resource-loader 抄送: Cheng; Author 主题: Re: [englercj/resource-loader] i can't load a image from url (#115)

I've fixed your fiddle: https://jsfiddle.net/L6wn9b4p/

There were a number of things causing it not to work

  1. You weren't adding the canvas element correct. I've fixed this with document.body.appendChild(app.view);
  2. You correctly worked out that you needed to manually set a loadType, because your url has no extension, but you'd created a new options object when you were already within the options object
  3. You needed to use the texture of res.test to create the Sprite

― You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/englercj/resource-loader/issues/115#issuecomment-412267551, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ANtC1KqgXnqZ-7pGShy4eJHSceU2MxJsks5uPrdEgaJpZM4V5Flc.