Copy link to clipboard
Copied
Ok sorry for messing around on the forum.
I am embedding an image in its own class called character.
the code for the class is here:
package{
import flash.display.DisplayObject;
import flash.display.Sprite;
public class Character extends Sprite
{
[Embed(source="../images/character.png)]
public var GameObjectImage:Class;
public var gameObjectImage:DisplayObject = new GameObjectImage();
public function Character()
{
this.addChild(gameObjectImage);
}
}
}
Then in my application class I create a new character object like this:
public var character:Character = new Character();
Then in a function i called createGameobjects I add the object to the stage with:
addGameObjectToStage(character, 50, 50);
which uses this function also in the application class:
public function addGameObjectToStage(gameObject:Sprite, xPos:int, yPos:int):void
{
stage.addChild(gameObject);
gameObject.x = xPos;
gameObject.y = yPos;
}
I just cant get this working. I was embedding images straight into the application class, I am advised to load all images into their own class now.
The errors I get point to the Character class.
I will upload my .as files here now.
Again guys any help is much appreciated.
Edit: You will see from the Dungeon application class file that I was embedding images straight into it, this is why lines are commented out for the character. Also I am using a class called Collision for object collisions.
Sorry for any confusion.
Have something to add?
Find more inspiration, events, and resources on the new Adobe Community
Explore Now