Click the seed package in the toolbar, select the appropriate seed (cabbage or radish), and add a click seeding event to the Land (not completely implemented yet)
Here, the seed object uses the constructor prototype:
Constructor prototype
// Seed object
Function Seed (event, seedname ){
This . Mousedownevent = Event | Window. event; // Mouse press event
This . Seedname = Seedname; // Seed name
This . Divseed = Null ; // Created Seeds
This . Iscanmove = False ; // Movable or not
This . Iscansow = False ; // Can I click to sow?
}
// Create seed according to different types
Seed. Prototype. createseed = Function (){
VaR E = This . Mousedownevent;
VaR Oseed = Document. createelement ( " Div " );
Oseed. style. Width= " 51px " ;
Oseed. style. Height = " 58px " ;
Oseed. style. Position = " Absolute " ;
Oseed. style. Top = Document.doc umentelement. scrolltop + E. clienty - 25 + " Px " ; // Note that the scroll bar must be taken into account when the mouse coordinates are obtained.
Oseed. style. Left = Document.doc umentelement. scrollleft + E. clientx - 0 + " Px " ;
Oseed. style. Background = " URL ('HTTP: // images.cnblogs.com/cnblogs_com/meiqunfeng/farm/seed " + This . Seedname + " . PNG ') No-repeat " ;
Document. getelementbyid ("Map"). Appendchild (oseed );
This . Divseed = Oseed;
This . Iscanmove = True ;
This . Iscansow = True ;
}
// Move the mouse to move the seed
Seed. Prototype. seedmove = Function (E ){
E = E | Window. event;
This . Divseed. style. Top = Document.doc umentelement. scrolltop + E. clienty - 25 ;
This . Divseed. style. Left = Document.doc umentelement. scrollleft + E. clientx - 0 ;
}
// Seeding
Seed. Prototype. sowseed = Function (ID ){
// Obtains the left and top of the seeds held by the mouse.
// VaR left = This. divseed. style. Left. substring (0, this. divseed. style. Left. Length-2 );
// VaR Top = This. divseed. style. Top. substring (0, this. divseed. style. Top. Length-2 );
Alert ( " Seeding successful! " );
This . Iscanmove = False ;
This . Iscansow = False ;
}