Advertisement
Guest User

Untitled

a guest
Jul 18th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. const {ccclass, property} = cc._decorator;
  2.  
  3. @ccclass export default class NewClass extends cc.Component {
  4.  
  5. // LIFE-CYCLE CALLBACKS:
  6.  
  7. objectFromResource: Object
  8.  
  9. onLoad () {
  10. console.log("Starting onLoad() Function")
  11. var url = cc.url.raw('resources/json_resource.json')
  12. cc.loader.load(url, (err, res) => {
  13. cc.log(res)
  14. this.objectFromResource = res
  15. console.log("Loaded URL")
  16. });
  17. console.log("Ending onLoad() Function")
  18. }
  19.  
  20. start () {
  21. console.log('Starting start() Function')
  22. console.log(this.objectFromResource) //logging as null
  23. console.log('Ending start() function')
  24. }
  25.  
  26. update (dt) {
  27.  
  28. }
  29. }
  30.  
  31. Cocos Creator v2.1.1
  32. JSONReader.ts:16 Starting onLoad() Function
  33. JSONReader.ts:33 Ending onLoad() Function
  34. JSONReader.ts:37 Starting start() Function
  35. JSONReader.ts:38 undefined
  36. JSONReader.ts:39 Ending start() function
  37. JSONReader.ts:22 {__type__: "cc.JsonAsset", _name: "json_resource", _objFlags: 0, _native: "", json: Array(784)}
  38. JSONReader.ts:24 Loaded URL
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement