繁体   English   中英

AS3 OOP继承和功能

[英]AS3 OOP inheritance and functions

我希望有人可以帮我解决一个问题我试图将我创建的拼图中的as3代码集成到我的游戏FLA文件中。

在Game.fla中,我有一个名为Engine的主类,它包含从库中调用多个空影片剪辑到舞台,然后用库中的资源填充每个影片剪辑。 每个影片剪辑都有自己的与之关联的类。

我已经在一个单独的文件中创建了每个谜题,并使用自己的主类进行测试并确保谜题有效,当我尝试将谜题的代码添加到movieclip类时,我遇到了一些错误

输出错误

  **Warning** The linkage identifier 'feedback2' was already 
   assigned to the symbol 'wrong_box', and cannot be assigned 
    to the symbol 'graphics/scrambleAssets/wrong_box',
    since linkage identifiers must be unique.

和编译器错误

                  Line 132 1136: Incorrect number of arguments.  Expected 1.

第132行是这样的:

  if(ques_num==words.length){removeChild(checker);
  f3=new feedback3;
  addChild(f3);
   f3.x=100;
   f3.y=100;
  }else{
  getword();}

主类

      public function show_level1Puzzle(){

        level1Puzzle_screen = new level1Puzzle(this);
        remove_levelChooseBoy();

        addChild(levelPuzzleBoy_screen);
        level1Puzzle_screen.x=510;
        level1Puzzle_screen.y=380;
    }

** level1Puzzle的等级**

    package actions {

import flash.display.MovieClip;

public class level1Puzzle extends MovieClip {
                    public var main_class:Engine;

                    // variables used in puzzle
                   var words:Array = new Array; 
        Var rand1:int;var rand2:int; 
        var i:int; //variable used for loop iterations
        // more variables

    public function level1Puzzle(passed_class:Engine) {
                    main_class = passed_class;

    public function getword(passed_class:Engine) {
        main_class = passed_class;
        words=["cat","dog"];
        current_word=words[ques_num];
        setTiles(current_word.length);
        ques_num++;
    }
    public function setTiles(a) {tileArray=[ ];
        for(i=0;i<a;i++){
            var tempclip:Tile =new Tile;addChild(tempclip);
                tempclip.x=300+(i*180);tempclip.y=200;tempclip.tag=i;
            tempclip.original_posx=tempclip.x;
            tempclip.original_posy=tempclip.y;
            tileArray[i]=tempclip;

            var tempclip2:Placeholder =new Placeholder;addChild(tempclip2);
            tempclip2.x=300+(i*180);tempclip2.y=400;
            targetArray[i]=tempclip2;

        }//for i
        scramble_word(a);
    }

// PUZZLE的更多功能

这个函数有一个参数:

public function getword(passed_class:Engine) {
        main_class = passed_class;
        words=["cat","dog"];
        current_word=words[ques_num];
        setTiles(current_word.length);
        ques_num++;
    }

在第132行,您没有传递参数,因此这是错误消息的原因。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM