Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
First post and question - Page 2 — Gideros Forum

First post and question

2

Comments

  • john26john26 Maintainer
    @loucsam, try restarting adb like this (enter these commands at the command prompt):

    C:\Android\android-sdk\platform-tools>adb kill-server

    C:\Android\android-sdk\platform-tools>adb start-server
    * daemon not running. starting it now on port 5037 *
    * daemon started successfully *

    Eclipse should then recognise your tablet. The tablet should appear when you choose Run As...
  • john26john26 Maintainer
    @loucsam, I've also PM'd you the comparison between Lua and Python I mentioned. Hope it helps!
  • No internet at home for past 24 hours and still none, so I rediscovered my television last night! (posting now from work)

    Thanks john26 for the lua v python comparison email(and the FORTRAN mentions (I've mostly been a FORTRAN programmer), it is very useful. :D

    I'll try john26's method with the adb commands and see if that works, if not try yours scouser, thankyou, although it sounds like a good learning exercise anyway scouser.



    (don't even know what adb is yet, at a guess Android DeBug?) Google tells me .......... "Android Debug Bridge (adb) is a versatile command line tool that lets you communicate with an emulator instance or connected Android-powered device" )

    Cheers,
    Max
  • and i had completed 500 post wooooohooooo :bz


    :D
    Not bad - almost halfway there :)
    @techdojo :-
    I cant understand whether you are trying to encourage me or ....

    :)
  • Always encouraging young padawan, always encouraging....
    :)
    WhiteTree Games - Home, home on the web, where the bits and bytes they do play!
    #MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill
  • 4 days so far without internet :| (posting from work)

    I've been concentrating on game coding over the weekend, and have gotten well into it. I've had some 'technical difficulties' with Lua slowing me down, especially with attempting to use 'classes', as I am not an OOP type of guy, more like an OOPS guy.

    Also I started with the game template and found it too confusing as a starting point, and went back to basics and created my own from scratch. The template will be invaluable once I have sussed things out a bit more.

    I do have one specific question at the moment, which has been my biggest issue.

    I have a chess board as the playing surface, and I place some pieces on the board, I then want to click on a vacant square and know which square it is(x=3,y=5), and if there is a piece on the square know which piece is on it.

    So far I have created ONE listener, and then I do some fancy screen x coordinate to board x position , screen y to board y conversions to determine where I am clicking.

    Initially I intended having one listener per square, and per piece to tell me which square or piece is being selected, and I half expected event to pass me enough information to tell me which square was clicked, but no luck.

    How would you implement this?

    (Can't post code from work sorry.)

    P.S. No the game is not an actual game of chess. It's a chess logic related puzzle.

    Cheers,
    max
  • BJGBJG Member
    edited February 2013
    Sounds like you could set up a class for the pieces which inherits from Sprite. You'd have an "Init" section which would add a listener, and a method to handle the event which used "hitTestPoint" to see whether the coordinates of the event fell within the bounds of the piece. This would allow a particular piece instance to determine whether it had been clicked or not. I think it might look something a bit like this...
    Chesspiece = Core.class(Sprite)
    function Chesspiece:init()
    	self:addEventListener(Event.MOUSE_DOWN, self.clicked, self)
    :
    :
    function Chesspiece:clicked(event)
    if self:hitTestPoint(event.x, event.y) then
    :
    :
  • ScouserScouser Guru
    edited February 2013
    @loucsam: maybe you need something like
    gameScreen = Core.class(Sprite)
     
    tile = Core.class(Sprite)
     
    local BOARD_WIDTH = 8
    local BOARD_HEIGHT = 8
     
    local appWidth = application:getLogicalWidth()
    local appHeight = application:getLogicalHeight()
     
     
    local TILE_SIZE = 38
    local GRID_OFFSET_X = ((appWidth - (BOARD_WIDTH * TILE_SIZE)) /2) - TILE_SIZE
    local GRID_OFFSET_Y = 120 - TILE_SIZE
     
    local BLACK = 0
    local WHITE = 0xffffff
     
    function tile:touchTile( event )
    	if self:hitTestPoint(event.x, event.y) then
    		event:stopPropagation()
    		if self.bIsEmpty then
    			-- Put code here to put a piece on the board
    		print( self.row, self.col, self )
    		end
    	end
    end
     
    function tile:init(x, y, col, parent)
    	local xp = (x * TILE_SIZE) + GRID_OFFSET_X
    	local yp = (y * TILE_SIZE) + GRID_OFFSET_Y
     
    	local tile = Shape.new()
    	local alpha = 1.0
    	self.bIsEmpty = true
    	tile:setFillStyle(Shape.SOLID, col, alpha)
     
    	tile:beginPath()
    	tile:moveTo(0,0)
    	tile:lineTo(TILE_SIZE,0)
    	tile:lineTo(TILE_SIZE,TILE_SIZE)
    	tile:lineTo(0,TILE_SIZE)
    	tile:lineTo(0,0)
    	tile:endPath()
     
    	self.x = xp
    	self.y = yp
    	self.row = y
    	self.col = x 
     
    	self:setPosition(self.x, self.y)
     
    	self.tile = tile
    	self.parent = parent
    	self.piece = 0
    	self:addChild(tile)	
    	self:addEventListener(Event.MOUSE_UP, self.touchTile, self)
    end
     
    board = Core.class(Sprite)
     
    function board:init()
    	self.grid = {}	-- This is the actual playing area
    	local x, y, colour, row, t
    	colour = WHITE
    	for y=1, BOARD_HEIGHT do
    		row = {}
    		for x=1, BOARD_WIDTH do
    			t = tile.new(x, y, colour, self)
    			row[x] = t
    			self:addChild(t)
    			if x < BOARD_WIDTH then
    				if colour == BLACK then colour = WHITE
    				else colour = BLACK end
    			end
    		end
    		self.grid[y] = row
    	end
    end
     
    function gameScreen:init()
    	self.board = board.new()
    	self:addChild(self.board)
    end
     
    -- Update the screen elements here
    function gameScreen:onEnterFrame(event)
    end
    This code will create a chess board with 64 clickable tiles and print the tile coords within the grid and also the tile object when you click on it.
  • Thankyou so much to both of you. The support in this community is just amazing.

    Clearly this line:
    if self:hitTestPoint(event.x, event.y) then
    was the key to getting this working.

    Would you mind explaining why you do a stopPropogation? I read the docs, and I understand the English meaning of the word, I just don't understand why it is needed in this context.

    I'll try attach an image of how it is looking so far....

    Many many many thanks,
    Max
    bandicam 2013-02-18 21-56-23-102.jpg
    595 x 634 - 64K
  • You could just about suss out the game from looking at the image I reckon ;)
  • @loucsam: (I almost wrote louscam :) ). The stopPropogation is just a habit to stop the touches being sent to any layers below the board. You can omit it if you want, it shouldn't affect your game.
  • It's a good habit to get into though, as if you don't you'll find that your touch events are actually sent to EVERY object in the display tree and if you don't stop them, then you'll end up responding to multiple touch events, which could cause some nasty bugs.
    WhiteTree Games - Home, home on the web, where the bits and bytes they do play!
    #MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill
  • loucsamloucsam Member
    edited February 2013
    Things are going well, putting logic in place, although I can see a problem needing to be resolved at some point.

    How do I set the hierarchy/priority of bitmaps being displayed on the screen?

    I have 2 groups of 5 images, where one group needs to always be displayed over the top of the other group?

    Alternatively, the current single image being moved about needs priority over all the others regardless of which group of 5.

    Is the hierarchy random-ish, or order of creation, or can I set the priority?

    p.s. I completely re-factored my code using scouser's sample code above(Thankyou again scouser), which has helped a lot, some mysteries remain in it though, but I'm getting there.

    Cheers,
    Max
  • Ok I eventually found this.
    http://www.giderosmobile.com/forum/discussion/1521/z-axis-or-stage-drawing-order

    Essentially I have to create the sprites in the order lowest to highest priority (I think), I will go read it properly.
  • loucsamloucsam Member
    edited February 2013
    It refers to this code:
    function Sprite:bringToFront()
    	self:getParent():addChild(self)
    end
     
    function Sprite:sendToBack()
    	self:getParent():addChildAt(self, 0)
    end
     
    function Sprite:setIndex(index)
    	local parent=self:getParent()
    	if index<parent:getChildIndex(self) then
    		index=index-1
    	end
    	parent:addChildAt(self, index)
    end
    I think when my listener is triggered for the object(bitmap) I pick up and move around, that I want to stay above all the other objects, that I ought to call this Sprite:bringToFront() function.

    If my 'object' was defined similar to below, how would I use the above bringToFront?
    local texture = Texture.new("image.png")
    local bitmap1 = Bitmap.new(texture)
    stage:addChild(bitmap1)
  • My guess (not at home to try):

    bringToFront(bitmap1)

    Would that work?
  • As bitmap inherits from sprite, you can call
    bitmap1:bringToFront()
    or
    Sprite.bringToFront(bitmap1)
    would also work :)
  • loucsamloucsam Member
    edited February 2013
    thanks @ar2rsawseen, always good to know multiple ways of doing things, and to have an explanation why. Much appreciated.

    Update: fixed my problem. :D Cheers.
  • Hi @john26

    No I haven't as yet.

    Last week after I had 4 days without net, then I had a go at trying to connect it up (tablet to PC). Wasn't having any luck, so I went to "network" on my PC and told it to look for devices, and my computer 'blue screened'. It kept BSODding on each reboot, until I restored from the last recovery point.

    I haven't been game enough to hook it up since, as I didn't want any more dramas for now and was keen to start coding.
  • @john you mentioned adb kill/restart, would a reboot have the same effect? As in I have rebooted many times of late, wouldn't that have done the same job as a restart?

    @scouser I might send you the details soon and ask nicely for a driver made, if you wouldn't mind of course?

    Cheers,
    max
  • john26john26 Maintainer
    @loucsam, not sure if rebooting would do the same thing or not... You would have to reboot with the device connected by USB I suppose, for it to have the same effect. I would recommend doing what I said:

    1) connect device to PC
    2) restart adb as I said
    3) Select Run As from Eclipse and see if your device appears as a target.

    I think there is an adb list command (or something like that) which allows you to check all devices adb can detect. If adb can't see it, Eclipse can't either.
  • Thanks @john26 I will give it a go tonight at home, fingers crossed :D
  • Okay...
    I issued the adb devices command before connecting the tablet, and it found no devices
    I then connected the device, and as per the image attached, it searched for a driver and failed.
    I re-issued the adb devices and still no devices found:

    >adb devices
    * daemon not running. starting it now on port 5037 *
    * daemon started successfully *
    List of devices attached

    bandicam 2013-02-28 17-07-57-292.jpg
    535 x 279 - 59K
  • @loucsam: If you give me the VID & PID I can try and modify my driver file and send that to you. Maybe that will work.
    You can find your VID & PID by locating your device in your device manager (it may show up as unknown device).
    If you can't find the device itself then find the disk device in the Disk drives section of your device manager.

    Right click on the device corresponding to the android disk drive and select properties.
    Now select the Details tab in the dialog box that popped up.
    In the Property drop down list there will be an entry called parent. Select this and in the Value area you should see something like
    USB\VID_18D1&PID_4E22&MI_00\6&c2ba2f&0&0000
    Hi @scouser I found the info you needed:

    USB\VID_2207&PID_0010\0123456789ABCDEF

    Could you please have a go at creating the driver, and provide instructions for what to do with it?

    Cheers,
    Max


  • ScouserScouser Guru
    edited February 2013
    @loucsam: I have added your VID/PID to my driver setup file. Download the drivers from here and try installing for your device. Let me know if it's OK. If it doesn't work then I'm at a loss but I'm sure it should work.

    When you attach your device & windows starts looking for drivers simply tell the install process to use the drivers found in the folder where you extracted this file. Windows should do the rest.
  • loucsamloucsam Member
    edited February 2013
    Hi @scouser, thanks for that, although I don't seem to have access to that link, 'error 403'.

    Error (403)
    It seems you don't belong here! You should probably sign in. Check out our Help Center and forums for help, or head back to home.

    If I sign in to my own dropbox account it takes me to my home dropbox, and so I don't see your files.

    What am I doing wrong?
Sign In or Register to comment.