Hi All,
Can I ask if anyone can help me with rendering an image into another image?
Is this possible?
Basically I have a situation where I need to create a sprite manually using the Draw commands - DrawLine etc.
As these items draw above everything else, I want to save the drawn image as a sprite, rotate it, position text, paste the text onto the image (think of a gameshow spin wheel), rotate again, paste more text, etc etc.
This image would then be saved and can be used in game as a... gameshow spinwheel. Well done, you guessed it.
I am a little confused as to the usage of Render, Sync, Update etc and their impact to what I am hoping to do.
Below is basic code. Note the function call to CreateSpinWheel() - no combination of Render, Sync etc seems to bear fruit - I can manage to have the wheel show (built using the DrawLine function) OR the pasted text (and hence rotates as it should - albeit without the wheel behind), but cant seem to be able to get both together.
It feels as though an image can not be rendered into another image?
Any help or pointers would be greatly appreciated. Thanks.
// Project: SpinWheelWIP
// Created: 2015-05-04
// set window properties
SetWindowTitle( "SpinWheelWIP" )
SetWindowSize( 1080, 1920, 0 )
// set display properties
SetVirtualResolution( 1080, 1920 )
SetOrientationAllowed( 1, 1, 1, 1 )
Wheel_Img=1
CreateRenderImage(Wheel_Img,1080,1920,0,1)
WheelSpr=CreateSprite(Wheel_Img)
SetSpriteVisible(WheelSpr,0)
SetSpriteOffset(WheelSpr,1080/2,1920/2)
Final_Img=2
CreateRenderImage(Final_Img,1080,1920,0,1)
FinalSpr=CreateSprite(Final_Img)
SetSpriteVisible(FinalSpr,1)
SetSpriteOffset(FinalSpr,1080/2,1920/2)
rad=500
segments=3
col=Random(0,255)
Dim colours[10]
For n=0 to 10
colours[n]=MakeColor(Random(0,255),Random(0,255),Random(0,255))
Next n
Dim name$[10]
name$[1]="Martin"
name$[2]="Andy"
name$[3]="Lisa"
name$[4]="Lyla"
name$[5]="Jessica"
name$[6]="Olly"
name$[7]="Fred"
name$[8]="Mohammed"
name$[9]="Dunny"
name$[10]="PooTash"
spin#=0
spinspeed#=0
CreateSpinWheel(segments,rad,Wheel_Img,Final_Img)
do
SetSpriteAngle(FinalSpr,spin#)
spin#=spin#+spinspeed#
If spin#>360 then spin#=0
If spinspeed#>0 then spinspeed#=spinspeed#-0.3
If spinspeed#<0 then spinspeed#=0
If (GetPointerReleased())
spinspeed#=spinspeed#+Random(50,80)
EndIf
//DrawEllipse(1080/2,1080/2,1080/2,1080/2,MakeColor(255,255,255),MakeColor(0,0,0),0)
Print( ScreenFPS() )
Sync()
loop
Function CreateSpinWheel(segments,rad,Wheel_Img,Final_Img)
cx=1080/2
cy=1920/2
SetRenderToImage(Wheel_Img,0)
//ClearScreen()
slice#=360/segments
For seg=0 to segments
For a#=seg*slice# to (seg+1)*slice# step 0.05
ox#=Sin(a#)*rad
oy#=Cos(a#)*rad
DrawLine(cx,cy,ox#+cx,oy#+cy,colours[seg],colours[seg])
Next a#
Next seg
//Render()
Sync()
SetRenderToImage(Final_Img,0)
//ClearScreen()
//Render()
//Sync()
text=CreateText("Name")
SetTextSize(text,100)
SetTextPosition(text,1080/2,1920/2)
SetTextVisible(text,1)
//Render()
Sync()
//DrawEllipse(cx,cy,rad,rad,MakeColor(255,255,255),MakeColor(0,0,0),0)
SetRenderToScreen()
SetTextVisible(text,0)
EndFunction