|
@@ -1,5 +1,5 @@
|
|
|
|
|
|
-const itemData = require("../data/item");
|
|
|
+const HomeApi = require("../net/HomeApi");
|
|
|
const DWTool = require("../utils/DWTool");
|
|
|
|
|
|
cc.Class({
|
|
@@ -12,8 +12,8 @@ cc.Class({
|
|
|
nameRichText: cc.RichText,
|
|
|
},
|
|
|
|
|
|
- init(propData, pickupCallback) {
|
|
|
- console.log(propData);
|
|
|
+ init(buildingId, propData, pickupCallback) {
|
|
|
+ this.buildingId = buildingId;
|
|
|
DWTool.loadResSpriteFrame(`./item/${propData.id}`)
|
|
|
.then((spriteFrame) => {
|
|
|
this.propSprite.spriteFrame = spriteFrame;
|
|
@@ -36,6 +36,17 @@ cc.Class({
|
|
|
|
|
|
this.node.y = -26;
|
|
|
this.node.x = 150;
|
|
|
+
|
|
|
+ this.node.on(cc.Node.EventType.TOUCH_END, _.debounce(() => {
|
|
|
+ HomeApi.itemCollect(this.buildingId, () => {
|
|
|
+
|
|
|
+
|
|
|
+ this.pickupCallback();
|
|
|
+ this.node.destroy();
|
|
|
+ }, (err) => {
|
|
|
+ console.log(err);
|
|
|
+ })
|
|
|
+ }, 1000, true), this);
|
|
|
},
|
|
|
|
|
|
showAnimation() {
|