dimanche 18 septembre 2016

Need help on laying out images on the screens

Ok, so I'm working out on this android app for my subject. I'm still an amateur at the AS3 language so I need your help.

I'm trying to figure out the best way to display image files for the android layout of each screen. My initial idea was to actually put all the layouts into a single picture so all I have to do is just display the image for the screen image. But that's bad practice and that means my image x and y coordinates are not exact.

So, I tried displaying the base menu picture file and image 2 and add them both into the screen. However, I only seem to captured the base menu but not the 2nd image.

My function for getting the images, under class name "MyResource'

      public function getImage(name:String):Image{
        var img:Image = new Image(assetManager.getTexture(name));
        return img;
    }

My 'main menu' class. It has a bunch of buttons that will redirect it to selected the selected class containing the screens.

    switch (btn.name)
        {
           case "genji": 
            trace("Genji voice menu was selected.");
            app.getScreenManager().getScreen(ScreenManager.SCREEN_GENJI);
            break;
        } 

The screen class that's supposed to display the 2nd image.

    public class GenjiScreenClass extends Screens 
{


    public function GenjiScreenClass(app:StarlingBaseClass) 
    {
        super(app);

    }

    override public function initialize():void{
        trace("I am in GenjiScreenClass initialize() function");

        var img:Image = myResource.getImage("basemenu320x480");
        var genjiImage:Image = myResource.getImage("GenjiMenuPicture")
        this.addChild(genjiImage);
        this.addChild(img);



    }



} 

The image files are all under asset/x1. The base menu image came out but how come the 2nd one didn't?

Aucun commentaire:

Enregistrer un commentaire