How to switch the activity correctly? - nativescript
I'm developing a POS application with this device(on android 4.4.2) with Nativescript Vue.
I have an SDK for the device, and created a plugin to use it in my application. Everything works fine with it, like printing receipts and getting the device info, but the Payment activity is not working. I've written a function that should open the Activity and on the screen has to appear a payment interface from the device, but nothing happens.
This is my function:
payNative() {
// Build the payment call
try {
let amount = new java.lang.Double('13.87');
let payment = this.$mypos.MyPOSPayment.builder()
// Mandatory parameters
.productAmount(amount)
.currency(this.$mypos.Currency.EUR)
// Foreign transaction ID. Maximum length: 128 characters
.foreignTransactionId(UUID.randomUUID().toString())
.build();
let context = application.android.context;
// Start the transaction
// this.$mypos.MyPOSAPI.openPaymentActivity(context, payment, 1);
let MyPOSUtil = this.$mypos.MyPOSUtil;
let myposIntent;
if (payment.isMotoTransaction()) {
console.log('motoo');
myposIntent = new android.content.Intent(MyPOSUtil.PAYMENT_CORE_ENTRY_POINT_MOTO_INTENT);
console.log(myposIntent);
} else if (payment.isGiftCardTransaction()) {
console.log('giftt');
myposIntent = new android.content.Intent(MyPOSUtil.PAYMENT_CORE_ENTRY_POINT_GIFTCARD_INTENT);
console.log(myposIntent);
} else {
myposIntent = new android.content.Intent(MyPOSUtil.PAYMENT_CORE_ENTRY_POINT_INTENT);
console.log('normalll');
console.log(myposIntent);
}
let skipConfirmationScreen = false;
console.log('*************** ++++++++++++++ ******************');
console.log('INTENT_TRANSACTION_REQUEST_CODE', MyPOSUtil.TRANSACTION_TYPE_PAYMENT);
console.log('INTENT_TRANSACTION_AMOUNT', new java.lang.Double(payment.getProductAmount()));
console.log('INTENT_TRANSACTION_TIP_AMOUNT', new java.lang.Double(payment.getTipAmount()));
console.log('INTENT_SKIP_CONFIRMATION_SCREEN', skipConfirmationScreen);
console.log('INTENT_TRANSFER_TIPS_ENABLED', payment.isTippingModeEnabled());
console.log('INTENT_TRANSACTION_CURRENCY', payment.getCurrency().toString());
console.log('INTENT_TRANSACTION_FOREIGN_TRANSACTION_ID', payment.getForeignTransactionId());
console.log('INTENT_PRINT_MERCHANT_RECEIPT', payment.getPrintMerchantReceipt());
console.log('INTENT_PRINT_CUSTOMER_RECEIPT', payment.getPrintCustomerReceipt());
console.log('INTENT_OPERATOR_CODE', payment.getOperatorCode());
console.log('INTENT_REFERENCE_NUMBER', payment.getReferenceNumber());
console.log('INTENT_REFERENCE_NUMBER_TYPE', payment.getReferenceType());
console.log('INTENT_MOTO_PASSWORD', payment.getMotoPassword());
console.log('*************** ++++++++++++++ ******************');
myposIntent.putExtra(MyPOSUtil.INTENT_TRANSACTION_REQUEST_CODE, MyPOSUtil.TRANSACTION_TYPE_PAYMENT);
myposIntent.putExtra(MyPOSUtil.INTENT_TRANSACTION_AMOUNT, new java.lang.Double(payment.getProductAmount()));
myposIntent.putExtra(MyPOSUtil.INTENT_TRANSACTION_TIP_AMOUNT, new java.lang.Double(payment.getTipAmount()));
myposIntent.putExtra(MyPOSUtil.INTENT_SKIP_CONFIRMATION_SCREEN, skipConfirmationScreen);
myposIntent.putExtra(MyPOSUtil.INTENT_TRANSFER_TIPS_ENABLED, payment.isTippingModeEnabled());
myposIntent.putExtra(MyPOSUtil.INTENT_TRANSACTION_CURRENCY, payment.getCurrency().toString());
myposIntent.putExtra(MyPOSUtil.INTENT_TRANSACTION_FOREIGN_TRANSACTION_ID, payment.getForeignTransactionId());
myposIntent.putExtra(MyPOSUtil.INTENT_PRINT_MERCHANT_RECEIPT, payment.getPrintMerchantReceipt());
myposIntent.putExtra(MyPOSUtil.INTENT_PRINT_CUSTOMER_RECEIPT, payment.getPrintCustomerReceipt());
myposIntent.putExtra(MyPOSUtil.INTENT_OPERATOR_CODE, payment.getOperatorCode());
myposIntent.putExtra(MyPOSUtil.INTENT_REFERENCE_NUMBER, payment.getReferenceNumber());
myposIntent.putExtra(MyPOSUtil.INTENT_REFERENCE_NUMBER_TYPE, payment.getReferenceType());
myposIntent.putExtra(MyPOSUtil.INTENT_MOTO_PASSWORD, payment.getMotoPassword());
console.log(myposIntent);
application.android.foregroundActivity.startActivityForResult(myposIntent, 1);
} catch (e) {
console.log(e);
}
}
When I execute it, this is the live log from the device (adb logcat)
I/JS ( 6712): '*************** ++++++++++++++ ******************'
I/JS ( 6712): 'INTENT_TRANSACTION_REQUEST_CODE' 101
I/JS ( 6712): 'INTENT_TRANSACTION_AMOUNT' {}
D/alsa_pcm( 144): pcm_open:,sparams.stop_threshold:1540, config->stop_threshold:0
V/audio_hw_primary( 144): do not use out resampler
I/JS ( 6712): 'INTENT_TRANSACTION_TIP_AMOUNT' {}
I/JS ( 6712): 'INTENT_SKIP_CONFIRMATION_SCREEN' false
I/JS ( 6712): 'INTENT_TRANSFER_TIPS_ENABLED' false
I/JS ( 6712): 'INTENT_TRANSACTION_CURRENCY' 'EUR'
I/JS ( 6712): 'INTENT_TRANSACTION_FOREIGN_TRANSACTION_ID' '4b3d6780-b87e-4633-bf0f-76a43f963847'
I/JS ( 6712): 'INTENT_PRINT_MERCHANT_RECEIPT' 0
I/JS ( 6712): 'INTENT_PRINT_CUSTOMER_RECEIPT' 0
I/JS ( 6712): 'INTENT_OPERATOR_CODE' null
I/JS ( 6712): 'INTENT_REFERENCE_NUMBER' null
I/JS ( 6712): 'INTENT_REFERENCE_NUMBER_TYPE' 0
I/JS ( 6712): 'INTENT_MOTO_PASSWORD' null
I/JS ( 6712): '*************** ++++++++++++++ ******************'
I/JS ( 6712): {}
W/DeviceManager( 488): ++++++++++switch == true
E/DeviceManager( 488): +++switch = true action=com.mypos.transaction.START_TRANSACTION packageName= callingPackage=sellfer.pos className=
W/PAXDROID/PaxCustomerManager( 488): Runtime: /data/app/com.mypos-2.apk is in the whitelist, no need to verify it at run time.
W/ActivityManager( 488): startActivityMayWait() packageName = com.mypos, appSourcePath = /data/app/com.mypos-2.apk
I/ActivityManager( 488): START u0 {act=com.mypos.transaction.START_TRANSACTION cmp=com.mypos/.ui.activity.PaymentActivity (has extras)} from pid 6712
E/ActivityManager( 488): hbc:home_stack_is_frant_stack = false
E/ActivityManager( 488): hbc:mService.mBooting = false
E/ActivityManager( 488): hbc:home_stack_is_frant_stack = false
E/ActivityManager( 488): hbc:mService.mBooting = false
D/ConnectivityService( 488): onUidRulesChanged(uid=10058, uidRules=0)
D/IPP_IPPS_com.pax.ipp.service.IppStub( 1501): 01-17 03:10:59.065 CLIENT: 6.5
D/IPP_IPPS_com.pax.ipp.service.IppStub( 1501): 01-17 03:10:59.066 SERVICE: 6.6
D/ipps ( 1600): file>>>/storage/emulated/0/neptune/app.db
D/ipps ( 1600): insert Db>>>SQLiteDatabase: /storage/emulated/0/neptune/app.db
D/ipps ( 1600): after insert Db>>>0
D/IPP_IPPS_com.pax.ipp.service.IppStub( 1501): 01-17 03:10:59.110 CLIENT: 6.5
D/IPP_IPPS_com.pax.ipp.service.IppStub( 1501): 01-17 03:10:59.112 SERVICE: 6.6
D/ipps ( 1600): file>>>/storage/emulated/0/neptune/app.db
D/ipps ( 1600): insert Db>>>SQLiteDatabase: /storage/emulated/0/neptune/app.db
D/ipps ( 1600): after insert Db>>>0
E/SpdevServerThread( 771): msg from sp
E/SpdevServerThread( 771): get a message msg.cmd=3
E/SpdevServerThread( 771): sp icon
E/SpdevServerThread( 771): subcmd is:0x04
E/SpdevServerThread( 771): msg is:0x00
W/ContextImpl( 771): Calling a method in the system process without a qualified user: android.app.ContextImpl.sendBroadcast:1214 android.content.ContextWrapper.sendBroadcast:372 com.pax.daemon.observer.ServerService$2.onIconEvent:498 com.pax.daemon.server.SpdevServerThread.notifyIconStatusObserver:268 com.pax.daemon.server.SpdevServerThread.msg_handler:67
E/IcCardStatusReceive( 668): onReceive=com.pax.intent.action.ICCSTATUS
W/InputMethodManagerService( 488): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy#420ab808 attribute=null, token = android.os.BinderProxy#422039d8
E/ActivityManager( 488): hbc:home_stack_is_frant_stack = false
E/ActivityManager( 488): hbc:mService.mBooting = false
D/ConnectivityService( 488): onUidRulesChanged(uid=10058, uidRules=0)
D/IPP_IPPS_com.pax.ipp.manager.Terminal( 1501): 01-17 03:10:59.473 HOLDED BY=, RECENT IS=1600, HOLDER IS RECENT=false
D/IPP_IPPS_com.pax.ipp.manager.Terminal( 1501): 01-17 03:10:59.474 HAS RELEASED=true
D/IPP_IPPI_com.pax.ippi.impl.NeptuneUser( 1600): 01-17 03:10:59.477 unRegister
D/DeviceManagerService( 488): setNavigationBarInvisible: invisible=false
W/DeviceManagerService( 488): setBackKeyDisable disable = false
D/DeviceManagerService( 488): setHomeKeyDisable disable=false
D/DeviceManagerService( 488): setRecentKeyDisable disable=false
D/audio_hw_primary( 144): out_standby
D/BatteryService( 488): huangbc ... shutdownIfBatteryNotPresent call ...
D/BatteryService( 488): huangbc ... shutdownIfBatteryNotPresent call ...
D/PowerManagerService( 488): mHoldBootFastWakeLock = true
I/PowerUI ( 546): mIntentReceiver action=android.intent.action.BATTERY_CHANGED
E/PaxSmartDeviceManagerService( 668): mBatteryReceiver=BATTERY_STATUS_CHARGING
D/ConnectivityService( 488): Sampling interval elapsed, updating statistics ..
D/ConnectivityService( 488): Done.
D/ConnectivityService( 488): Setting timer for 30seconds
D/AlarmManager( 488): hbc ... set alarm:package = android, type = 3, triggerAtTime = 4792556, windowLength = -1, interval = 0
E/PaxSmartDeviceManagerService( 668): MyTimerTask------
What should happen is to switch to device's Payment activity, but nothing happens on the screen.
This part of the log hints me that my function actually trying to do the thing, but something is wrong, but I'm new with Nativescript and android.
W/DeviceManager( 488): ++++++++++switch == true
E/DeviceManager( 488): +++switch = true action=com.mypos.transaction.START_TRANSACTION packageName= callingPackage=sellfer.pos className=
W/PAXDROID/PaxCustomerManager( 488): Runtime: /data/app/com.mypos-2.apk is in the whitelist, no need to verify it at run time.
W/ActivityManager( 488): startActivityMayWait() packageName = com.mypos, appSourcePath = /data/app/com.mypos-2.apk
I/ActivityManager( 488): START u0 {act=com.mypos.transaction.START_TRANSACTION cmp=com.mypos/.ui.activity.PaymentActivity (has extras)} from pid 6712
Related
Wxpython dynamically changes the content of Choice
The problem is that there are two Choice drop-down boxes in the UI, the content of the second box is initially empty, and when the user selects an option in the first box, the corresponding option appears in the second box。 For example, if the first box is month, the second box is day, and the user selects January, then the second box has 1... . 31, the user chooses February, the second frame is 1... 28。 My code is as follows. ` import wx class myFrame(wx.Frame): def __init__(self): wx.Frame.__init__ ( self, None, id = wx.ID_ANY, title = wx.EmptyString, pos = wx.DefaultPosition, size = wx.Size( 500,300 ), style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL ) self.SetSizeHints( wx.DefaultSize, wx.DefaultSize ) bSizer9 = wx.BoxSizer( wx.VERTICAL ) self.m_staticText14 = wx.StaticText( self, wx.ID_ANY, u"select Month", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_staticText14.Wrap( -1 ) bSizer9.Add( self.m_staticText14, 0, wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 5 ) # select month m_choice1Choices = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"] self.m_choice1 = wx.Choice( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, m_choice1Choices, 0 ) self.m_choice1.SetSelection( 0 ) bSizer9.Add( self.m_choice1, 0, wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 5 ) self.m_staticText15 = wx.StaticText( self, wx.ID_ANY, u"select Day", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_staticText15.Wrap( -1 ) bSizer9.Add( self.m_staticText15, 0, wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 5 ) # select day m_choice2Choices = [str(i) for i in range(1,31)] self.m_choice2 = wx.Choice( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, m_choice2Choices, 0 ) self.m_choice2.SetSelection( 0 ) bSizer9.Add( self.m_choice2, 0, wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 5 ) self.SetSizer( bSizer9 ) self.Layout() self.Centre( wx.BOTH ) app = wx.App() myFrame().Show() app.MainLoop() `
The problem does not really reside in the wx.Choice instead it's how do I offer different day options for different months. The Choice issue is simply addressed by changes to the items in its list and that can be done by a Bind to the Month choice. Simply put, if the Month is changed, alter the list of days as appropriate to the month. (The ditty, "30 days hath September, April, June and November. All the rest have 31, excepting February alone") Below, somewhat untested but you get the idea, I Bind the month choice to a callback which resets the list of days for the chosen month. As a side note, check your range command, the stop value is where it stops, so range(1,31) will give you 1...30 import wx import datetime from calendar import monthrange year = datetime.datetime.now().year month_days = [] for i in range(1,13): month_days.append(monthrange(year,i)[1]) class myFrame(wx.Frame): def __init__(self): wx.Frame.__init__ ( self, None, id = wx.ID_ANY, title = wx.EmptyString, pos = wx.DefaultPosition, size = wx.Size( 500,300 ), style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL ) self.SetSizeHints( wx.DefaultSize, wx.DefaultSize ) bSizer9 = wx.BoxSizer( wx.VERTICAL ) self.m_staticText14 = wx.StaticText( self, wx.ID_ANY, u"select Month", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_staticText14.Wrap( -1 ) bSizer9.Add( self.m_staticText14, 0, wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 5 ) # select month m_choice1Choices = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"] self.m_choice1 = wx.Choice( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, m_choice1Choices, 0 ) self.m_choice1.SetSelection( 0 ) bSizer9.Add( self.m_choice1, 0, wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 5 ) self.m_staticText15 = wx.StaticText( self, wx.ID_ANY, u"select Day", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_staticText15.Wrap( -1 ) bSizer9.Add( self.m_staticText15, 0, wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 5 ) # select day #m_choice2Choices = [str(i) for i in range(1,31)] mth_idx = self.m_choice1.GetSelection() self.m_choice2Choices = [str(i) for i in range(1,month_days[mth_idx]+1)] self.m_choice2 = wx.Choice( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, self.m_choice2Choices, 0 ) self.m_choice2.SetSelection( 0 ) bSizer9.Add( self.m_choice2, 0, wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 5 ) self.m_choice1.Bind(wx.EVT_CHOICE, self.DaysInMonth) self.SetSizer( bSizer9 ) self.Layout() self.Centre( wx.BOTH ) def DaysInMonth(self, event): mth_idx = self.m_choice1.GetSelection() self.m_choice2Choices = [str(i) for i in range(1,month_days[mth_idx]+1)] self.m_choice2.SetItems(self.m_choice2Choices) app = wx.App() myFrame().Show() app.MainLoop()
lua corona - How to load an image using loadRemoteImage
I want to load an image from a URL. I can load an image using this code: local group = display.newGroup(); local testImg; testImg = display.newImage( "cells/cellBottom.png"); group:insert( testImg ); but i need to use something like: testImg = display.loadRemoteImage( "https://www.dropbox.com/s/fqlwsa5gupt5rsj/amcCells.png") group:insert( testImg ); Please tell me how to load this image. Cheers :)
Just use example given in Corona. This works with the following url but your url seems to have problem. local function networkListener( event ) if ( event.isError ) then print ( "Network error - download failed" ) else event.target.alpha = 0 transition.to( event.target, { alpha = 1.0 } ) end print ( "event.response.fullPath: ", event.response.fullPath ) print ( "event.response.filename: ", event.response.filename ) print ( "event.response.baseDirectory: ", event.response.baseDirectory ) end display.loadRemoteImage( "http://coronalabs.com/images/coronalogogrey.png", "GET", networkListener, "coronalogogrey.png", system.TemporaryDirectory, 50, 50 )
try add yougroup:insert(event.target) in listener local function networkListener( event ) if ( event.isError ) then print ( "Network error - download failed" ) else event.target.alpha = 0 transition.to( event.target, { alpha = 1.0 } ) **yourgroup:insert(event.target)** end print ( "event.response.fullPath: ", event.response.fullPath ) print ( "event.response.filename: ", event.response.filename ) print ( "event.response.baseDirectory: ", event.response.baseDirectory ) end display.loadRemoteImage( "http://coronalabs.com/images/coronalogogrey.png", "GET", networkListener, "coronalogogrey.png", system.TemporaryDirectory, 50, 50 )
QGraphicsView freezes when zooming under Win32
I use QGraphicsView and QGraphicsScene to display a map - a lot of object (lines, images, polygons, etc). I implemented zooming the view this way: ... void MapView::wheelEvent( QWheelEvent *pEvent ) { if ( pEvent->modifiers() & Qt::ControlModifier ) { if ( pEvent->delta() > 0 ) zoomIn(); else zoomOut(); pEvent->accept(); } else { QGraphicsView::wheelEvent( pEvent ); } } ... void MapView::zoomIn( int nValue ) { m_dZoom = ( nValue == -1 ) ? qMin( ( m_dZoom + m_dZoomStep ), m_dZoomMax ) : qMin( ( m_dZoom + qreal( nValue ) ), m_dZoomMax ); setupTransform(); } void MapView::zoomOut( int nValue ) { m_dZoom = ( nValue == -1 ) ? qMax( ( m_dZoom - m_dZoomStep ), m_dZoomMin ) : qMax( ( m_dZoom - qreal( nValue ) ), m_dZoomMin ); setupTransform(); } ... void MapView::setupTransform() { QTransform t = transform(); t.reset(); qreal dScale = qPow( qreal( 2 ), ( m_dZoom - ( m_dZoomMax / 4 ) ) / qreal( 50 ) ); t.scale( dScale, dScale ); setTransform( t ); emit onZoomChanged( m_dZoom ); } ... When I run application on Linux (CentOS 6.3, Qt 4.8) - zooming the view runs very good (smoothly). But when I run it on Windows (Windows 7 32bit, Qt 5.4) zoomig the view freezes - I constanly rotate the mouse wheel with no effect (no zooming, the view is not responding), and after a second or two later the view starts responding again. When this happens current zoom position turned out to be correctly set - it seems like the view were zooming but not updating the picture. The problem occurs with different zoom values and scroll positions, but always when the view is going to crop map objects (paths). Do you have any ideas how to fix that problem, or am I doing something wrong? Thank you very much in advance.
handle events in corona lua
Iam new to corona, so I dont know how to organize my code to best. I am trying to regiser click when user click on leftHam image, but I dont how to do it most efficently. Right now I am getting leftHam is nil although on creation it should be assinged a value. local composer = require( "composer" ) local widget = require( "widget" ) local scene = composer.newScene() local _H = display.contentHeight local _W = display.contentWidth leftNavBtn = nil local navbarGroup function scene:create( event ) local sceneGroup = self.view local background = display.newImage("res/bg.png" ) background:scale( _W, _H ) background.x = _W background.y = _H local navbarGroup = display.newContainer(_W, _H/4) navbarGroup.x = _W /2 --navbarGroup.y = 0 local top_bar = display.newImage("res/home/top_bar.png") top_bar.y = top_bar.height/2 navbarGroup:insert(top_bar) --local leftNavBtn = display.newImageRect("res/home/hamburger.png", 100, 100) leftNavBtn.y = leftNavBtn.height/1.5 leftNavBtn.x = - navbarGroup.width/2 + leftNavBtn.width leftNavBtn = display.newImageRect("res/home/hamburger.png", 100, 100) leftNavBtn.y = leftNavBtn.height/1.5 leftNavBtn.x = - navbarGroup.width/2 + leftNavBtn.width navbarGroup:insert(leftNavBtn) local rightNavBtn = display.newImageRect("res/home/hamburger.png", 100, 100) rightNavBtn.y = leftNavBtn.height/1.5 rightNavBtn.x = navbarGroup.width/2 - leftNavBtn.width navbarGroup:insert(rightNavBtn) end function test() print("clickedddddddddddd") end function leftNavBtn:touch(event) if event.phase == "began" then display.getCurrentStage( ):setFocus(self) self.isFocus = true elseif self.isFocus then if event.phase == "moved" then print("moved") elseif event.phase == "ended" or event.phase == "cancelled" then display.getCurrentStage( ):setFocus(nil) self.isFocus = false end end return true end leftNavBtn:addEventListener( "touch", test ) scene:addEventListener( "create", scene ) return scene
Do you mean leftNavBtn because leftHam doesn't exist anywhere. You are creating leftNavBtn in scene:create but are attempting to use it before calling that function anywhere (the leftNavBtn:addEventListener( "touch", test )) line. Within scene:create you also use leftNavBtn before creating it because you commented out this line local leftNavBtn = display.newImageRect("res/home/hamburger.png", 100, 100) without commenting out the two lines after it (which set of three lines you then duplicate immediately after that).
Dynamic image creation with touch action in corona
I have touch problem with dynamic image creation. my code is local widget = require "widget" --Hide status bar display.setStatusBar( display.HiddenStatusBar ) --bg image local backgroundPortrait = display.newImage( "background.png", 0, 0 ) --local image1Group --image1Group = display.newGroup() --3 frames local frame1 = display.newImageRect( "icon_1.png", 75, 75 ) frame1:setReferencePoint( display.CenterReferencePoint ) frame1.x = 160 frame1.y = 120 local frame2 = display.newImageRect( "icon_2.png", 75, 75 ) frame2:setReferencePoint( display.CenterReferencePoint ) frame2.x = 60 frame2.y = 360 local frame3 = display.newImageRect( "icon_3.png", 75, 75 ) frame3:setReferencePoint( display.CenterReferencePoint ) frame3.x = 260 frame3.y = 360 -- Center image function createImage() centerFrame = display.newImageRect( "additionalvampire1.jpg", 75, 75 ) centerFrame:setReferencePoint( display.CenterReferencePoint ) centerFrame.x = display.contentCenterX centerFrame.y = display.contentCenterY centerFrame:addEventListener("touch", centerFrame) end createImage() function removeTouchEventFun() centerFrame:removeEventListener("touch", centerFrame) end function transitionCompleted(centerFrame) print("transitionCompleted called") removeTouchEventFun() centerFrame:removeSelf() centerFrame=nil createImage() end function centerFrame:touch(event) if event.phase == "began" then self.markX = self.x -- store x location of object self.markY = self.y -- store y location of object elseif event.phase == "moved" then local x = (event.x - event.xStart) + self.markX local y = (event.y - event.yStart) + self.markY self.x, self.y = x, y -- move object based on calculations above elseif event.phase == "ended" then if (centerFrame.x<=160 and centerFrame.y>=240) then transition.to( centerFrame, { time=1000, alpha=1, x=60, y=360, width=1 ,height=1, onComplete= transitionCompleted } ) elseif (centerFrame.x>=160 and centerFrame.y>=240) then transition.to( centerFrame, { time=1000, alpha=1, x=260, y=360, width=1 ,height=1, onComplete= transitionCompleted } ) else transition.to( centerFrame, { time=1000, alpha=1, x=160, y=120, width=1 ,height=1, onComplete= transitionCompleted } ) end end return true end when drag the image to any one frame it is zoom-out and remove the object and create the another image. for this image touch not working... i need image creation with touch action when the image transition compete method. what should i do?...
local centerFrame function transitionCompleted(centerFrame) print("transitionCompleted called") if(centerFrame) then centerFrame:removeSelf() centerFrame=nil createImage() end end function onCenterFrameTouch(event) //your code here end function createImage() centerFrame = display.newImageRect( "additionalvampire1.jpg", 75, 75 ) centerFrame:setReferencePoint( display.CenterReferencePoint ) centerFrame.x = display.contentCenterX centerFrame.y = display.contentCenterY centerFrame:addEventListener("touch", onCenterFrameTouch) end