Newbie Doing Sprite Candy

Blitz3D Forums/Blitz3D Userlibs/Newbie Doing Sprite Candy

GrayKnight2k(Posted 2009) [#1]
Hello there,

So it has been awhile since I have been tinkering around with Blitz3D and I am trying to get back into it. I am trying to use SpriteCandy to do my 2D images in the 3D component and I can't even get screen positioning correct...

I am trying to create a 1280x1024 screen resolution and position a 1280x1024 background image starting in the upper left of the screen and stretching all the way to the lower right. For some reason my background at coordinates "0,0" start way off of my screen. The 0,0 origin is far off screen and I do not know why. In addition, the 1280x1024 background I created does not fill up the entire 1280x1024 view. See the following code:

;Resolution
Const Screen_Width  = 1280
Const Screen_Height = 1024

Graphics3D Screen_Width, Screen_Height, 0, 1


SetBuffer BackBuffer()

; INCLUDE 
Include "sprite candy.bb" ;Sprite Candy -- Awww Yea

; CREATE CAMERA, LIGHT, BACKGROUND
Cam = CreateCamera()

; CREATE THE HUD
HUD% = HUD_Create (Cam)

; LOAD IMAGE RESOURCES
Resource1% = HUD_LoadImageResource ("background.png") ;background

; CREATE LAYERS
Layer_Background% = HUD_CreateLayer(HUD, Resource1) ;background layer

; CREATE IMAGE OBJECTS
Image_Background% = HUD_CreateImage (Layer_Background, 0,0)

; ------------------------------------------------------------------------
; MAIN LOOP
; ------------------------------------------------------------------------
While Not KeyDown(1)

	HUD_Update 
	RenderWorld 
	Flip 0
	
Wend

HUD_RemoveAll True 
End




Does anyone have thoughts on how to fix it? I am very frustrated by what seems like such a "simple" problem.

Thanks,

-Gk2k


GrayKnight2k(Posted 2009) [#2]
Is it possible that sprite candy cannot read a 1280x1024 sized texture? I have been fooling around with it and the width seems to clip (and repeat the image) starting at 1000 pixels in...


GIB3D(Posted 2009) [#3]
Texture's size must be to the power of 2
128x128
1024x512
2x2
32x64

So if Sprite Candy uses textures, then that would be the problem.. or the answer.


GrayKnight2k(Posted 2009) [#4]
Thank you, that makes sense.

Do you know, then, if textures draw on the screen by default starting in the center, or from the upper left corner of the texture? I am trying to draw textures beginning from the upper left point of the image.


MadJack(Posted 2009) [#5]
GK2k

Look up HUD_SetObjectOrigin in your SC manual.

By default, objects (including images) have a centre origin, however you can use
HUD_SetObjectOrigin(object_name, -1,-1) to set an object's origin to top left (for example).

(Don't forget, SC has an internal screen resolution of 640x480)


GrayKnight2k(Posted 2009) [#6]
Thank you both for your help. I am going to study the manual more closely. :)