It looks like you're new here. If you want to get involved, click one of these buttons!
mainmenu = Core.class(Sprite) function mainmenu:init() --Create Event Button local createBtn = Bitmap.new(Texture.new("Images/btn1.png")) local createBtn_over = Bitmap.new(Texture.new("Images/btn1_over.png")) --The Actual Button and Listener local button1 = Button.new(createBtn, createBtn_over) button1:addEventListener("click", function() self.sceneManager:changeScene("createEvent", 1, SceneManager.flipWithFade) end) --Add Button To Scene button1:setPosition(70, 200) stage:addChild(button1) ------------------------------------------------------------------------------- --Create Event Button local viewBtn = Bitmap.new(Texture.new("Images/btn2.png")) local viewBtn_over = Bitmap.new(Texture.new("Images/btn2_over.png")) --The Actual Button and Listener local button2 = Button.new(viewBtn, viewBtn_over) button2:addEventListener("click", function() self.sceneManager:changeScene("ViewEdit") end) --Add Button To Scene button2:setPosition(70,450) stage:addChild(button2) ------------------------------------------------------------------------------- --Create Event Button local settingsBtn = Bitmap.new(Texture.new("Images/btn3.png")) local settingsBtn_over = Bitmap.new(Texture.new("Images/btn3_over.png")) --The Actual Button and Listener local button3 = Button.new(settingsBtn, settingsBtn_over) button3:addEventListener("click", function() self.sceneManager:changeScene("Settings") end) --Add Button To Scene button3:setPosition(70, 700) stage:addChild(button3) ------------------------------------------------------------------------------- stage:addChild(self.sceneManager) mainmenu.sharedInstance=self end |
Dislikes: wretch
Comments
You need to use self when adding buttons as:
That is the second time I've mixed you to up .
I tried the line of code you showed me, but it still isn't showing up for some reason.
And this is really hampering me from continuing my app
Hopefully you can figure out why!
Thanks!
-Landon
Lead Coder and Designer
best regards
Here is my main.lua , and maybe you can find the problem, because I can't seem to fix the problem with:
-Landon
Lead Coder and Designer
Thanks!
-Landon
Lead Coder and Designer
Best regards
Here is my attached app file. Thanks for the help, and don't steal my idea
Have a good evening!
-Landon
Lead Coder and Designer
i also had this problem when i was using uikit and my problem was in uikit there is also button class and b'coz of that whenever i calls button.new() it was calling the class in uikit and not the our lua one and it was creating the problem might be you also have similar problem can you try giving any new class name to the button class (our lua one)
i had not tried your example and giving suggestions blindly so sorry if it will not work
Just as an aside, I think you would do well to use a capital letter to start all class names. It is common practice in Lua to use capitals for global variables and since class names are also global this fits well. This would allow you to more easily distinguish between Lua variables that are actually classes and those that are instances of those classes (which would continue to start with lowercase letter).
best regards
Thanks for the response. Yet I can't seem to replicate what I had before I added the BhWax lines, and the View/Edit Button doesn't appear as you said. I copied all of what you gave me and put main.new() in my main.lua file also. I attached my file again as a new one so you can look at it again, because it isn't working still.
And again, thanks for your help!
-Landon
Lead Coder and Designer
Here is the zipped up project that "works". I only made the changes that I detailed above. It includes the BhWax line to show the status bar, so that is working too.
If it doesn't work for you then perhaps your Gideros player is broken? Did you read @hgvyas123 's response above? Have you made sure that you aren't including the UIKit plugin in your player?
If you have checked these things and nothing works then you need to start playing detective. This is what every programmer has to learn to do. Start again with a blank project. Add one button. Does it appear? Add the BhWax line, does it work? Add the scenemanager and one scene. Does it still work? In short, try building the project up from scratch, line by line, until you find where it fails.
best regards
I took your advice and tried to make a new Project from scratch, and I keep getting stuck at the button. I can see the background I added. But I can't seem to get my buttons on the screen still. I have changed their position and it still doesn't work. I have also changed the button.lua class name to PlanitBtn.lua and changed all of the lines inside it to PlanitBtn that had to be changed from Button. I am using Retina Display with my app if that helps in any way.
I also tried to comment out the BhWax lines and also disabled init.lua from execution and that still didn't work. I am dead in the water
I have attached my sample project with all of the pictures and everything. Its very minimalistic because @bowerandy told me to build it up to the point where it doesn't work.
Have a great evening!
-Landon
Lead Coder and Designer
In your recent cut down project you have *at least* two issues. The first is that you have put the main.new() line inside the main:init() function. Hence it never gets called. Do you remember me saying it should go as the last line in main.lua? To avoid doubt, your main.lua should look like this:
I didn't mean to attach that file, I ment to attach the one that you had showed me. Sorry
I have another question. I wanted to know how I would add a datePicker to my app. I followed this tutorial by @OZApps .
http://howto.oz-apps.com/2012/10/using-date-pickers.html
But everytime I try to add it to my project it crashes, and says:
WARNING: No object named 'CGRect' found.
Party.lua:21: attempt to call global 'CGRect' (a nil value)
stack traceback:
Party.lua:21: in function 'init'
[string "property.lua"]:31: in function 'new'
scenemanager.lua:277: in function 'changeScene'
CreateEvent.lua:12: in function
I have attached my working Project up to this point so you could take a look at it. Also, where would I find documentation to add such things as a textBox, imagePicker, etc?
Again thanks for all your help!
-Landon
Lead Coder and Designer
you will have to go a little slow than the pace you are currently on. You are jumping from topic to topic or rather issue to issue very fast and not reading the resolutions.
@Andy's demo, my tutorial, etc are all based on running samples that we got working at our end. Which means that if you are unable to achieve the same, they you are missing some steps.
The CGRect is a structure and is made available via the structs.lua file which is available in the lib/stdlib folder from Corey (which is part of the wax plug-in)
If you go step by step and read line by line, you might get things working. While other developers will help you, there is only so much time that they would be willing to allocate. So use that wisely... just a suggestion.
Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
Cool Vizify Profile at https://www.vizify.com/oz-apps
I am very sorry for going at faster than a pace than I can go. Its always been a bad habit of mine. I am only 16 yrs old, and I have highschool work and other things and I'm just trying to stay on top of this my friend and I have planned for a very long time.
Also, sorry for asking so much from other developers including @bowerandy @OZApps @ar2rsawseen . I've learned the LUA language very well, but when it comes down to Objective-C, its like I've never coded before in my life.
We aren't making a game, rather we are making a Social/Travel app as you can tell by the title, Planit. We searched for the best place for LUA and Gideros was it. We saw that you could "bridge" LUA and Objective-C together to include native widgets and such.
I see many developers telling others how to use Wax and they are giving all this code, and I've been wondering where exactly they've been finding all of this, but no one has given me a definitive answer. We just need DatePickers and TextBoxes and that's really it.
@OZApps as you said, I added the structs.lua file to my app and now the DatePicker is showing up. But I am using SceneManager and the DatePicker isn't "abiding" by what SceneManager is telling everything else to do. I guess because of:
And again @OZApps @bowerandy , I am truly sorry for all of what I had done.
Thanks for still helping
-Landon
Lead Coder and Designer
Gideros uses OpenGL and everything that is native to Gideros is drawn on this OpenGL Surface. This is the same with other cross platform frameworks too.
iOS SDK uses it's own views, OpenGL is one such view. So, you can add the Gideros 'stage' to the iOS views, but you cannot add the UIView to the Gideros Stage or objects.
All of the native elements created could either be over or under the OpenGL Stage, but never part of it. Hope that helps you resolve that issue.
Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
Cool Vizify Profile at https://www.vizify.com/oz-apps
Lead Coder and Designer
Lead Coder and Designer
Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
Cool Vizify Profile at https://www.vizify.com/oz-apps
Thanks.
Lead Coder and Designer
How would I make it so that the widgets "listen" to the scene events? Also, how would I manually add and remove elements?
Sorry for asking so much, I'm just really confused.
Thanks.
Lead Coder and Designer
I suggest you read near the end of here http://appcodingeasy.com/Gideros-Mobile/Manage-Scenes-in-Gideros-Mobile to see how different stages of scene manager dispatches events that you can use to remove items and here http://www.giderosmobile.com/documentation/reference_manual.html#Sprite:removeChild for an explanation of how you remove a sprite which might help you with removing elements.
And maybe try adding a sprite to the stage (rather than to the scene) and removing it manually as the scene changes in a very simple test project with no plugins etc first
The code to set up the scene looks like this:
PS: As an aside, the demo also shows how to use the Google Text to Speech service to get speech into your apps for free - again using some simple BhWax calls.
Best regards
Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
Cool Vizify Profile at https://www.vizify.com/oz-apps
There are still two hierarchies. As you point out, the UIViews all live in a plane above all the Gideros scene (OpenGL) objects. There is no way around this. All that the BhUIViewFrame does is put a stub object in the Gideros scene that can be moved about and tweened like any other Gideros sprite. The frame just points to its associated UIView and makes sure that it moves/fades along with it.
best regards
But I have to say you appear a bit out of your depth here, especially with the BhWax stuff. In order to use it you *will* need to learn how Objective C works, if only to be able to read the code successfully. Perhaps an online tutorial might help?
If I wanted to bring up an iOS component using Wax I would first go to StackOverflow and type in a query to find if anyone else has asked how to use this component in Objective C. If you find a suitable answer then there is a fairly straightforward way of converting the Objective C into Lua. I provided a little tutorial on this here:
http://bowerhaus.eu/blog/files/activity_spinner.html
You will also need to read and understand this link:
https://github.com/probablycorey/wax/wiki/Overview
best regards
Sorry I haven't been on lately. I've just gotten over the flu and it was horrible . But atleast I'm back and back in business .
Anyways, @bowerandy , thanks for understanding. I don't mind people being like that, it shows me that I have to provide more on the problem and look at it more rather then shoot responses back without "thoroughly" looking through the answer. I've looked over your links and I'm still a little startled at the Objective-C side compared to LUA. But hopefully I will get down the concept sometime in the next week or 2.
Also, @OZApps , I looked over your tutorial here about tweeting from your app:
http://howto.oz-apps.com/2012/09/tweet-tweet-right-from-your-lua-app.html
I looked over it, and there didn't seem to be any need for any extra files. So what I did was take your code and pasted it into my app like so:
WARNING: No object named 'TWTweetComposeViewController' found.
Mainmenu.lua:12: attempt to index global 'TWTweetComposeViewController' (a nil value)
stack traceback:
Mainmenu.lua:12: in function
I have all of the files for Wax and HotWax and they are all up to date. I can't seem to find the problem as I am still trying to understand Objective-C and LUA "binding" like I stated above.
Thanks in advance.
-Landon
Lead Coder and Designer