Hi all,
I'm initially creating a sprite with a capsule shaped image and assigning a polygon collision shape, so I can automatically create a capsule collider. Then I change the image to the actual animation sheet. I set the bUpdateShape flag to false, this "should" force it to keep the original shape (or so the documentation states). However as soon as I change the image the collision shape gets updated.
Any ideas??
// this initialises the sam object
function Sam_Initialise(PosX as integer, PosY as integer)
// locals
_nColImage as integer
// do we need to do a full load or just reset the sam object
if not GetSpriteExists( g_Sam.ActorObject.WorldObject.Sprite ) or g_Sam.ActorObject.WorldObject.Sprite = 0
// load the sprite animations
g_Sam.ActorObject.WorldObject.SpriteImage = LoadSubImage(g_nActorSpriteSheet, "Sam.png")
g_Sam.ActorObject.IdleAnimation.StartFrame = 34
g_Sam.ActorObject.IdleAnimation.EndFrame = 72
g_Sam.ActorObject.IdleAnimation.FPS = 15
g_Sam.ActorObject.JumpAnimation.StartFrame = 15
g_Sam.ActorObject.JumpAnimation.EndFrame = 30
g_Sam.ActorObject.JumpAnimation.FPS = 15
g_Sam.ActorObject.RunAnimation.StartFrame = 1
g_Sam.ActorObject.RunAnimation.EndFrame = 14
g_Sam.ActorObject.RunAnimation.FPS = 15
remstart
AttackAnimation as integer
DestroyAnimation as integer
remend
// create the sprite using the collision image initially
_nColImage = LoadSubImage(g_nActorSpriteSheet, "Sam_Col.png")
g_Sam.ActorObject.WorldObject.Sprite = CreateSprite(_nColImage)
SetSpriteSize(g_Sam.ActorObject.WorldObject.Sprite, 64, 64)
SetSpriteOffset(g_Sam.ActorObject.WorldObject.Sprite, 32, 32)
SetSpriteDepth(g_Sam.ActorObject.WorldObject.Sprite, g_nMapLayerDepth)
//SetSpriteAnimation(g_Sam.ActorObject.WorldObject.Sprite, 64, 64, 107)
// set the character properties
g_Sam.ActorObject.WorldObject.Mass = 11
g_Sam.ActorObject.Acceleration = g_Sam.ActorObject.WorldObject.Mass * 10000.0
g_Sam.ActorObject.Deceleration = g_Sam.ActorObject.WorldObject.Mass * 3333.33
g_Sam.ActorObject.JumpVelocity = 450.0
g_Sam.ActorObject.WorldObject.Friction = 0
g_Sam.ActorObject.WorldObject.PhysicsType = 2
g_Sam.ActorObject.MaxSpeed = 200.0
g_Sam.ActorObject.WorldObject.Name = "Sam"
g_Sam.ActorObject.MaxHealth = 100
// configure the sprite physical properties
SetSpritePhysicsOn( g_Sam.ActorObject.WorldObject.Sprite, g_Sam.ActorObject.WorldObject.PhysicsType )
//SetSpriteShapeBox( g_Sam.ActorObject.WorldObject.Sprite, -15, -26, 15, 32, 0 )
SetSpriteShape( g_Sam.ActorObject.WorldObject.Sprite, 3 )
SetSpritePhysicsRestitution( g_Sam.ActorObject.WorldObject.Sprite, 0 )
SetSpritePhysicsMass(g_Sam.ActorObject.WorldObject.Sprite, g_Sam.ActorObject.WorldObject.Mass)
SetSpritePhysicsFriction( g_Sam.ActorObject.WorldObject.Sprite, g_Sam.ActorObject.WorldObject.Friction)
SetSpritePhysicsCanRotate( g_Sam.ActorObject.WorldObject.Sprite, 0)
// load the sounds
// set the final image
SetSpriteImage(g_Sam.ActorObject.WorldObject.Sprite, g_Sam.ActorObject.WorldObject.SpriteImage, 0)
SetSpriteAnimation(g_Sam.ActorObject.WorldObject.Sprite, 64, 64, 107)
endif
// set the common properties
g_Sam.ActorObject.Health = g_Sam.ActorObject.MaxHealth
SetSpritePositionByOffset(g_Sam.ActorObject.WorldObject.Sprite, PosX, PosY)
g_Sam.ActorObject.ActorType = kActorType_Sam
// enable this object
SetSpriteVisible(g_Sam.ActorObject.WorldObject.Sprite, 1)
SetSpriteActive(g_Sam.ActorObject.WorldObject.Sprite, 1)
// set the default animation
PlaySprite(g_Sam.ActorObject.WorldObject.Sprite, g_Sam.ActorObject.IdleAnimation.FPS, 0, g_Sam.ActorObject.IdleAnimation.StartFrame, g_Sam.ActorObject.IdleAnimation.EndFrame)
g_Sam.ActorObject.State = "idle"
g_Sam.ActorObject.StateEnterTime = GetMilliseconds()
endfunction
All programmers are playwrights and all computers are lousy actors.