actually, i couldn’t understand what you mean, but when i clicked your getters/setters link, then i got it… that’s something “awesome”!!!
Access of undefined property
@SHiLLySiT, @jacobalbano i’ve a little question about this “multiplication” stuff, i mean, actually not instance multiplication, so it’s not multiplication i think anyway, my question is about embedding things, i’m using a global store class to embed everything and get from there to entities while entities creating… is that wrong? also, what if i embed “same file with same path” to “two or more different classes in their own package” is compilation combines them or adds two different image files to swf?
How to best manage embedded assets?
More coding issues, is the added class on the frame it is added? because i cant seem to be able to get the entity to change graphic when hovered over:
override public function added():void
{
var gameWorld:GameWorld = world as GameWorld;
if (gameWorld.FleaCount >= 5)
{
if (collidePoint(x, y, Input.mouseFlashX, Input.mouseFlashY))
{
graphic = new Image(FLEAHOVERED)
}
else
{
null
}
}
}
that’s yours
if (collidePoint(x, y, Input.mouseFlashX, Input.mouseFlashY))
you’re missing parameters here, also i can’t understand, doesn’t your function requiring “type” value?
that’s default
collidePoint(type:String, pX:Number, pY:Number)
The collidePoint() function doesn’t take a type parameter. It checks to see if the entity overlaps with a position.
You’ll want to put this code in the update() function rather than added(), otherwise it will only run once. It’s also a good idea to store the images for each state rather than creating a new one every time the entity is hovered. I also recommend using the world coordinates of the mouse.
if (collidePoint(x, y, world.mouseX, world.mouseY))
{
graphic = hoveredImage;
}
else
{
graphic = normalImage;
}
oh, sorry for that, i’m used to use world class’s collidePoint() function… i’ve just realized that.
Does it show up in the debug console? I can’t think of anything that would be wrong at this point, so I’m just guessing. Also, are you sure the collide check is actually running? Is it possible that gameworld.FleaCount >= 5
is always false?
even without gameworld.FleaCount
the collide check isn’t working.
And there’s nothing in the console
If there’s nothing in the console, something else is definitely wrong. Are you 100% sure the entity is actually in the world? Did you override update() in your World class and forget to call super.update()?
oh…
Thanks, it works again.
Shows how much i know about this. But, why do you have to call super.update?
Also earlier you said to grapic = hoveredImage
i have a class for hovered image but, how do you store the graphic?
public class MyEntity extends Entity
{
private var hovered:Image;
private var normal:Image;
public function MyEntity()
{
super();
hovered = new Image(HOVERED);
normal = new Image(NORMAL);
graphic = normal;
}
override public function update():void
{
super.update();
if (collidePoint(x, y, world.mouseX, world.mouseY))
{
graphic = hovered;
}
else
{
graphic = normal;
}
|
}
You need to call to super because otherwise the original method you’re overriding won’t be called.
Yay, same error as last time, how can I access a var that is in a entity class, rather than an world class. Thanks.
I am trying to select a certain entity, and when it is selected, the world class needs to know so it can spawn a new entity relative to it. i have a Variable in my entity class; FleaSlected, but the world class can’t access it.
Can you share some of the code from your entity class?
Is the FleaSelected
variable public
, or is it protected
or private
?
Is this Entity
stored non-locally in your World
class somewhere or do you use something like add(new Entity())
?
If you share more information about your code and code structure, it will be a lot easier for us to help you.