Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]

SceneGroup a nil Value....how is that possible?
Started by ryhanlon Jun 09 2014 08:39 PM

2 replies to this topic
This topic has been archived. This means that you cannot reply to this topic.
[TOPIC: post.html]


[GLOBAL: userInfoPane.html]
  • Observer

  • 6 posts
  • Enterprise

I'm putting this in my Create Scene in Composer and making sure to add all of the variables to sceneGroup but I keep getting errors messages like:


Line: 101     Attempt to index global 'sceneGroup' (a nil value)


This is all pertaining to my Multiple Lines of Text which I followed using this tutorial here:



It works great until I add these variables (below) to sceneGroup.  Thanks for your help.



        function scene:create( event )
        local sceneGroup = self.view
Chapter1 = [[ Chapter One ]]
local textOptions1 = {
   text = Chapter1,
   x = display.contentCenterX + 220,
   y = display.contentCenterY - 230,
   width = 400,
   height = 100,
   fontSize =45,
   align = "center"
local textField1 = display.newText(textOptions1)
textField1:setFillColor(0, 0, 0)
local myText = [[     Laughter danced off the walls and popcorn scented the air at the Quirkydale Academy.  Like most schools throughout the galaxy, the students sat at desks and teachers wrote on Vid-Boards/Holo-Boards.
     Today Quirkydale Academy celebrated Valentine’s Day.  In the class at the end of the hall,  Itty Bitty Kittie rested her elbow on her desk and her head on her hand as her green eyes drifted closed.]]
local textOptions2 = {
   text = myText,
   x = display.contentCenterX + 220,
   y = display.contentCenterY + 110,
   width = 420,
   height = 500,
   fontSize = 28,
   align = "left"
local textField2 = display.newText(textOptions2)
textField2:setFillColor(0, 0, 0)

sceneGroup:insert (textField1)
sceneGroup:insert (myText)
sceneGroup:insert (textOptions2)
sceneGroup:insert (textField2)

[TOPIC: post.html]

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 26,608 posts
  • Enterprise

First, I don't know what line 101 is.  That would help a lot.  Secondly you are trying to insert non-display objects into the group:




myText is a string, not a display object.  It can't realistically be put into a group.  I don't know that it would generate that error, but it's possible.



[TOPIC: post.html]


[GLOBAL: userInfoPane.html]
  • Observer

  • 6 posts
  • Enterprise

Hi Rob,


Line 101 is where the sceneGroup = self.view is located.  It doesn't show as line 101 above because I copied and pasted only a part of my code..


I entered/coded my text using "The Multi-line method" of positioning text onto the page.  When I try to insert these elements into the Composer group I get the above error message.  Line 5 to 18 is the code for the first portion of code for the Multi-line method (Chapter heading) and Line 21 to 36 is code for the second entry using the multi-line method (the story text).  I've tried various ways to enter it into the composer group, but I keep getting error messages  for lines 39 to 44--I've tried all of them and some of them--different variations but always sceneGroup a nil value message).


I don't understand exactly how this group of code works together so I don't know exactly what part(which variable or variables) needs to be used to enter it into the group.  How would I put this into a group? For example into the composer group or it's own group?   I even tried making my own TextGroup but same nil error message.


Thank you for your time in helping me understand this.