Question

so i am working on a game that is very siilar to tony.pa's tile-based tutorials I have this function.

function isTeleporter (xt:int, yt:int):Boolean 
    {
        if(currentMap[yt][xt] == 105)
        {
            return true;
        }else
        {
            return false;
        }
    }

In my everyframe function i have this

if(isTeleporter(hero.xtile, hero.ytile))
           {
               myParent.gotoAndStop(2);
           }

It gives this error 1061: Call to a possibly undefined method gotoAndStop through a reference with static type flash.display:Sprite.

I believe it is because to generate the game in the first frame i have this

import TBGEngine;
//call new tbg with Sprite as parameter, tbg will place all visible objects inside this sprite
var mygame:TBGEngine = new TBGEngine(this);

I want to be able to switch frames and have a new level that on the new frame or a credit screen or an animation or something, but currently i have no idea how to do so. Any help is greatly appreciated! Im a sixteen year old highschool student in a small town with no computer science program at my school, so im pretty much on my own.

Was it helpful?

Solution

You cannot use gotoAndStop() on Sprite because Sprite does not have this method - it is not intended to be used with animations. Imagine Sprite as a simple one-framed Movieclip. Whenever you want to use animations inside of a DisplayObjectContainer you MUST use MovieClip. Same if you are subclassing Sprite - your subclass will not be able to go to any frame.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top