Main Menu

FrameSheetAnims

Started by ATLUS, July 29, 2008, 04:59:03 AM

Previous topic - Next topic

ATLUS

TransparentColour not found
PlayBASIC Code: [Select]
; PROJECT : bug
; AUTHOR : ATLUS
; CREATED : 29.07.2008
; EDITED : 29.07.2008
; ---------------------------------------------------------------------

setfps 60
#include "FrameSheetAnims"

; Tell Frame Sheet Library to create FX images for use as rotated sprites
FrameSheetDefaultImageType=2
loadimage "anime.bmp",2
walkfr=NewFrameSheet(2,24,32,3,-1)
walk=NewAnim(walkfr,7)
Xpos =300
ypos =60
CreateSprite 1

; set sprite to Rotated mode
SpriteDrawMode 1,2 ; set sprite to rotated mode

; Tell PB to auto center this sprite, so it can be easily mirror/flipped
AutoCenterSpriteHandle 1,true

do
Cls Rgb(0,0,0)

if leftkey()=true
Xpos=Xpos-1
stepanim(walk)
scalespriteX 1,-1 ; negate scaling to flip sprite on the X axis (LEFT)
endif

if rightkey()=1
Xpos=Xpos+1
stepanim(walk)
scalespriteX 1,1 ; restore position scaling to flip sprite on the X axis (RIGHT)
endif
remstart if spacekey()=true
stepanim(kick)
endif remend

SpriteImage 1,GetAnimImage(walk)

Positionsprite 1,Xpos,Ypos

Drawallsprites

sync
loop




and little qustion how make anim if anim images in midle frameimage(need make blow by hand)?

thaaks

For the transparent color you should use the function NewFrameSheet() properly. The last parameter is the transparent color.
For your image I would assume your call should look like

walkfr=NewFrameSheet(2,24,32,3,RGB(255,0,255))


For the separate animations: Either use separate images - one for each animation sequence. Or you need to deal with the animation position on your own (using AnimPos(ThisAnim,pos) and GetAnimPos(ThisAnim)).

I'd suggest simply use separate images for each animation sequence. Simplifies dealing with separate animations a lot  ;)

Hope that helps,
Tommy

ATLUS

oh its too not bug  :-\ Sorry for topic!!!

And Thanks for answer!!!!

ATLUS

#3
Plz help me! I already all tried not what be not got with anim on button :-\
Thanks

PlayBASIC Code: [Select]
; PROJECT : move
; AUTHOR : ATLUS
; CREATED : 08.08.2008
; EDITED : 08.08.2008
; ---------------------------------------------------------------------

; ---------------------------------------------------------------------

; limit Frame rate to a Max of 60 frames (redraws per second)
openscreen 248,168,32,1
Setfps 60
#include "FrameSheetAnims"
FrameSheetDefaultImageType=2
loadimage "anime.bmp",2
ast32frames=loadframesheet("anime.bmp",24,32,-1)
anim1=NewAnim(ast32Frames,7)
createsprite 1
spritedrawmode 1,2
AutoCenterSpriteHandle 1,true
loadimage "bbackDro.bmp",1
preparefximage 1
drawimage 1,1,1,1
Type tObject
X# ; Objects X coordinate on the screen
Y# ; Objects Y coordinate on the screen
Speed# ; Speed Object is moving

Jumping ; Flag to indicate if the object uis jumping
JumpHeight# ; height (in pixels) this charcter can jump
JumpAngle# ; When jumping object moves this angle from 0 to 180 degrees,
; when the object is drawn, it displaced on the Y axis by SIN() of jump angle#

EndType
cirx#=1
ciry#=143
Dim Player as tObject
Player.X=1
Player.Y=143
Player.Speed=1

Player.JumpHeight# =35 ; object can jump 100 pixels



// -------------------------------------
// Start of Programs MAIN LOOP
// -------------------------------------
Do
setcursor 0,0
drawimage 1,0,0,1
// -------------------------------------
// Control Player (ARROW KEYS)
// -------------------------------------

if LeftKey()=true
// MOve the player left
Player.x#=Player.x#-PLayer.Speed#
cirx#=cirx#-PLayer.Speed#
stepanim(anim1)
scalespriteX 1,-1
endif
if Player.x#<0 then Player.x#=0
if cirx#<0 then cirx#=0
if RightKey()=true
// MOve the player RIGHT
Player.x#=Player.x#+PLayer.Speed#
cirx#=cirx#+PLayer.Speed#
stepanim(anim1)
scalespriteX 1,1
endif
if Player.x#>248 then Player.x#=248
if cirx#>248 then cirx#=248
if UpKey()=true
// MOve the player UP
Player.Y#=Player.Y#-PLayer.Speed#
ciry#=ciry#-PLayer.Speed#
stepanim(anim1)
endif
if Player.y#<125 then Player.y#=125
if ciry#<125 then ciry#=125

if DownKey()=true
// MOve the player DOWN
Player.Y#=Player.Y#+PLayer.Speed#
ciry#=ciry#+PLayer.Speed#
stepanim(anim1)
endif
if Player.y#>150 then Player.y#=150
if ciry#>150 then ciry#=150
// LEFT CTRL key to jump
if Ctrlkeys(1)=true
if player.Jumping=false
player.jumping=true
player.JumpAngle#=0
endif
endif

// Update the Jump angle
if Player.jumping=true
JumpAngle#=player.JumpAngle#+2
if JumpAngle#=>180
Player.Jumping=false
JumpAngle#=0
endif
Player.JumpAngle#=JumpAngle#
endif

// -------------------------------------
// Draw Player as ellipse
// -------------------------------------
;add the players jumping offset to the players screen position
Ypos#=PLayer.Y# -Sin(Player.JumpAngle#)*Player.JumpHeight#
Ellipsec cirx#,ciry#+16,9,4,true, Rgb(0,0,0)
SpriteImage 1,GetAnimImage(anim1)
Positionsprite 1,Player.x#,Ypos#
Drawallsprites
print player.jumping
// -------------------------------------
// DRaw the screen, and loop back to the do statement ot keep program running
// -------------------------------------

Sync
loop








kevin

#4
Update

  I've update the example to use your graphics.   This versions support 8 way movement,  jumping, walking, punch and kick animations.



ATLUS

Great  :o !!!!!!!!!!!!!
Very big thanks you!!!!!!!!!!!!!!!!!!!
I learn this method so remember it everywhere
again thanks!!!

thaaks

Just looked at the beatemup example for the first time - I should have done earlier  :o

I could have done the animation stuff in "Who stole Waldo?" much simpler  ::)

Cheers,
Tommy