I have tried your spritenegine, but it didn't work.
The texture of my sprite player is always the orange box.
Code: Select all
CompilerIf #PB_Compiler_IsMainFile
XIncludeFile "SpriteEngine.pbi"
UsePNGImageDecoder()
UseJPEGImageDecoder()
DisableExplicit
If InitEngine3D()=0 Or InitSpriteEngine()=0
MessageRequester("Init", "Failed!")
End
EndIf
InitKeyboard()
AntialiasingMode(#PB_AntialiasingMode_None)
win=OpenWindow(#PB_Any, 0, 0, 800, 600, "Sprite Engine FX", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(win), 0, 0, WindowWidth(win), WindowHeight(win))
Procedure LoadImage2(image,filename$)
img = LoadImage(#PB_Any,filename$)
w = ImageWidth(img)
h = ImageHeight(img)
Atlas=CreateAtlas(#PB_Any, w, h)
If StartDrawing(AtlasOutput(Atlas))
DrawingMode(#PB_2DDrawing_AlphaBlend)
DrawAlphaImage(ImageID(img),0,0)
StopDrawing()
EndIf
Frame=SetAtlasFrame(Atlas, #PB_Any, 0, 0, w,h,w/2,h*0.8)
ProcedureReturn Frame
EndProcedure
;draw sprite image atlas
fontID=LoadFont(0, "Arial", 22, #PB_Font_Bold|#PB_Font_HighQuality|#PB_Font_Italic)
spriteAtlas=CreateAtlas(#PB_Any, 128, 128)
If StartDrawing(AtlasOutput(spriteAtlas))
DrawingMode(#PB_2DDrawing_AlphaBlend)
FrontColor(RGBA(200, 110, 20, 255))
Box(0, 0, 128, 128)
StopDrawing()
EndIf
;define sprite frames (with centered hotspot)
squareFrame = SetAtlasFrame(spriteAtlas, #PB_Any, 5, 5, 16, 64,8,32)
dotFrame = SetAtlasFrame(spriteAtlas, #PB_Any, 5, 5, 2,2 ,1 ,1)
;create front view
frontView=CreateView(#PB_Any, RGB(62, 62, 62), #False, 0, 0, 100, 100)
If frontView
;add layer
newLayer=CreateLayer(#PB_Any, frontView, AtlasID(spriteAtlas))
sprite = LoadImage2(#PB_Any,"player.png")
Perso = CreateAnimatedSprite(#PB_Any, newLayer, 100, 300, sprite)
dot sprites
dot=CreateAnimatedSprite(#PB_Any, newLayer, 224, 153, dotFrame)
SetSpriteColor(dot,RGBA(10, 156, 63, 255))
skew sprites
rotatingSprite=CreateAnimatedSprite(#PB_Any, newLayer, 224, 153, squareFrame)
SkewSprite(rotatingSprite, 32, -32)
EndIf
Repeat
ExamineKeyboard()
If KeyboardPushed(#PB_Key_Right)
MoveView(frontView,1,0)
EndIf
If KeyboardPushed(#PB_Key_Left)
MoveView(frontView,-1,0)
EndIf
If KeyboardPushed(#PB_Key_Down)
MoveView(frontView,0,-1)
EndIf
If KeyboardPushed(#PB_Key_Up)
MoveView(frontView,0,1)
EndIf
RenderSprites()
RenderWorld()
RotateSprite(rotatingSprite,1)
FlipBuffers()
Until WaitWindowEvent(1)=#PB_Event_CloseWindow
End
CompilerEndIf