Scrolling Game Development Kit Forum
SGDK Version 2 => Help, Errors, FAQ => Topic started by: Tanja on 2008-03-12, 03:09:30 AM
-
this is abouts durnurds sprite template. i found one thing that may be worked over.
the range in which the player must be to activate the shooting script, is calculated so:
System.Math.Abs(this.x-(ParentLayer.m_SpriteCategories.Player[playerIdx]).x)
this works well with small sprites. the center point of this calculation is x of the sprite, not its center. but the bigger the sprite, the more the range is shifting (optically) to the left.
i tried to fix it, but i failed. this was my script:
System.Math.Abs(this.x+this.SolidWidth/2-(ParentLayer.m_SpriteCategories.Player[playerIdx]).x)
maybe this could be fixed and the sprite template be updated. that would be nice.
-
Did you try this?
System.Math.Abs(this.x-(ParentLayer.m_SpriteCategories.Player[playerIdx]).x +
(this.SolidWidth - (ParentLayer.m_SpriteCategories.Player[playerIdx]).SolidWidth) / 2)
-
seems to work the right way! thanks.
System.Math.Abs(this.y-(ParentLayer.m_SpriteCategories.Player[playerIdy]).y +
(this.SolidHeight - (ParentLayer.m_SpriteCategories.Player[playerIdy]).SolidHeight) / 2)
so, this would work to determine the right vertical range, wouldn't it? (i do not completely understand what is standing there, i only changed x and width. :laugh:)
of course the sprite must have a parameter called playerldy then, and use it.
-
You may have gotten a little trigger happy with find/replace there. Not that it's a problem, but Idx stood for "Index" which has nothing to do with the x coordinate of the sprite.