Advertisement
Guest User

Untitled

a guest
Jun 1st, 2013
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. function Oggetto(idname,nome,posizione_x,posizione_y,width,height,doption){
  3.     this.nome           =   nome        ;  
  4.     this.posizione_x    =   posizione_x ;
  5.     this.posizione_y    =   posizione_y ;
  6.     this.width          =   width       ;
  7.     this.height         =   height      ;
  8.     this.doption        =   doption     ;
  9.     this.idname         =   idname      ;
  10.     console.log(this.idname);
  11.     this.context        =   document.getElementById(idname).getContext("2d");  
  12. }
  13. Oggetto.prototype.draw = function () {
  14. };
  15. Oggetto.prototype.clear = function () {
  16. };
  17.  
  18.  
  19.  
  20. function Entita(idname,nome,posizione_x,posizione_y,width,height,doption){
  21.     Oggetto.call(this,idname,nome,posizione_x,posizione_y,width,height,doption);
  22. }
  23. Entita.prototype.draw = function (){
  24.     this.context.rect(this.posizione_x,this.posizione_y,this.width,this.height);
  25.     this.context.stroke();
  26. };
  27. Entita.prototype.clear = function () {
  28.     // this.context.clearRect(this.posizione_x, this.posizione_y, this.width, this.height);
  29.      //Richiamo il metodo per la creazione di un rettangolo con background
  30.      this.context.clearRect(this.posizione_x-4, this.posizione_y-4, this.width+10, this.height+10);
  31.      
  32. };
  33. Entita.prototype.enlarge = function (w,h) {
  34.      this.clear();
  35.      this.width     =   w;
  36.      this.height    =   h;
  37.      this.draw();
  38. };
  39. Entita.prototype =  new  Oggetto();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement