Maybe I am using the command in a wrong way.?
After some frames the program freezes.
Does the command does not work on Instances? Or does I something wrong?
Testing it with Tweentime: 0 or 0.01, causes the program to freeze sooner.
I wanted to test, if an Instance with Animation set to a specific frame will be faster than playing an animation completly.
The character is from the MP_12 (FPSC)
Anim$=GetObjectAnimationName(obj,1)
SetObjectAnimationFrame(obx[i],Anim$,1,1)
----------------- complete program -----
// Project: FENGINE
// Created: 2016-09-12
function GetValueIf(who, ifx, SetValue,elsen)
if who = ifx
SetValu=SetValue
else
SetValu=elsen
endif
endfunction SetValu
function CreateTObj(imgName$, imgName2$)
ObjID = 0
img2ID = LoadImage(imgName2$)
ObjID = CreateObjectFromHeightMap(imgName$, 32, 3, 32, 2, 2 )
RotateObjectLocalZ(ObjID,90)
RotateObjectLocalX(ObjID,-90)
RotateObjectLocalY(ObjID,90)
SetObjectImage( ObjID, img2ID, 0 )
//SetObjectUVScale( ObjID, 0, 32, 32 ) // scale the detail texture so it repeats
endfunction ObjID
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "FENGINE" )
SetResolutionMode( 0)
sizex=1280
sizey=720
SetWindowSize( sizex,sizey, 0 )
// set display properties
SetVirtualResolution( sizex, sizey )
SetOrientationAllowed( 1, 1, 1, 1 )
//img=LoadImage("characters\scifiblue_small.jpg")
img=LoadImage("characters\scifiwhite_1024.jpg")
spr = CreateSprite(img)
dim nimg[5]
for o=0 to 5
nimg[o] = CreateRenderImage(GetImageWidth(img),GetImageHeight(img),0,0 ) //GetImageWidth(img), GetImageHeight(img),32,1)
SetRenderToImage( nimg[o],0)
SetSpriteScale(spr,sizex/GetImageWidth(img),sizey/GetImageHeight(img))
SetSpritePosition(spr,0,0)
SetSpriteColor(spr,GetValueIf(mod(o,4),0,255,100),GetValueIf(mod(o,2),2,255,150),GetValueIf(mod(o,4),3,255,mod(o,2)*25+75),255)
//SetSpriteColor(spr,255,255,255,255)
//SetSpriteColor(spr,random(0,255),random(0,32)*16,random(0,3)*64,255)
DrawSprite(spr)
next
DeleteSprite(spr)
AddVirtualButton( 1, 32, 680, 64 )
SetWindowSize( 1280,720, 0 ) // !!! No Exit in Fullscreen
SetVirtualResolution( 1280, 720 )
SetRenderToScreen()
obj=LoadObjectWithChildren("characters\scifiassaulttroop.X")
objo=LoadObject("characters\scifiassaulttroop.X")
anz=GetObjectNumAnimations( obj )
if anz>0
endif
PlayObjectAnimation( obj, "",0,2000,1,1)
SetObjectImage(obj,img,0)
SetObjectImage(objo,img,0)
//SetObjectImage(obj,img,1)
SetCameraRange(1,10,2000)
SetCameraPosition( 1,0,75,-100 )
SetCameraLookAt( 1,0,37,0,0 )
SetSyncRate(0,0)
loadfig()
SetObjectAnimationSpeed(obj,15)
SetObjectPosition(objo,-50,-10,0)
dim obx[100]
for i=1 to 40
// Slow-Version:
//obx[i]=LoadObjectWithChildren("characters\scifiassaulttroop.X")
//SetObjectScalePermanent(obx[i],1,1,1)
//CloneObject(obx[i],obj)
obx[i]=InstanceObject(obj)
SetObjectVisible(obx[i],0)
//obx[i]=CloneObject(obj)
SetObjectImage(obx[i],nimg[mod(i,5)],0)
SetObjectPosition(Obx[i],mod(i,10)*60+20*mod((i/10),2)-150, (i/10)*60 -150,150)
if GetObjectNumAnimations(obx[i])>0
Anim$=GetObjectAnimationName(obj,1)
SetObjectAnimationFrame(obx[i],Anim$,1,1)
/*
PlayObjectAnimation( obx[i], "",0+10*i,2000-20*i,1,1)
SetObjectAnimationSpeed(obx[i],15)
*/
Endif
Print( ScreenFPS() )
Sync()
next
for i=1 to 40
SetObjectVisible(obx[i],1)
next
function loadfig()
endfunction
//CreateTObj("Tobj.png","Tobj_D.png")
do
if GetVirtualButtonpressed(1)=1: exit: endif
Print( Str(ScreenFPS())+" p:"+Str(GetPolygonsDrawn())+" pc:"+Str(GetPolygonsDrawn()/5398) )
Sync()
loop