Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
TNTVirtualPad Error — Gideros Forum

TNTVirtualPad Error

twisttaptwisttap Member
edited January 2013 in General questions
I am getting

scene_main init
The supplied index is out of bounds.
stack traceback:

error constantly from TNTvirtualpad and cant solve for about an hour now.
What I have is
main = Core.class(Sprite)
 
local vPad
 
local function is32bit()
	return string.dump(is32bit):byte(9) == 4
end
 
if is32bit() then
	require("Helper/tntvpad32")
else
	require("Helper/tntvpad64")
end
 
 
 
 
 
function main:init()
	self.name = "scene_main"
	print(self.name .." init")
 
	vPad = CTNTVirtualPad.new(self, "Assets/vpad",  PAD.STICK_SINGLE, PAD.BUTTONS_FOUR, 20, 0)
 
	vPad:setJoyStyle(PAD.COMPO_LEFTPAD, PAD.STYLE_MOVABLE)
	vPad:setPosition(PAD.COMPO_LEFTPAD, 100, 100)
	vPad:start()
 
 
 
 
 
	-- World & DebugDraw
	_WORLD = b2.World.new(0, 9.8, true)
	_DEBUGDRAW = b2.DebugDraw.new()
	_WORLD:setDebugDraw(_DEBUGDRAW)
 
...
Anyone knows why ?
Tagged:

Comments

  • Also the folders are properly adjusted, I am using the default gfx from tnt and vpad txt is:


    tntvpad_analogpad.png, 0, 0, 64, 64, 0, 0, 0, 0
    tntvpad_base.png, 64, 0, 94, 94, 0, 0, 0, 0
    tntvpad_buttondown.png, 0, 64, 64, 64, 0, 0, 0, 0
    tntvpad_buttonup.png, 158, 0, 64, 64, 0, 0, 0, 0

  • zvardinzvardin Member
    Accepted Answer
    Hm, just a guess without looking at the code too deeply. But what if you try changing the layer to 1, or anything greater than 0?

    I'm curious if maybe it's trying to add at position 0 with the layerIndex parameter.
  • twisttaptwisttap Member
    edited January 2013
    I tried various levels there from 0 to 3 but produces' the same result.
  • twisttaptwisttap Member
    edited January 2013
    humm actually 1 worked on there after readding the whole stuff.
  • I just tested quick and if I used 0 I got the same error, so that seems to be it. When this was originally made you could add a child to position 0, I believe, which later @atilim updated to work more like lua tables so 1 is first.
  • Interesting it's up to 3, without seeing the actual code behind the scenes, I'm not sure what's happening, but @GregBUG might be interested in checking it out cause it could just be a minor usability bug.
  • I think it is the layer level of the created levels. I have
    stage and top of that main layer which 1 seems logical.
  • I think it is the layer level of the created levels. I have
    stage and top of that main layer which 1 seems logical.
    yes.

    init function is

    function CTNTVirtualPad:init(parent, textureFileName, padSticks, padButtons, borderSpace, layerIndex)

    where parent is sprite parent ex: stage
    and layerIndex is the layer level of parent.

    every pad component is added
    using addChilAt(parent, layerIndex)

    so you can control your vpad layer level.

    try example 2 of vpad
    and play with:

    back is layer 1 on stage
    carro is layer 2 on stage
    and vpad is layer 3 on stage

    as is in the example the "carro" sprite is "under" vpad (vpad is level 3 top)
    change vpad:init with level 2 and carros is over vpad...

    hope it help...
    TNT ENGiNE for Gideors Studio - Particle Engine, Virtual Pad, Animator Studio, Collision Engine - DOWNLOAD NOW !!! IT'S FREE!!! -
    www.tntengine.com
  • Yea quite a good explanation. Thanks :)
  • twisttaptwisttap Member
    edited January 2013
    Hello again, I am still having an error on this issue.
    I have two layers added to stage: grid Layer(which will be removed later) and main layer
    and on main layer I have the TNTvirtual pad.

    I am using
    vPad = CTNTVirtualPad.new(stage, "Assets/tntskinpad", PAD.STICK_SINGLE, PAD.BUTTONS_FOUR, 30,2)

    to add vpad but it is somehow adding the pads behind the other layers on main.lua
    (I am using 1.30 version of it) and since I dont have the option to add the vpad manually anyone have a solution for this ?

    The solution I found is: I am creating a third layer named uiLayer which is a empty sprite, adding it to the stage above main.lua and I add the vPad with
    vPad = CTNTVirtualPad.new(uiLayer, "Assets/tntskinpad",  PAD.STICK_SINGLE, PAD.BUTTONS_FOUR, 30,1)
    but I don't want to use this little "hack" to use vPad. :)



  • GregBUGGregBUG Guru
    edited January 2013
    @twisttap

    you "hack" is not that bad.... :)

    anyway another solution is:
    ------ main.lua -----	
    	self:addChild(bg1)
    	self:addChild(newlevel)
    	self:addChild(bg2)
     
    	vPad = CTNTVirtualPad.new(self, "Assets/tntskinpad",  PAD.STICK_SINGLE, PAD.BUTTONS_FOUR, 30,4)	
    	vPad:setTextures(PAD.COMPO_BUTTON1, "buttona.png", "buttonb.png")
     
    	vPad:setJoyStyle(PAD.COMPO_LEFTPAD, PAD.STYLE_CLASSIC)
    	vPad:setPosition(PAD.COMPO_LEFTPAD, 100, 200)
     
    ---------
    adding vpad after bg1, newlevel and bg2 and assign layer 4 on vpad...

    just tested on camera2 sources and work... :)

    but i like more your hack...

    TNT ENGiNE for Gideors Studio - Particle Engine, Virtual Pad, Animator Studio, Collision Engine - DOWNLOAD NOW !!! IT'S FREE!!! -
    www.tntengine.com
  • Actually, I decided to use that method to inlude all my UI with it. Seems more healty to me on the long run and also it is better to seperate the actual game with the UI layer.
    But thanks anyway @gregbug :)
Sign In or Register to comment.